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 { Some(()) } else { None }
2615    }
2616
2617    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2618    fn decode(
2619        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2620    ) -> Result<AudioCapturerEvent, fidl::Error> {
2621        let (bytes, _handles) = buf.split_mut();
2622        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2623        debug_assert_eq!(tx_header.tx_id, 0);
2624        match tx_header.ordinal {
2625            0x6bbe69746a3c8bd9 => {
2626                let mut out = fidl::new_empty!(
2627                    StreamSourceOnPacketProducedRequest,
2628                    fidl::encoding::DefaultFuchsiaResourceDialect
2629                );
2630                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2631                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2632            }
2633            0x550e69b41d03e2c2 => {
2634                let mut out = fidl::new_empty!(
2635                    fidl::encoding::EmptyPayload,
2636                    fidl::encoding::DefaultFuchsiaResourceDialect
2637                );
2638                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2639                Ok((AudioCapturerEvent::OnEndOfStream {}))
2640            }
2641            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2642                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2643            }
2644            _ => Err(fidl::Error::UnknownOrdinal {
2645                ordinal: tx_header.ordinal,
2646                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2647            }),
2648        }
2649    }
2650}
2651
2652/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2653pub struct AudioCapturerRequestStream {
2654    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2655    is_terminated: bool,
2656}
2657
2658impl std::marker::Unpin for AudioCapturerRequestStream {}
2659
2660impl futures::stream::FusedStream for AudioCapturerRequestStream {
2661    fn is_terminated(&self) -> bool {
2662        self.is_terminated
2663    }
2664}
2665
2666impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2667    type Protocol = AudioCapturerMarker;
2668    type ControlHandle = AudioCapturerControlHandle;
2669
2670    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2671        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2672    }
2673
2674    fn control_handle(&self) -> Self::ControlHandle {
2675        AudioCapturerControlHandle { inner: self.inner.clone() }
2676    }
2677
2678    fn into_inner(
2679        self,
2680    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2681    {
2682        (self.inner, self.is_terminated)
2683    }
2684
2685    fn from_inner(
2686        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2687        is_terminated: bool,
2688    ) -> Self {
2689        Self { inner, is_terminated }
2690    }
2691}
2692
2693impl futures::Stream for AudioCapturerRequestStream {
2694    type Item = Result<AudioCapturerRequest, fidl::Error>;
2695
2696    fn poll_next(
2697        mut self: std::pin::Pin<&mut Self>,
2698        cx: &mut std::task::Context<'_>,
2699    ) -> std::task::Poll<Option<Self::Item>> {
2700        let this = &mut *self;
2701        if this.inner.check_shutdown(cx) {
2702            this.is_terminated = true;
2703            return std::task::Poll::Ready(None);
2704        }
2705        if this.is_terminated {
2706            panic!("polled AudioCapturerRequestStream after completion");
2707        }
2708        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2709            |bytes, handles| {
2710                match this.inner.channel().read_etc(cx, bytes, handles) {
2711                    std::task::Poll::Ready(Ok(())) => {}
2712                    std::task::Poll::Pending => return std::task::Poll::Pending,
2713                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2714                        this.is_terminated = true;
2715                        return std::task::Poll::Ready(None);
2716                    }
2717                    std::task::Poll::Ready(Err(e)) => {
2718                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2719                            e.into(),
2720                        ))));
2721                    }
2722                }
2723
2724                // A message has been received from the channel
2725                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2726
2727                std::task::Poll::Ready(Some(match header.ordinal {
2728                    0x3b3a37fc34fe5b56 => {
2729                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2730                        let mut req = fidl::new_empty!(
2731                            StreamBufferSetAddPayloadBufferRequest,
2732                            fidl::encoding::DefaultFuchsiaResourceDialect
2733                        );
2734                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2735                        let control_handle =
2736                            AudioCapturerControlHandle { inner: this.inner.clone() };
2737                        Ok(AudioCapturerRequest::AddPayloadBuffer {
2738                            id: req.id,
2739                            payload_buffer: req.payload_buffer,
2740
2741                            control_handle,
2742                        })
2743                    }
2744                    0x5d1e4f74c3658262 => {
2745                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2746                        let mut req = fidl::new_empty!(
2747                            StreamBufferSetRemovePayloadBufferRequest,
2748                            fidl::encoding::DefaultFuchsiaResourceDialect
2749                        );
2750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2751                        let control_handle =
2752                            AudioCapturerControlHandle { inner: this.inner.clone() };
2753                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
2754                    }
2755                    0x7a7b57f0f7d9e4bb => {
2756                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2757                        let mut req = fidl::new_empty!(
2758                            StreamSourceReleasePacketRequest,
2759                            fidl::encoding::DefaultFuchsiaResourceDialect
2760                        );
2761                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2762                        let control_handle =
2763                            AudioCapturerControlHandle { inner: this.inner.clone() };
2764                        Ok(AudioCapturerRequest::ReleasePacket {
2765                            packet: req.packet,
2766
2767                            control_handle,
2768                        })
2769                    }
2770                    0x27afd605e97b09d2 => {
2771                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2772                        let mut req = fidl::new_empty!(
2773                            fidl::encoding::EmptyPayload,
2774                            fidl::encoding::DefaultFuchsiaResourceDialect
2775                        );
2776                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2777                        let control_handle =
2778                            AudioCapturerControlHandle { inner: this.inner.clone() };
2779                        Ok(AudioCapturerRequest::DiscardAllPackets {
2780                            responder: AudioCapturerDiscardAllPacketsResponder {
2781                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2782                                tx_id: header.tx_id,
2783                            },
2784                        })
2785                    }
2786                    0x35f9d721e905b831 => {
2787                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2788                        let mut req = fidl::new_empty!(
2789                            fidl::encoding::EmptyPayload,
2790                            fidl::encoding::DefaultFuchsiaResourceDialect
2791                        );
2792                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2793                        let control_handle =
2794                            AudioCapturerControlHandle { inner: this.inner.clone() };
2795                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
2796                    }
2797                    0x1531ea9ea2c852cd => {
2798                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2799                        let mut req = fidl::new_empty!(
2800                            AudioCapturerSetPcmStreamTypeRequest,
2801                            fidl::encoding::DefaultFuchsiaResourceDialect
2802                        );
2803                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2804                        let control_handle =
2805                            AudioCapturerControlHandle { inner: this.inner.clone() };
2806                        Ok(AudioCapturerRequest::SetPcmStreamType {
2807                            stream_type: req.stream_type,
2808
2809                            control_handle,
2810                        })
2811                    }
2812                    0x784e25df72cea780 => {
2813                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2814                        let mut req = fidl::new_empty!(
2815                            AudioCapturerCaptureAtRequest,
2816                            fidl::encoding::DefaultFuchsiaResourceDialect
2817                        );
2818                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2819                        let control_handle =
2820                            AudioCapturerControlHandle { inner: this.inner.clone() };
2821                        Ok(AudioCapturerRequest::CaptureAt {
2822                            payload_buffer_id: req.payload_buffer_id,
2823                            payload_offset: req.payload_offset,
2824                            frames: req.frames,
2825
2826                            responder: AudioCapturerCaptureAtResponder {
2827                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2828                                tx_id: header.tx_id,
2829                            },
2830                        })
2831                    }
2832                    0x7768adbb1ccfd7a6 => {
2833                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2834                        let mut req = fidl::new_empty!(
2835                            AudioCapturerStartAsyncCaptureRequest,
2836                            fidl::encoding::DefaultFuchsiaResourceDialect
2837                        );
2838                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2839                        let control_handle =
2840                            AudioCapturerControlHandle { inner: this.inner.clone() };
2841                        Ok(AudioCapturerRequest::StartAsyncCapture {
2842                            frames_per_packet: req.frames_per_packet,
2843
2844                            control_handle,
2845                        })
2846                    }
2847                    0x5bfc8790a8cef8cb => {
2848                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2849                        let mut req = fidl::new_empty!(
2850                            fidl::encoding::EmptyPayload,
2851                            fidl::encoding::DefaultFuchsiaResourceDialect
2852                        );
2853                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2854                        let control_handle =
2855                            AudioCapturerControlHandle { inner: this.inner.clone() };
2856                        Ok(AudioCapturerRequest::StopAsyncCapture {
2857                            responder: AudioCapturerStopAsyncCaptureResponder {
2858                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2859                                tx_id: header.tx_id,
2860                            },
2861                        })
2862                    }
2863                    0x33223cb2962c95e3 => {
2864                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2865                        let mut req = fidl::new_empty!(
2866                            fidl::encoding::EmptyPayload,
2867                            fidl::encoding::DefaultFuchsiaResourceDialect
2868                        );
2869                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2870                        let control_handle =
2871                            AudioCapturerControlHandle { inner: this.inner.clone() };
2872                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
2873                    }
2874                    0x658a6a17ddb3a8e0 => {
2875                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2876                        let mut req = fidl::new_empty!(
2877                            AudioCapturerBindGainControlRequest,
2878                            fidl::encoding::DefaultFuchsiaResourceDialect
2879                        );
2880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2881                        let control_handle =
2882                            AudioCapturerControlHandle { inner: this.inner.clone() };
2883                        Ok(AudioCapturerRequest::BindGainControl {
2884                            gain_control_request: req.gain_control_request,
2885
2886                            control_handle,
2887                        })
2888                    }
2889                    0x50d037aa5a4b4d71 => {
2890                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2891                        let mut req = fidl::new_empty!(
2892                            fidl::encoding::EmptyPayload,
2893                            fidl::encoding::DefaultFuchsiaResourceDialect
2894                        );
2895                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2896                        let control_handle =
2897                            AudioCapturerControlHandle { inner: this.inner.clone() };
2898                        Ok(AudioCapturerRequest::GetReferenceClock {
2899                            responder: AudioCapturerGetReferenceClockResponder {
2900                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2901                                tx_id: header.tx_id,
2902                            },
2903                        })
2904                    }
2905                    0x732b2c496d521bcf => {
2906                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2907                        let mut req = fidl::new_empty!(
2908                            AudioCapturerSetReferenceClockRequest,
2909                            fidl::encoding::DefaultFuchsiaResourceDialect
2910                        );
2911                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2912                        let control_handle =
2913                            AudioCapturerControlHandle { inner: this.inner.clone() };
2914                        Ok(AudioCapturerRequest::SetReferenceClock {
2915                            reference_clock: req.reference_clock,
2916
2917                            control_handle,
2918                        })
2919                    }
2920                    0x42a16f392bd21b25 => {
2921                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2922                        let mut req = fidl::new_empty!(
2923                            AudioCapturerSetUsageRequest,
2924                            fidl::encoding::DefaultFuchsiaResourceDialect
2925                        );
2926                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2927                        let control_handle =
2928                            AudioCapturerControlHandle { inner: this.inner.clone() };
2929                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
2930                    }
2931                    0x7a73e251b8d2382b => {
2932                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2933                        let mut req = fidl::new_empty!(
2934                            AudioCapturerSetUsage2Request,
2935                            fidl::encoding::DefaultFuchsiaResourceDialect
2936                        );
2937                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2938                        let control_handle =
2939                            AudioCapturerControlHandle { inner: this.inner.clone() };
2940                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
2941                    }
2942                    0x5dcaaa670b433088 => {
2943                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2944                        let mut req = fidl::new_empty!(
2945                            fidl::encoding::EmptyPayload,
2946                            fidl::encoding::DefaultFuchsiaResourceDialect
2947                        );
2948                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2949                        let control_handle =
2950                            AudioCapturerControlHandle { inner: this.inner.clone() };
2951                        Ok(AudioCapturerRequest::GetStreamType {
2952                            responder: AudioCapturerGetStreamTypeResponder {
2953                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2954                                tx_id: header.tx_id,
2955                            },
2956                        })
2957                    }
2958                    _ if header.tx_id == 0
2959                        && header
2960                            .dynamic_flags()
2961                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2962                    {
2963                        Ok(AudioCapturerRequest::_UnknownMethod {
2964                            ordinal: header.ordinal,
2965                            control_handle: AudioCapturerControlHandle {
2966                                inner: this.inner.clone(),
2967                            },
2968                            method_type: fidl::MethodType::OneWay,
2969                        })
2970                    }
2971                    _ if header
2972                        .dynamic_flags()
2973                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2974                    {
2975                        this.inner.send_framework_err(
2976                            fidl::encoding::FrameworkErr::UnknownMethod,
2977                            header.tx_id,
2978                            header.ordinal,
2979                            header.dynamic_flags(),
2980                            (bytes, handles),
2981                        )?;
2982                        Ok(AudioCapturerRequest::_UnknownMethod {
2983                            ordinal: header.ordinal,
2984                            control_handle: AudioCapturerControlHandle {
2985                                inner: this.inner.clone(),
2986                            },
2987                            method_type: fidl::MethodType::TwoWay,
2988                        })
2989                    }
2990                    _ => Err(fidl::Error::UnknownOrdinal {
2991                        ordinal: header.ordinal,
2992                        protocol_name:
2993                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2994                    }),
2995                }))
2996            },
2997        )
2998    }
2999}
3000
3001/// AudioCapturer
3002///
3003/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3004/// CreateAudioCapturer method, which may be used by clients to capture audio
3005/// from either the current default audio input device, or the current default
3006/// audio output device depending on the flags passed during creation.
3007///
3008/// **Format support**
3009///
3010/// See (Get|Set)StreamType below. By default, the captured stream type will be
3011/// initially determined by the currently configured stream type of the source
3012/// that the AudioCapturer was bound to at creation time. Users may either fetch
3013/// this type using GetStreamType, or they may choose to have the media
3014/// resampled or converted to a type of their choosing by calling SetStreamType.
3015/// Note: the stream type may only be set while the system is not running,
3016/// meaning that there are no pending capture regions (specified using CaptureAt)
3017/// and that the system is not currently running in 'async' capture mode.
3018///
3019/// **Buffers and memory management**
3020///
3021/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3022/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3023/// following requirements related to the management of the payload buffer.
3024///
3025/// + The payload buffer must be supplied before any capture operation may
3026///   start. Any attempt to start capture (via either CaptureAt or
3027///   StartAsyncCapture) before a payload buffer has been established is an
3028///   error.
3029/// + The payload buffer may not be changed while there are any capture
3030///   operations pending.
3031/// + The stream type may not be changed after the payload buffer has been set.
3032/// + The payload buffer must be an integral number of audio frame sizes (in
3033///   bytes)
3034/// + When running in 'async' mode (see below), the payload buffer must be at
3035///   least as large as twice the frames_per_packet size specified during
3036///   StartAsyncCapture.
3037/// + The handle to the payload buffer supplied by the user must be readable,
3038///   writable, mappable and transferable.
3039/// + Users should always treat the payload buffer as read-only.
3040///
3041/// **Synchronous vs. Asynchronous capture mode**
3042///
3043/// The AudioCapturer interface can be used in one of two mutually exclusive
3044/// modes: Synchronous and Asynchronous. A description of each mode and their
3045/// tradeoffs is given below.
3046///
3047/// **Synchronous mode**
3048///
3049/// By default, AudioCapturer instances are running in 'sync' mode. They will
3050/// only capture data when a user supplies at least one region to capture into
3051/// using the CaptureAt method. Regions supplied in this way will be filled in
3052/// the order that they are received and returned to the client as StreamPackets
3053/// via the return value of the CaptureAt method. If an AudioCapturer instance
3054/// has data to capture, but no place to put it (because there are no more
3055/// pending regions to fill), the next payload generated will indicate that their
3056/// has been an overflow by setting the Discontinuity flag on the next produced
3057/// StreamPacket. Synchronous mode may not be used in conjunction with
3058/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3059/// the system still regions supplied by CaptureAt waiting to be filled.
3060///
3061/// If a user has supplied regions to be filled by the AudioCapturer instance in
3062/// the past, but wishes to reclaim those regions, they may do so using the
3063/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3064/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3065/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3066/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3067/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3068/// overwrite any region of the payload buffer after a completed region is
3069/// returned, it may overwrite the unfilled portions of a partially filled
3070/// buffer which has been returned as a result of a DiscardAllPackets operation.
3071///
3072/// **Asynchronous mode**
3073///
3074/// While running in 'async' mode, clients do not need to explicitly supply
3075/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3076/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3077/// callback interface and the number of frames to capture per-callback. Once
3078/// running in async mode, the AudioCapturer instance will identify which
3079/// payload buffer regions to capture into, capture the specified number of
3080/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3081/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3082/// 'sync' mode using the StopAsyncCapture method.
3083///
3084/// It is considered an error to attempt any of the following operations.
3085///
3086/// + To attempt to enter 'async' capture mode when no payload buffer has been
3087///   established.
3088/// + To specify a number of frames to capture per payload which does not permit
3089///   at least two contiguous capture payloads to exist in the established
3090///   shared payload buffer simultaneously.
3091/// + To send a region to capture into using the CaptureAt method while the
3092///   AudioCapturer instance is running in 'async' mode.
3093/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3094///   running in 'async' mode.
3095/// + To attempt to re-start 'async' mode capturing without having first
3096///   stopped.
3097/// + To attempt any operation except for SetGain while in the process of
3098///   stopping.
3099///
3100/// **Synchronizing with a StopAsyncCapture operation**
3101///
3102/// Stopping asynchronous capture mode and returning to synchronous capture mode
3103/// is an operation which takes time. Aside from SetGain, users may not call any
3104/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3105/// (including calling StopAsyncCapture again) until after the stop operation has
3106/// completed. Because of this, it is important for users to be able to
3107/// synchronize with the stop operation. Two mechanisms are provided for doing
3108/// so.
3109///
3110/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3111/// callback has been called, they can be certain that stop operation is complete
3112/// and that the AudioCapturer instance has returned to synchronous operation
3113/// mode.
3114///
3115/// The second way to determine that a stop operation has completed is to use the
3116/// flags on the packets which get delivered via the user-supplied
3117/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3118/// asked to stop, any partially filled packet will be returned to the user, and
3119/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3120/// set on it to indicate that this is the final frame in the sequence. If
3121/// there is no partially filled packet to return, the AudioCapturer will
3122/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3123/// in order to deliver a packet with the end-of-stream flag set on it. Once
3124/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3125/// has finished the stop operation and returned to synchronous operating mode.
3126///
3127/// **Timing and Overflows**
3128///
3129/// All media packets produced by an AudioCapturer instance will have their PTS
3130/// field filled out with the capture time of the audio expressed as a timestamp
3131/// given by the reference clock timeline. Note: this timestamp is actually a
3132/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3133/// PTS) and is meant to represent the underlying system's best estimate of the
3134/// capture time of the first frame of audio, including all outboard and hardware
3135/// introduced buffering delay. As a result, all timestamps produced by an
3136/// AudioCapturer should be expected to be in the past relative to 'now' on the
3137/// stream's reference clock timeline.
3138///
3139/// The one exception to the "everything has an explicit timestamp" rule is when
3140/// discarding submitted regions while operating in synchronous mode. Discarded
3141/// packets have no data in them, but FIDL demands that all pending
3142/// method-return-value callbacks be executed. Because of this, the regions will
3143/// be returned to the user, but their timestamps will be set to
3144/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3145/// partially filled payload will have a valid timestamp, but a payload size
3146/// smaller than originally requested. The final discarded payload (if there
3147/// were any to discard) will be followed by an OnEndOfStream event.
3148///
3149/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3150/// the first frame of audio contained in the second packet was captured exactly
3151/// one nominal frame time after the final frame of audio in the first packet.
3152/// If this relationship does not hold, the second StreamPacket will have the
3153/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3154///
3155/// Even though explicit timestamps are provided on every StreamPacket produced,
3156/// users who have very precise timing requirements are encouraged to always
3157/// reason about time by counting frames delivered since the last discontinuity,
3158/// rather than simply using the raw capture timestamps. This is because the
3159/// explicit timestamps written on continuous packets may have a small amount of
3160/// rounding error based on whether or not the units of the capture timeline
3161/// reference clock are divisible by the chosen audio frame rate.
3162///
3163/// Users should always expect the first StreamPacket produced by an
3164/// AudioCapturer to have the discontinuous flag set on it (as there is no
3165/// previous packet to be continuous with). Similarly, the first StreamPacket
3166/// after a DiscardAllPackets or a Stop/Start cycle will always be
3167/// discontinuous. After that, there are only two reasons that a StreamPacket
3168/// will ever be discontinuous:
3169///
3170/// 1. The user is operating in synchronous mode and does not supply regions to
3171///    be filled quickly enough. If the next continuous frame of data has not
3172///    been captured by the time it needs to be purged from the source buffers,
3173///    an overflow has occurred and the AudioCapturer will flag the next captured
3174///    region as discontinuous.
3175/// 2. The user is operating in asynchronous mode and some internal error
3176///    prevents the AudioCapturer instance from capturing the next frame of audio
3177///    in a continuous fashion. This might be high system load or a hardware
3178///    error, but in general it is something which should never normally happen.
3179///    In practice, however, if it does, the next produced packet will be flagged
3180///    as being discontinuous.
3181///
3182/// **Synchronous vs. Asynchronous Trade-offs**
3183///
3184/// The choice of operating in synchronous vs. asynchronous mode is up to the
3185/// user, and depending on the user's requirements, there are some advantages and
3186/// disadvantages to each choice.
3187///
3188/// Synchronous mode requires only a single Zircon channel under the hood and can
3189/// achieve some small savings because of this. In addition, the user has
3190/// complete control over the buffer management. Users specify exactly where
3191/// audio will be captured to and in what order. Because of this, if users do
3192/// not need to always be capturing, it is simple to stop and restart the capture
3193/// later (just by ceasing to supply packets, then resuming later on). Payloads
3194/// do not need to be uniform in size either, clients may specify payloads of
3195/// whatever granularity is appropriate.
3196///
3197/// The primary downside of operating in synchronous mode is that two messages
3198/// will need to be sent for every packet to be captured. One to inform the
3199/// AudioCapturer of the instance to capture into, and one to inform the user
3200/// that the packet has been captured. This may end up increasing overhead and
3201/// potentially complicating client designs.
3202///
3203/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3204/// however, when operating in 'async' mode, AudioCapturer instances have no way
3205/// of knowing if a user is processing the StreamPackets being sent in a timely
3206/// fashion, and no way of automatically detecting an overflow condition. Users
3207/// of 'async' mode should be careful to use a buffer large enough to ensure that
3208/// they will be able to process their data before an AudioCapturer will be
3209/// forced to overwrite it.
3210#[derive(Debug)]
3211pub enum AudioCapturerRequest {
3212    /// Adds a payload buffer to the current buffer set associated with the
3213    /// connection. A `StreamPacket` struct reference a payload buffer in the
3214    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3215    ///
3216    /// A buffer with ID `id` must not be in the current set when this method is
3217    /// invoked, otherwise the service will close the connection.
3218    AddPayloadBuffer {
3219        id: u32,
3220        payload_buffer: fidl::Vmo,
3221        control_handle: AudioCapturerControlHandle,
3222    },
3223    /// Removes a payload buffer from the current buffer set associated with the
3224    /// connection.
3225    ///
3226    /// A buffer with ID `id` must exist in the current set when this method is
3227    /// invoked, otherwise the service will will close the connection.
3228    RemovePayloadBuffer {
3229        id: u32,
3230        control_handle: AudioCapturerControlHandle,
3231    },
3232    /// Releases payload memory associated with a packet previously delivered
3233    /// via `OnPacketProduced`.
3234    ReleasePacket {
3235        packet: StreamPacket,
3236        control_handle: AudioCapturerControlHandle,
3237    },
3238    DiscardAllPackets {
3239        responder: AudioCapturerDiscardAllPacketsResponder,
3240    },
3241    DiscardAllPacketsNoReply {
3242        control_handle: AudioCapturerControlHandle,
3243    },
3244    /// Sets the stream type of the stream to be delivered. Causes the source
3245    /// material to be reformatted/resampled if needed in order to produce the
3246    /// requested stream type. Must be called before the payload buffer is
3247    /// established.
3248    SetPcmStreamType {
3249        stream_type: AudioStreamType,
3250        control_handle: AudioCapturerControlHandle,
3251    },
3252    /// Explicitly specifies a region of the shared payload buffer for the audio
3253    /// input to capture into.
3254    CaptureAt {
3255        payload_buffer_id: u32,
3256        payload_offset: u32,
3257        frames: u32,
3258        responder: AudioCapturerCaptureAtResponder,
3259    },
3260    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3261    /// packets of exactly 'frames_per_packet' number of frames each. The
3262    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3263    /// of produced packets.
3264    StartAsyncCapture {
3265        frames_per_packet: u32,
3266        control_handle: AudioCapturerControlHandle,
3267    },
3268    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3269    /// that may be used by the client if explicit synchronization is needed.
3270    StopAsyncCapture {
3271        responder: AudioCapturerStopAsyncCaptureResponder,
3272    },
3273    StopAsyncCaptureNoReply {
3274        control_handle: AudioCapturerControlHandle,
3275    },
3276    /// Binds to the gain control for this AudioCapturer.
3277    BindGainControl {
3278        gain_control_request:
3279            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3280        control_handle: AudioCapturerControlHandle,
3281    },
3282    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3283    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3284    GetReferenceClock {
3285        responder: AudioCapturerGetReferenceClockResponder,
3286    },
3287    /// Sets the reference clock that controls this capturer's playback rate. If the input
3288    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3289    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3290    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3291    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3292    ///
3293    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3294    /// added. It also cannot be called a second time (even before capture).
3295    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3296    /// diverge at some later time, they should create a clone of the monotonic clock, set
3297    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3298    SetReferenceClock {
3299        reference_clock: Option<fidl::Clock>,
3300        control_handle: AudioCapturerControlHandle,
3301    },
3302    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3303    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3304    SetUsage {
3305        usage: AudioCaptureUsage,
3306        control_handle: AudioCapturerControlHandle,
3307    },
3308    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3309    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3310    SetUsage2 {
3311        usage: AudioCaptureUsage2,
3312        control_handle: AudioCapturerControlHandle,
3313    },
3314    /// Gets the currently configured stream type. Note: for an AudioCapturer
3315    /// which was just created and has not yet had its stream type explicitly
3316    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3317    /// was created -- of the source (input or looped-back output) to which the
3318    /// AudioCapturer is bound. Even if this matches the client's desired format,
3319    /// `SetPcmStreamType` must still be called.
3320    GetStreamType {
3321        responder: AudioCapturerGetStreamTypeResponder,
3322    },
3323    /// An interaction was received which does not match any known method.
3324    #[non_exhaustive]
3325    _UnknownMethod {
3326        /// Ordinal of the method that was called.
3327        ordinal: u64,
3328        control_handle: AudioCapturerControlHandle,
3329        method_type: fidl::MethodType,
3330    },
3331}
3332
3333impl AudioCapturerRequest {
3334    #[allow(irrefutable_let_patterns)]
3335    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3336        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3337        {
3338            Some((id, payload_buffer, control_handle))
3339        } else {
3340            None
3341        }
3342    }
3343
3344    #[allow(irrefutable_let_patterns)]
3345    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3346        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3347            Some((id, control_handle))
3348        } else {
3349            None
3350        }
3351    }
3352
3353    #[allow(irrefutable_let_patterns)]
3354    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3355        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3356            Some((packet, control_handle))
3357        } else {
3358            None
3359        }
3360    }
3361
3362    #[allow(irrefutable_let_patterns)]
3363    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3364        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3365            Some((responder))
3366        } else {
3367            None
3368        }
3369    }
3370
3371    #[allow(irrefutable_let_patterns)]
3372    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3373        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3374            Some((control_handle))
3375        } else {
3376            None
3377        }
3378    }
3379
3380    #[allow(irrefutable_let_patterns)]
3381    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3382        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3383            Some((stream_type, control_handle))
3384        } else {
3385            None
3386        }
3387    }
3388
3389    #[allow(irrefutable_let_patterns)]
3390    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3391        if let AudioCapturerRequest::CaptureAt {
3392            payload_buffer_id,
3393            payload_offset,
3394            frames,
3395            responder,
3396        } = self
3397        {
3398            Some((payload_buffer_id, payload_offset, frames, responder))
3399        } else {
3400            None
3401        }
3402    }
3403
3404    #[allow(irrefutable_let_patterns)]
3405    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3406        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3407        {
3408            Some((frames_per_packet, control_handle))
3409        } else {
3410            None
3411        }
3412    }
3413
3414    #[allow(irrefutable_let_patterns)]
3415    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3416        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3417            Some((responder))
3418        } else {
3419            None
3420        }
3421    }
3422
3423    #[allow(irrefutable_let_patterns)]
3424    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3425        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3426            Some((control_handle))
3427        } else {
3428            None
3429        }
3430    }
3431
3432    #[allow(irrefutable_let_patterns)]
3433    pub fn into_bind_gain_control(
3434        self,
3435    ) -> Option<(
3436        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3437        AudioCapturerControlHandle,
3438    )> {
3439        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3440        {
3441            Some((gain_control_request, control_handle))
3442        } else {
3443            None
3444        }
3445    }
3446
3447    #[allow(irrefutable_let_patterns)]
3448    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3449        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3450            Some((responder))
3451        } else {
3452            None
3453        }
3454    }
3455
3456    #[allow(irrefutable_let_patterns)]
3457    pub fn into_set_reference_clock(
3458        self,
3459    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3460        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3461            Some((reference_clock, control_handle))
3462        } else {
3463            None
3464        }
3465    }
3466
3467    #[allow(irrefutable_let_patterns)]
3468    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3469        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3470            Some((usage, control_handle))
3471        } else {
3472            None
3473        }
3474    }
3475
3476    #[allow(irrefutable_let_patterns)]
3477    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3478        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3479            Some((usage, control_handle))
3480        } else {
3481            None
3482        }
3483    }
3484
3485    #[allow(irrefutable_let_patterns)]
3486    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3487        if let AudioCapturerRequest::GetStreamType { responder } = self {
3488            Some((responder))
3489        } else {
3490            None
3491        }
3492    }
3493
3494    /// Name of the method defined in FIDL
3495    pub fn method_name(&self) -> &'static str {
3496        match *self {
3497            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3498            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3499            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3500            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3501            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3502            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3503            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3504            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3505            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3506            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3507            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3508            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3509            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3510            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3511            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3512            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3513            AudioCapturerRequest::_UnknownMethod {
3514                method_type: fidl::MethodType::OneWay, ..
3515            } => "unknown one-way method",
3516            AudioCapturerRequest::_UnknownMethod {
3517                method_type: fidl::MethodType::TwoWay, ..
3518            } => "unknown two-way method",
3519        }
3520    }
3521}
3522
3523#[derive(Debug, Clone)]
3524pub struct AudioCapturerControlHandle {
3525    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3526}
3527
3528impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3529    fn shutdown(&self) {
3530        self.inner.shutdown()
3531    }
3532    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3533        self.inner.shutdown_with_epitaph(status)
3534    }
3535
3536    fn is_closed(&self) -> bool {
3537        self.inner.channel().is_closed()
3538    }
3539    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3540        self.inner.channel().on_closed()
3541    }
3542
3543    #[cfg(target_os = "fuchsia")]
3544    fn signal_peer(
3545        &self,
3546        clear_mask: zx::Signals,
3547        set_mask: zx::Signals,
3548    ) -> Result<(), zx_status::Status> {
3549        use fidl::Peered;
3550        self.inner.channel().signal_peer(clear_mask, set_mask)
3551    }
3552}
3553
3554impl AudioCapturerControlHandle {
3555    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3556        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3557            (packet,),
3558            0,
3559            0x6bbe69746a3c8bd9,
3560            fidl::encoding::DynamicFlags::empty(),
3561        )
3562    }
3563
3564    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3565        self.inner.send::<fidl::encoding::EmptyPayload>(
3566            (),
3567            0,
3568            0x550e69b41d03e2c2,
3569            fidl::encoding::DynamicFlags::empty(),
3570        )
3571    }
3572}
3573
3574#[must_use = "FIDL methods require a response to be sent"]
3575#[derive(Debug)]
3576pub struct AudioCapturerDiscardAllPacketsResponder {
3577    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3578    tx_id: u32,
3579}
3580
3581/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3582/// if the responder is dropped without sending a response, so that the client
3583/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3584impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3585    fn drop(&mut self) {
3586        self.control_handle.shutdown();
3587        // Safety: drops once, never accessed again
3588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3589    }
3590}
3591
3592impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3593    type ControlHandle = AudioCapturerControlHandle;
3594
3595    fn control_handle(&self) -> &AudioCapturerControlHandle {
3596        &self.control_handle
3597    }
3598
3599    fn drop_without_shutdown(mut self) {
3600        // Safety: drops once, never accessed again due to mem::forget
3601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3602        // Prevent Drop from running (which would shut down the channel)
3603        std::mem::forget(self);
3604    }
3605}
3606
3607impl AudioCapturerDiscardAllPacketsResponder {
3608    /// Sends a response to the FIDL transaction.
3609    ///
3610    /// Sets the channel to shutdown if an error occurs.
3611    pub fn send(self) -> Result<(), fidl::Error> {
3612        let _result = self.send_raw();
3613        if _result.is_err() {
3614            self.control_handle.shutdown();
3615        }
3616        self.drop_without_shutdown();
3617        _result
3618    }
3619
3620    /// Similar to "send" but does not shutdown the channel if an error occurs.
3621    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3622        let _result = self.send_raw();
3623        self.drop_without_shutdown();
3624        _result
3625    }
3626
3627    fn send_raw(&self) -> Result<(), fidl::Error> {
3628        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3629            (),
3630            self.tx_id,
3631            0x27afd605e97b09d2,
3632            fidl::encoding::DynamicFlags::empty(),
3633        )
3634    }
3635}
3636
3637#[must_use = "FIDL methods require a response to be sent"]
3638#[derive(Debug)]
3639pub struct AudioCapturerCaptureAtResponder {
3640    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3641    tx_id: u32,
3642}
3643
3644/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3645/// if the responder is dropped without sending a response, so that the client
3646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3647impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3648    fn drop(&mut self) {
3649        self.control_handle.shutdown();
3650        // Safety: drops once, never accessed again
3651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3652    }
3653}
3654
3655impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3656    type ControlHandle = AudioCapturerControlHandle;
3657
3658    fn control_handle(&self) -> &AudioCapturerControlHandle {
3659        &self.control_handle
3660    }
3661
3662    fn drop_without_shutdown(mut self) {
3663        // Safety: drops once, never accessed again due to mem::forget
3664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3665        // Prevent Drop from running (which would shut down the channel)
3666        std::mem::forget(self);
3667    }
3668}
3669
3670impl AudioCapturerCaptureAtResponder {
3671    /// Sends a response to the FIDL transaction.
3672    ///
3673    /// Sets the channel to shutdown if an error occurs.
3674    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3675        let _result = self.send_raw(captured_packet);
3676        if _result.is_err() {
3677            self.control_handle.shutdown();
3678        }
3679        self.drop_without_shutdown();
3680        _result
3681    }
3682
3683    /// Similar to "send" but does not shutdown the channel if an error occurs.
3684    pub fn send_no_shutdown_on_err(
3685        self,
3686        mut captured_packet: &StreamPacket,
3687    ) -> Result<(), fidl::Error> {
3688        let _result = self.send_raw(captured_packet);
3689        self.drop_without_shutdown();
3690        _result
3691    }
3692
3693    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3694        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3695            (captured_packet,),
3696            self.tx_id,
3697            0x784e25df72cea780,
3698            fidl::encoding::DynamicFlags::empty(),
3699        )
3700    }
3701}
3702
3703#[must_use = "FIDL methods require a response to be sent"]
3704#[derive(Debug)]
3705pub struct AudioCapturerStopAsyncCaptureResponder {
3706    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3707    tx_id: u32,
3708}
3709
3710/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3711/// if the responder is dropped without sending a response, so that the client
3712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3713impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3714    fn drop(&mut self) {
3715        self.control_handle.shutdown();
3716        // Safety: drops once, never accessed again
3717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3718    }
3719}
3720
3721impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
3722    type ControlHandle = AudioCapturerControlHandle;
3723
3724    fn control_handle(&self) -> &AudioCapturerControlHandle {
3725        &self.control_handle
3726    }
3727
3728    fn drop_without_shutdown(mut self) {
3729        // Safety: drops once, never accessed again due to mem::forget
3730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3731        // Prevent Drop from running (which would shut down the channel)
3732        std::mem::forget(self);
3733    }
3734}
3735
3736impl AudioCapturerStopAsyncCaptureResponder {
3737    /// Sends a response to the FIDL transaction.
3738    ///
3739    /// Sets the channel to shutdown if an error occurs.
3740    pub fn send(self) -> Result<(), fidl::Error> {
3741        let _result = self.send_raw();
3742        if _result.is_err() {
3743            self.control_handle.shutdown();
3744        }
3745        self.drop_without_shutdown();
3746        _result
3747    }
3748
3749    /// Similar to "send" but does not shutdown the channel if an error occurs.
3750    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3751        let _result = self.send_raw();
3752        self.drop_without_shutdown();
3753        _result
3754    }
3755
3756    fn send_raw(&self) -> Result<(), fidl::Error> {
3757        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3758            (),
3759            self.tx_id,
3760            0x5bfc8790a8cef8cb,
3761            fidl::encoding::DynamicFlags::empty(),
3762        )
3763    }
3764}
3765
3766#[must_use = "FIDL methods require a response to be sent"]
3767#[derive(Debug)]
3768pub struct AudioCapturerGetReferenceClockResponder {
3769    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3770    tx_id: u32,
3771}
3772
3773/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3774/// if the responder is dropped without sending a response, so that the client
3775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3776impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3777    fn drop(&mut self) {
3778        self.control_handle.shutdown();
3779        // Safety: drops once, never accessed again
3780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3781    }
3782}
3783
3784impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
3785    type ControlHandle = AudioCapturerControlHandle;
3786
3787    fn control_handle(&self) -> &AudioCapturerControlHandle {
3788        &self.control_handle
3789    }
3790
3791    fn drop_without_shutdown(mut self) {
3792        // Safety: drops once, never accessed again due to mem::forget
3793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3794        // Prevent Drop from running (which would shut down the channel)
3795        std::mem::forget(self);
3796    }
3797}
3798
3799impl AudioCapturerGetReferenceClockResponder {
3800    /// Sends a response to the FIDL transaction.
3801    ///
3802    /// Sets the channel to shutdown if an error occurs.
3803    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3804        let _result = self.send_raw(reference_clock);
3805        if _result.is_err() {
3806            self.control_handle.shutdown();
3807        }
3808        self.drop_without_shutdown();
3809        _result
3810    }
3811
3812    /// Similar to "send" but does not shutdown the channel if an error occurs.
3813    pub fn send_no_shutdown_on_err(
3814        self,
3815        mut reference_clock: fidl::Clock,
3816    ) -> Result<(), fidl::Error> {
3817        let _result = self.send_raw(reference_clock);
3818        self.drop_without_shutdown();
3819        _result
3820    }
3821
3822    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3823        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3824            (reference_clock,),
3825            self.tx_id,
3826            0x50d037aa5a4b4d71,
3827            fidl::encoding::DynamicFlags::empty(),
3828        )
3829    }
3830}
3831
3832#[must_use = "FIDL methods require a response to be sent"]
3833#[derive(Debug)]
3834pub struct AudioCapturerGetStreamTypeResponder {
3835    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3836    tx_id: u32,
3837}
3838
3839/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3840/// if the responder is dropped without sending a response, so that the client
3841/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3842impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3843    fn drop(&mut self) {
3844        self.control_handle.shutdown();
3845        // Safety: drops once, never accessed again
3846        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3847    }
3848}
3849
3850impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
3851    type ControlHandle = AudioCapturerControlHandle;
3852
3853    fn control_handle(&self) -> &AudioCapturerControlHandle {
3854        &self.control_handle
3855    }
3856
3857    fn drop_without_shutdown(mut self) {
3858        // Safety: drops once, never accessed again due to mem::forget
3859        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3860        // Prevent Drop from running (which would shut down the channel)
3861        std::mem::forget(self);
3862    }
3863}
3864
3865impl AudioCapturerGetStreamTypeResponder {
3866    /// Sends a response to the FIDL transaction.
3867    ///
3868    /// Sets the channel to shutdown if an error occurs.
3869    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3870        let _result = self.send_raw(stream_type);
3871        if _result.is_err() {
3872            self.control_handle.shutdown();
3873        }
3874        self.drop_without_shutdown();
3875        _result
3876    }
3877
3878    /// Similar to "send" but does not shutdown the channel if an error occurs.
3879    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3880        let _result = self.send_raw(stream_type);
3881        self.drop_without_shutdown();
3882        _result
3883    }
3884
3885    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3886        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3887            (stream_type,),
3888            self.tx_id,
3889            0x5dcaaa670b433088,
3890            fidl::encoding::DynamicFlags::empty(),
3891        )
3892    }
3893}
3894
3895#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3896pub struct AudioConsumerMarker;
3897
3898impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
3899    type Proxy = AudioConsumerProxy;
3900    type RequestStream = AudioConsumerRequestStream;
3901    #[cfg(target_os = "fuchsia")]
3902    type SynchronousProxy = AudioConsumerSynchronousProxy;
3903
3904    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3905}
3906
3907pub trait AudioConsumerProxyInterface: Send + Sync {
3908    fn r#create_stream_sink(
3909        &self,
3910        buffers: Vec<fidl::Vmo>,
3911        stream_type: &AudioStreamType,
3912        compression: Option<&Compression>,
3913        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3914    ) -> Result<(), fidl::Error>;
3915    fn r#start(
3916        &self,
3917        flags: AudioConsumerStartFlags,
3918        reference_time: i64,
3919        media_time: i64,
3920    ) -> Result<(), fidl::Error>;
3921    fn r#stop(&self) -> Result<(), fidl::Error>;
3922    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3923    fn r#bind_volume_control(
3924        &self,
3925        volume_control_request: fidl::endpoints::ServerEnd<
3926            fidl_fuchsia_media_audio::VolumeControlMarker,
3927        >,
3928    ) -> Result<(), fidl::Error>;
3929    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3930        + Send;
3931    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3932}
3933#[derive(Debug)]
3934#[cfg(target_os = "fuchsia")]
3935pub struct AudioConsumerSynchronousProxy {
3936    client: fidl::client::sync::Client,
3937}
3938
3939#[cfg(target_os = "fuchsia")]
3940impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
3941    type Proxy = AudioConsumerProxy;
3942    type Protocol = AudioConsumerMarker;
3943
3944    fn from_channel(inner: fidl::Channel) -> Self {
3945        Self::new(inner)
3946    }
3947
3948    fn into_channel(self) -> fidl::Channel {
3949        self.client.into_channel()
3950    }
3951
3952    fn as_channel(&self) -> &fidl::Channel {
3953        self.client.as_channel()
3954    }
3955}
3956
3957#[cfg(target_os = "fuchsia")]
3958impl AudioConsumerSynchronousProxy {
3959    pub fn new(channel: fidl::Channel) -> Self {
3960        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3961        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3962    }
3963
3964    pub fn into_channel(self) -> fidl::Channel {
3965        self.client.into_channel()
3966    }
3967
3968    /// Waits until an event arrives and returns it. It is safe for other
3969    /// threads to make concurrent requests while waiting for an event.
3970    pub fn wait_for_event(
3971        &self,
3972        deadline: zx::MonotonicInstant,
3973    ) -> Result<AudioConsumerEvent, fidl::Error> {
3974        AudioConsumerEvent::decode(self.client.wait_for_event(deadline)?)
3975    }
3976
3977    /// Creates a `StreamSink` for the consumer with the indicated properties.
3978    ///
3979    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3980    /// sequentially rather than concurrently. The first stream sink that's created using this
3981    /// method is used as the sole source of packets incoming to the logical consumer until that
3982    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3983    /// the second stream sink is used, and so on.
3984    ///
3985    /// If an unsupported compression type is supplied, the
3986    /// `stream_sink_request` request will be closed with an epitaph value of
3987    /// `ZX_ERR_INVALID_ARGS`.
3988    pub fn r#create_stream_sink(
3989        &self,
3990        mut buffers: Vec<fidl::Vmo>,
3991        mut stream_type: &AudioStreamType,
3992        mut compression: Option<&Compression>,
3993        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3994    ) -> Result<(), fidl::Error> {
3995        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
3996            (buffers.as_mut(), stream_type, compression, stream_sink_request),
3997            0x525b3b97fdf7d884,
3998            fidl::encoding::DynamicFlags::empty(),
3999        )
4000    }
4001
4002    /// Starts rendering as indicated by `flags`.
4003    ///
4004    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4005    /// Typically, this is the timestamp of the first packet that will be
4006    /// rendered. If packets will be supplied with no timestamps, this value
4007    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4008    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4009    ///     1. When starting for the first time, the default media time is the
4010    ///        timestamp on the first packet sent to the stream sink.
4011    ///     2. When resuming after stop, the default media time is the media
4012    ///        time at which the stream stopped.
4013    ///
4014    /// `reference_time` is the monotonic system time at which rendering should
4015    /// be started. For supply-driven sources, this must be the time at which
4016    /// the first packet was (or will be) sent plus a lead time, which must be
4017    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4018    /// sources, the client must ensure that the lead time requirement is met at
4019    /// the start time.  Passing the default value of 0 for `reference_time`
4020    /// causes the consumer to choose a start time based on the availability of
4021    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4022    /// specified.
4023    ///
4024    /// The actual start time will be reflected in the updated status.
4025    pub fn r#start(
4026        &self,
4027        mut flags: AudioConsumerStartFlags,
4028        mut reference_time: i64,
4029        mut media_time: i64,
4030    ) -> Result<(), fidl::Error> {
4031        self.client.send::<AudioConsumerStartRequest>(
4032            (flags, reference_time, media_time),
4033            0x4fdbd44b3f2a3a3c,
4034            fidl::encoding::DynamicFlags::empty(),
4035        )
4036    }
4037
4038    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4039    /// be reflected in the updated status.
4040    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4041        self.client.send::<fidl::encoding::EmptyPayload>(
4042            (),
4043            0x3d46c3741686c40d,
4044            fidl::encoding::DynamicFlags::empty(),
4045        )
4046    }
4047
4048    /// Requests to change the playback rate of the renderer. 1.0 means normal
4049    /// playback. Negative rates are not supported. The new rate will be
4050    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4051    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4052        self.client.send::<AudioConsumerSetRateRequest>(
4053            (rate,),
4054            0x45342b73968bfafe,
4055            fidl::encoding::DynamicFlags::empty(),
4056        )
4057    }
4058
4059    /// Binds to this `AudioConsumer` volume control for control and notifications.
4060    pub fn r#bind_volume_control(
4061        &self,
4062        mut volume_control_request: fidl::endpoints::ServerEnd<
4063            fidl_fuchsia_media_audio::VolumeControlMarker,
4064        >,
4065    ) -> Result<(), fidl::Error> {
4066        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4067            (volume_control_request,),
4068            0x6f1b01fd887f5748,
4069            fidl::encoding::DynamicFlags::empty(),
4070        )
4071    }
4072
4073    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4074    /// to this method when the status changes - initially with respect to the initial status value
4075    /// and thereafter with respect to the previously-reported status value.
4076    pub fn r#watch_status(
4077        &self,
4078        ___deadline: zx::MonotonicInstant,
4079    ) -> Result<AudioConsumerStatus, fidl::Error> {
4080        let _response = self
4081            .client
4082            .send_query::<fidl::encoding::EmptyPayload, AudioConsumerWatchStatusResponse>(
4083                (),
4084                0x35cf702c721e2cc6,
4085                fidl::encoding::DynamicFlags::empty(),
4086                ___deadline,
4087            )?;
4088        Ok(_response.status)
4089    }
4090}
4091
4092#[cfg(target_os = "fuchsia")]
4093impl From<AudioConsumerSynchronousProxy> for zx::Handle {
4094    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4095        value.into_channel().into()
4096    }
4097}
4098
4099#[cfg(target_os = "fuchsia")]
4100impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4101    fn from(value: fidl::Channel) -> Self {
4102        Self::new(value)
4103    }
4104}
4105
4106#[cfg(target_os = "fuchsia")]
4107impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4108    type Protocol = AudioConsumerMarker;
4109
4110    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4111        Self::new(value.into_channel())
4112    }
4113}
4114
4115#[derive(Debug, Clone)]
4116pub struct AudioConsumerProxy {
4117    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4118}
4119
4120impl fidl::endpoints::Proxy for AudioConsumerProxy {
4121    type Protocol = AudioConsumerMarker;
4122
4123    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4124        Self::new(inner)
4125    }
4126
4127    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4128        self.client.into_channel().map_err(|client| Self { client })
4129    }
4130
4131    fn as_channel(&self) -> &::fidl::AsyncChannel {
4132        self.client.as_channel()
4133    }
4134}
4135
4136impl AudioConsumerProxy {
4137    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4138    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4139        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4140        Self { client: fidl::client::Client::new(channel, protocol_name) }
4141    }
4142
4143    /// Get a Stream of events from the remote end of the protocol.
4144    ///
4145    /// # Panics
4146    ///
4147    /// Panics if the event stream was already taken.
4148    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
4149        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4150    }
4151
4152    /// Creates a `StreamSink` for the consumer with the indicated properties.
4153    ///
4154    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4155    /// sequentially rather than concurrently. The first stream sink that's created using this
4156    /// method is used as the sole source of packets incoming to the logical consumer until that
4157    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4158    /// the second stream sink is used, and so on.
4159    ///
4160    /// If an unsupported compression type is supplied, the
4161    /// `stream_sink_request` request will be closed with an epitaph value of
4162    /// `ZX_ERR_INVALID_ARGS`.
4163    pub fn r#create_stream_sink(
4164        &self,
4165        mut buffers: Vec<fidl::Vmo>,
4166        mut stream_type: &AudioStreamType,
4167        mut compression: Option<&Compression>,
4168        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4169    ) -> Result<(), fidl::Error> {
4170        AudioConsumerProxyInterface::r#create_stream_sink(
4171            self,
4172            buffers,
4173            stream_type,
4174            compression,
4175            stream_sink_request,
4176        )
4177    }
4178
4179    /// Starts rendering as indicated by `flags`.
4180    ///
4181    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4182    /// Typically, this is the timestamp of the first packet that will be
4183    /// rendered. If packets will be supplied with no timestamps, this value
4184    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4185    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4186    ///     1. When starting for the first time, the default media time is the
4187    ///        timestamp on the first packet sent to the stream sink.
4188    ///     2. When resuming after stop, the default media time is the media
4189    ///        time at which the stream stopped.
4190    ///
4191    /// `reference_time` is the monotonic system time at which rendering should
4192    /// be started. For supply-driven sources, this must be the time at which
4193    /// the first packet was (or will be) sent plus a lead time, which must be
4194    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4195    /// sources, the client must ensure that the lead time requirement is met at
4196    /// the start time.  Passing the default value of 0 for `reference_time`
4197    /// causes the consumer to choose a start time based on the availability of
4198    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4199    /// specified.
4200    ///
4201    /// The actual start time will be reflected in the updated status.
4202    pub fn r#start(
4203        &self,
4204        mut flags: AudioConsumerStartFlags,
4205        mut reference_time: i64,
4206        mut media_time: i64,
4207    ) -> Result<(), fidl::Error> {
4208        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4209    }
4210
4211    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4212    /// be reflected in the updated status.
4213    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4214        AudioConsumerProxyInterface::r#stop(self)
4215    }
4216
4217    /// Requests to change the playback rate of the renderer. 1.0 means normal
4218    /// playback. Negative rates are not supported. The new rate will be
4219    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4220    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4221        AudioConsumerProxyInterface::r#set_rate(self, rate)
4222    }
4223
4224    /// Binds to this `AudioConsumer` volume control for control and notifications.
4225    pub fn r#bind_volume_control(
4226        &self,
4227        mut volume_control_request: fidl::endpoints::ServerEnd<
4228            fidl_fuchsia_media_audio::VolumeControlMarker,
4229        >,
4230    ) -> Result<(), fidl::Error> {
4231        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4232    }
4233
4234    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4235    /// to this method when the status changes - initially with respect to the initial status value
4236    /// and thereafter with respect to the previously-reported status value.
4237    pub fn r#watch_status(
4238        &self,
4239    ) -> fidl::client::QueryResponseFut<
4240        AudioConsumerStatus,
4241        fidl::encoding::DefaultFuchsiaResourceDialect,
4242    > {
4243        AudioConsumerProxyInterface::r#watch_status(self)
4244    }
4245}
4246
4247impl AudioConsumerProxyInterface for AudioConsumerProxy {
4248    fn r#create_stream_sink(
4249        &self,
4250        mut buffers: Vec<fidl::Vmo>,
4251        mut stream_type: &AudioStreamType,
4252        mut compression: Option<&Compression>,
4253        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4254    ) -> Result<(), fidl::Error> {
4255        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4256            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4257            0x525b3b97fdf7d884,
4258            fidl::encoding::DynamicFlags::empty(),
4259        )
4260    }
4261
4262    fn r#start(
4263        &self,
4264        mut flags: AudioConsumerStartFlags,
4265        mut reference_time: i64,
4266        mut media_time: i64,
4267    ) -> Result<(), fidl::Error> {
4268        self.client.send::<AudioConsumerStartRequest>(
4269            (flags, reference_time, media_time),
4270            0x4fdbd44b3f2a3a3c,
4271            fidl::encoding::DynamicFlags::empty(),
4272        )
4273    }
4274
4275    fn r#stop(&self) -> Result<(), fidl::Error> {
4276        self.client.send::<fidl::encoding::EmptyPayload>(
4277            (),
4278            0x3d46c3741686c40d,
4279            fidl::encoding::DynamicFlags::empty(),
4280        )
4281    }
4282
4283    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4284        self.client.send::<AudioConsumerSetRateRequest>(
4285            (rate,),
4286            0x45342b73968bfafe,
4287            fidl::encoding::DynamicFlags::empty(),
4288        )
4289    }
4290
4291    fn r#bind_volume_control(
4292        &self,
4293        mut volume_control_request: fidl::endpoints::ServerEnd<
4294            fidl_fuchsia_media_audio::VolumeControlMarker,
4295        >,
4296    ) -> Result<(), fidl::Error> {
4297        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4298            (volume_control_request,),
4299            0x6f1b01fd887f5748,
4300            fidl::encoding::DynamicFlags::empty(),
4301        )
4302    }
4303
4304    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4305        AudioConsumerStatus,
4306        fidl::encoding::DefaultFuchsiaResourceDialect,
4307    >;
4308    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4309        fn _decode(
4310            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4311        ) -> Result<AudioConsumerStatus, fidl::Error> {
4312            let _response = fidl::client::decode_transaction_body::<
4313                AudioConsumerWatchStatusResponse,
4314                fidl::encoding::DefaultFuchsiaResourceDialect,
4315                0x35cf702c721e2cc6,
4316            >(_buf?)?;
4317            Ok(_response.status)
4318        }
4319        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4320            (),
4321            0x35cf702c721e2cc6,
4322            fidl::encoding::DynamicFlags::empty(),
4323            _decode,
4324        )
4325    }
4326}
4327
4328pub struct AudioConsumerEventStream {
4329    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4330}
4331
4332impl std::marker::Unpin for AudioConsumerEventStream {}
4333
4334impl futures::stream::FusedStream for AudioConsumerEventStream {
4335    fn is_terminated(&self) -> bool {
4336        self.event_receiver.is_terminated()
4337    }
4338}
4339
4340impl futures::Stream for AudioConsumerEventStream {
4341    type Item = Result<AudioConsumerEvent, fidl::Error>;
4342
4343    fn poll_next(
4344        mut self: std::pin::Pin<&mut Self>,
4345        cx: &mut std::task::Context<'_>,
4346    ) -> std::task::Poll<Option<Self::Item>> {
4347        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4348            &mut self.event_receiver,
4349            cx
4350        )?) {
4351            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4352            None => std::task::Poll::Ready(None),
4353        }
4354    }
4355}
4356
4357#[derive(Debug)]
4358pub enum AudioConsumerEvent {
4359    OnEndOfStream {},
4360}
4361
4362impl AudioConsumerEvent {
4363    #[allow(irrefutable_let_patterns)]
4364    pub fn into_on_end_of_stream(self) -> Option<()> {
4365        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
4366    }
4367
4368    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4369    fn decode(
4370        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4371    ) -> Result<AudioConsumerEvent, fidl::Error> {
4372        let (bytes, _handles) = buf.split_mut();
4373        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4374        debug_assert_eq!(tx_header.tx_id, 0);
4375        match tx_header.ordinal {
4376            0x53a64e6d0e8f8a20 => {
4377                let mut out = fidl::new_empty!(
4378                    fidl::encoding::EmptyPayload,
4379                    fidl::encoding::DefaultFuchsiaResourceDialect
4380                );
4381                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4382                Ok((AudioConsumerEvent::OnEndOfStream {}))
4383            }
4384            _ => Err(fidl::Error::UnknownOrdinal {
4385                ordinal: tx_header.ordinal,
4386                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4387            }),
4388        }
4389    }
4390}
4391
4392/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4393pub struct AudioConsumerRequestStream {
4394    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4395    is_terminated: bool,
4396}
4397
4398impl std::marker::Unpin for AudioConsumerRequestStream {}
4399
4400impl futures::stream::FusedStream for AudioConsumerRequestStream {
4401    fn is_terminated(&self) -> bool {
4402        self.is_terminated
4403    }
4404}
4405
4406impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4407    type Protocol = AudioConsumerMarker;
4408    type ControlHandle = AudioConsumerControlHandle;
4409
4410    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4411        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4412    }
4413
4414    fn control_handle(&self) -> Self::ControlHandle {
4415        AudioConsumerControlHandle { inner: self.inner.clone() }
4416    }
4417
4418    fn into_inner(
4419        self,
4420    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4421    {
4422        (self.inner, self.is_terminated)
4423    }
4424
4425    fn from_inner(
4426        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4427        is_terminated: bool,
4428    ) -> Self {
4429        Self { inner, is_terminated }
4430    }
4431}
4432
4433impl futures::Stream for AudioConsumerRequestStream {
4434    type Item = Result<AudioConsumerRequest, fidl::Error>;
4435
4436    fn poll_next(
4437        mut self: std::pin::Pin<&mut Self>,
4438        cx: &mut std::task::Context<'_>,
4439    ) -> std::task::Poll<Option<Self::Item>> {
4440        let this = &mut *self;
4441        if this.inner.check_shutdown(cx) {
4442            this.is_terminated = true;
4443            return std::task::Poll::Ready(None);
4444        }
4445        if this.is_terminated {
4446            panic!("polled AudioConsumerRequestStream after completion");
4447        }
4448        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4449            |bytes, handles| {
4450                match this.inner.channel().read_etc(cx, bytes, handles) {
4451                    std::task::Poll::Ready(Ok(())) => {}
4452                    std::task::Poll::Pending => return std::task::Poll::Pending,
4453                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4454                        this.is_terminated = true;
4455                        return std::task::Poll::Ready(None);
4456                    }
4457                    std::task::Poll::Ready(Err(e)) => {
4458                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4459                            e.into(),
4460                        ))));
4461                    }
4462                }
4463
4464                // A message has been received from the channel
4465                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4466
4467                std::task::Poll::Ready(Some(match header.ordinal {
4468                    0x525b3b97fdf7d884 => {
4469                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4470                        let mut req = fidl::new_empty!(
4471                            AudioConsumerCreateStreamSinkRequest,
4472                            fidl::encoding::DefaultFuchsiaResourceDialect
4473                        );
4474                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4475                        let control_handle =
4476                            AudioConsumerControlHandle { inner: this.inner.clone() };
4477                        Ok(AudioConsumerRequest::CreateStreamSink {
4478                            buffers: req.buffers,
4479                            stream_type: req.stream_type,
4480                            compression: req.compression,
4481                            stream_sink_request: req.stream_sink_request,
4482
4483                            control_handle,
4484                        })
4485                    }
4486                    0x4fdbd44b3f2a3a3c => {
4487                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4488                        let mut req = fidl::new_empty!(
4489                            AudioConsumerStartRequest,
4490                            fidl::encoding::DefaultFuchsiaResourceDialect
4491                        );
4492                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4493                        let control_handle =
4494                            AudioConsumerControlHandle { inner: this.inner.clone() };
4495                        Ok(AudioConsumerRequest::Start {
4496                            flags: req.flags,
4497                            reference_time: req.reference_time,
4498                            media_time: req.media_time,
4499
4500                            control_handle,
4501                        })
4502                    }
4503                    0x3d46c3741686c40d => {
4504                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4505                        let mut req = fidl::new_empty!(
4506                            fidl::encoding::EmptyPayload,
4507                            fidl::encoding::DefaultFuchsiaResourceDialect
4508                        );
4509                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4510                        let control_handle =
4511                            AudioConsumerControlHandle { inner: this.inner.clone() };
4512                        Ok(AudioConsumerRequest::Stop { control_handle })
4513                    }
4514                    0x45342b73968bfafe => {
4515                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4516                        let mut req = fidl::new_empty!(
4517                            AudioConsumerSetRateRequest,
4518                            fidl::encoding::DefaultFuchsiaResourceDialect
4519                        );
4520                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4521                        let control_handle =
4522                            AudioConsumerControlHandle { inner: this.inner.clone() };
4523                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4524                    }
4525                    0x6f1b01fd887f5748 => {
4526                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4527                        let mut req = fidl::new_empty!(
4528                            AudioConsumerBindVolumeControlRequest,
4529                            fidl::encoding::DefaultFuchsiaResourceDialect
4530                        );
4531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4532                        let control_handle =
4533                            AudioConsumerControlHandle { inner: this.inner.clone() };
4534                        Ok(AudioConsumerRequest::BindVolumeControl {
4535                            volume_control_request: req.volume_control_request,
4536
4537                            control_handle,
4538                        })
4539                    }
4540                    0x35cf702c721e2cc6 => {
4541                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4542                        let mut req = fidl::new_empty!(
4543                            fidl::encoding::EmptyPayload,
4544                            fidl::encoding::DefaultFuchsiaResourceDialect
4545                        );
4546                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4547                        let control_handle =
4548                            AudioConsumerControlHandle { inner: this.inner.clone() };
4549                        Ok(AudioConsumerRequest::WatchStatus {
4550                            responder: AudioConsumerWatchStatusResponder {
4551                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4552                                tx_id: header.tx_id,
4553                            },
4554                        })
4555                    }
4556                    _ => Err(fidl::Error::UnknownOrdinal {
4557                        ordinal: header.ordinal,
4558                        protocol_name:
4559                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4560                    }),
4561                }))
4562            },
4563        )
4564    }
4565}
4566
4567/// Interface for playing and controlling audio.
4568#[derive(Debug)]
4569pub enum AudioConsumerRequest {
4570    /// Creates a `StreamSink` for the consumer with the indicated properties.
4571    ///
4572    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4573    /// sequentially rather than concurrently. The first stream sink that's created using this
4574    /// method is used as the sole source of packets incoming to the logical consumer until that
4575    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4576    /// the second stream sink is used, and so on.
4577    ///
4578    /// If an unsupported compression type is supplied, the
4579    /// `stream_sink_request` request will be closed with an epitaph value of
4580    /// `ZX_ERR_INVALID_ARGS`.
4581    CreateStreamSink {
4582        buffers: Vec<fidl::Vmo>,
4583        stream_type: AudioStreamType,
4584        compression: Option<Box<Compression>>,
4585        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4586        control_handle: AudioConsumerControlHandle,
4587    },
4588    /// Starts rendering as indicated by `flags`.
4589    ///
4590    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4591    /// Typically, this is the timestamp of the first packet that will be
4592    /// rendered. If packets will be supplied with no timestamps, this value
4593    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4594    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4595    ///     1. When starting for the first time, the default media time is the
4596    ///        timestamp on the first packet sent to the stream sink.
4597    ///     2. When resuming after stop, the default media time is the media
4598    ///        time at which the stream stopped.
4599    ///
4600    /// `reference_time` is the monotonic system time at which rendering should
4601    /// be started. For supply-driven sources, this must be the time at which
4602    /// the first packet was (or will be) sent plus a lead time, which must be
4603    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4604    /// sources, the client must ensure that the lead time requirement is met at
4605    /// the start time.  Passing the default value of 0 for `reference_time`
4606    /// causes the consumer to choose a start time based on the availability of
4607    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4608    /// specified.
4609    ///
4610    /// The actual start time will be reflected in the updated status.
4611    Start {
4612        flags: AudioConsumerStartFlags,
4613        reference_time: i64,
4614        media_time: i64,
4615        control_handle: AudioConsumerControlHandle,
4616    },
4617    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4618    /// be reflected in the updated status.
4619    Stop { control_handle: AudioConsumerControlHandle },
4620    /// Requests to change the playback rate of the renderer. 1.0 means normal
4621    /// playback. Negative rates are not supported. The new rate will be
4622    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4623    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4624    /// Binds to this `AudioConsumer` volume control for control and notifications.
4625    BindVolumeControl {
4626        volume_control_request:
4627            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4628        control_handle: AudioConsumerControlHandle,
4629    },
4630    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4631    /// to this method when the status changes - initially with respect to the initial status value
4632    /// and thereafter with respect to the previously-reported status value.
4633    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4634}
4635
4636impl AudioConsumerRequest {
4637    #[allow(irrefutable_let_patterns)]
4638    pub fn into_create_stream_sink(
4639        self,
4640    ) -> Option<(
4641        Vec<fidl::Vmo>,
4642        AudioStreamType,
4643        Option<Box<Compression>>,
4644        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4645        AudioConsumerControlHandle,
4646    )> {
4647        if let AudioConsumerRequest::CreateStreamSink {
4648            buffers,
4649            stream_type,
4650            compression,
4651            stream_sink_request,
4652            control_handle,
4653        } = self
4654        {
4655            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4656        } else {
4657            None
4658        }
4659    }
4660
4661    #[allow(irrefutable_let_patterns)]
4662    pub fn into_start(
4663        self,
4664    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4665        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4666            self
4667        {
4668            Some((flags, reference_time, media_time, control_handle))
4669        } else {
4670            None
4671        }
4672    }
4673
4674    #[allow(irrefutable_let_patterns)]
4675    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4676        if let AudioConsumerRequest::Stop { control_handle } = self {
4677            Some((control_handle))
4678        } else {
4679            None
4680        }
4681    }
4682
4683    #[allow(irrefutable_let_patterns)]
4684    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4685        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4686            Some((rate, control_handle))
4687        } else {
4688            None
4689        }
4690    }
4691
4692    #[allow(irrefutable_let_patterns)]
4693    pub fn into_bind_volume_control(
4694        self,
4695    ) -> Option<(
4696        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4697        AudioConsumerControlHandle,
4698    )> {
4699        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4700            self
4701        {
4702            Some((volume_control_request, control_handle))
4703        } else {
4704            None
4705        }
4706    }
4707
4708    #[allow(irrefutable_let_patterns)]
4709    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4710        if let AudioConsumerRequest::WatchStatus { responder } = self {
4711            Some((responder))
4712        } else {
4713            None
4714        }
4715    }
4716
4717    /// Name of the method defined in FIDL
4718    pub fn method_name(&self) -> &'static str {
4719        match *self {
4720            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4721            AudioConsumerRequest::Start { .. } => "start",
4722            AudioConsumerRequest::Stop { .. } => "stop",
4723            AudioConsumerRequest::SetRate { .. } => "set_rate",
4724            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4725            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4726        }
4727    }
4728}
4729
4730#[derive(Debug, Clone)]
4731pub struct AudioConsumerControlHandle {
4732    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4733}
4734
4735impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
4736    fn shutdown(&self) {
4737        self.inner.shutdown()
4738    }
4739    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4740        self.inner.shutdown_with_epitaph(status)
4741    }
4742
4743    fn is_closed(&self) -> bool {
4744        self.inner.channel().is_closed()
4745    }
4746    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4747        self.inner.channel().on_closed()
4748    }
4749
4750    #[cfg(target_os = "fuchsia")]
4751    fn signal_peer(
4752        &self,
4753        clear_mask: zx::Signals,
4754        set_mask: zx::Signals,
4755    ) -> Result<(), zx_status::Status> {
4756        use fidl::Peered;
4757        self.inner.channel().signal_peer(clear_mask, set_mask)
4758    }
4759}
4760
4761impl AudioConsumerControlHandle {
4762    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4763        self.inner.send::<fidl::encoding::EmptyPayload>(
4764            (),
4765            0,
4766            0x53a64e6d0e8f8a20,
4767            fidl::encoding::DynamicFlags::empty(),
4768        )
4769    }
4770}
4771
4772#[must_use = "FIDL methods require a response to be sent"]
4773#[derive(Debug)]
4774pub struct AudioConsumerWatchStatusResponder {
4775    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4776    tx_id: u32,
4777}
4778
4779/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4780/// if the responder is dropped without sending a response, so that the client
4781/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4782impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4783    fn drop(&mut self) {
4784        self.control_handle.shutdown();
4785        // Safety: drops once, never accessed again
4786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4787    }
4788}
4789
4790impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
4791    type ControlHandle = AudioConsumerControlHandle;
4792
4793    fn control_handle(&self) -> &AudioConsumerControlHandle {
4794        &self.control_handle
4795    }
4796
4797    fn drop_without_shutdown(mut self) {
4798        // Safety: drops once, never accessed again due to mem::forget
4799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4800        // Prevent Drop from running (which would shut down the channel)
4801        std::mem::forget(self);
4802    }
4803}
4804
4805impl AudioConsumerWatchStatusResponder {
4806    /// Sends a response to the FIDL transaction.
4807    ///
4808    /// Sets the channel to shutdown if an error occurs.
4809    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4810        let _result = self.send_raw(status);
4811        if _result.is_err() {
4812            self.control_handle.shutdown();
4813        }
4814        self.drop_without_shutdown();
4815        _result
4816    }
4817
4818    /// Similar to "send" but does not shutdown the channel if an error occurs.
4819    pub fn send_no_shutdown_on_err(
4820        self,
4821        mut status: &AudioConsumerStatus,
4822    ) -> Result<(), fidl::Error> {
4823        let _result = self.send_raw(status);
4824        self.drop_without_shutdown();
4825        _result
4826    }
4827
4828    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4829        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4830            (status,),
4831            self.tx_id,
4832            0x35cf702c721e2cc6,
4833            fidl::encoding::DynamicFlags::empty(),
4834        )
4835    }
4836}
4837
4838#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4839pub struct AudioCoreMarker;
4840
4841impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
4842    type Proxy = AudioCoreProxy;
4843    type RequestStream = AudioCoreRequestStream;
4844    #[cfg(target_os = "fuchsia")]
4845    type SynchronousProxy = AudioCoreSynchronousProxy;
4846
4847    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4848}
4849impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
4850
4851pub trait AudioCoreProxyInterface: Send + Sync {
4852    fn r#create_audio_renderer(
4853        &self,
4854        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4855    ) -> Result<(), fidl::Error>;
4856    fn r#create_audio_capturer_with_configuration(
4857        &self,
4858        stream_type: &AudioStreamType,
4859        configuration: &AudioCapturerConfiguration,
4860        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4861    ) -> Result<(), fidl::Error>;
4862    fn r#create_audio_capturer(
4863        &self,
4864        loopback: bool,
4865        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4866    ) -> Result<(), fidl::Error>;
4867    fn r#set_render_usage_gain(
4868        &self,
4869        usage: AudioRenderUsage,
4870        gain_db: f32,
4871    ) -> Result<(), fidl::Error>;
4872    fn r#set_render_usage_gain2(
4873        &self,
4874        usage: AudioRenderUsage2,
4875        gain_db: f32,
4876    ) -> Result<(), fidl::Error>;
4877    fn r#set_capture_usage_gain(
4878        &self,
4879        usage: AudioCaptureUsage,
4880        gain_db: f32,
4881    ) -> Result<(), fidl::Error>;
4882    fn r#set_capture_usage_gain2(
4883        &self,
4884        usage: AudioCaptureUsage2,
4885        gain_db: f32,
4886    ) -> Result<(), fidl::Error>;
4887    fn r#bind_usage_volume_control(
4888        &self,
4889        usage: &Usage,
4890        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4891    ) -> Result<(), fidl::Error>;
4892    fn r#bind_usage_volume_control2(
4893        &self,
4894        usage: &Usage2,
4895        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4896    ) -> Result<(), fidl::Error>;
4897    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4898    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4899    -> Self::GetVolumeFromDbResponseFut;
4900    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4901    fn r#get_volume_from_db2(
4902        &self,
4903        usage: &Usage2,
4904        gain_db: f32,
4905    ) -> Self::GetVolumeFromDb2ResponseFut;
4906    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4907    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4908    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4909    fn r#get_db_from_volume2(
4910        &self,
4911        usage: &Usage2,
4912        volume: f32,
4913    ) -> Self::GetDbFromVolume2ResponseFut;
4914    fn r#set_interaction(
4915        &self,
4916        active: &Usage,
4917        affected: &Usage,
4918        behavior: Behavior,
4919    ) -> Result<(), fidl::Error>;
4920    fn r#set_interaction2(
4921        &self,
4922        active: &Usage2,
4923        affected: &Usage2,
4924        behavior: Behavior,
4925    ) -> Result<(), fidl::Error>;
4926    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4927    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4928}
4929#[derive(Debug)]
4930#[cfg(target_os = "fuchsia")]
4931pub struct AudioCoreSynchronousProxy {
4932    client: fidl::client::sync::Client,
4933}
4934
4935#[cfg(target_os = "fuchsia")]
4936impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
4937    type Proxy = AudioCoreProxy;
4938    type Protocol = AudioCoreMarker;
4939
4940    fn from_channel(inner: fidl::Channel) -> Self {
4941        Self::new(inner)
4942    }
4943
4944    fn into_channel(self) -> fidl::Channel {
4945        self.client.into_channel()
4946    }
4947
4948    fn as_channel(&self) -> &fidl::Channel {
4949        self.client.as_channel()
4950    }
4951}
4952
4953#[cfg(target_os = "fuchsia")]
4954impl AudioCoreSynchronousProxy {
4955    pub fn new(channel: fidl::Channel) -> Self {
4956        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4957        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4958    }
4959
4960    pub fn into_channel(self) -> fidl::Channel {
4961        self.client.into_channel()
4962    }
4963
4964    /// Waits until an event arrives and returns it. It is safe for other
4965    /// threads to make concurrent requests while waiting for an event.
4966    pub fn wait_for_event(
4967        &self,
4968        deadline: zx::MonotonicInstant,
4969    ) -> Result<AudioCoreEvent, fidl::Error> {
4970        AudioCoreEvent::decode(self.client.wait_for_event(deadline)?)
4971    }
4972
4973    /// Creates an AudioRenderer which outputs audio to the default device.
4974    pub fn r#create_audio_renderer(
4975        &self,
4976        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4977    ) -> Result<(), fidl::Error> {
4978        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4979            (audio_out_request,),
4980            0x2ac9beba47f83435,
4981            fidl::encoding::DynamicFlags::empty(),
4982        )
4983    }
4984
4985    /// Creates an AudioCapturer according to the given requirements.
4986    ///
4987    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4988    /// It causes the source material to be reformatted/resampled if needed
4989    /// in order to produce the requested stream type.
4990    ///
4991    /// `usage` is used by Fuchsia to make decisions about user experience.
4992    /// See `AudioCaptureUsage` for more details.
4993    ///
4994    /// `configuration` must be initialized to a variant, or no capturer
4995    /// can be created.
4996    pub fn r#create_audio_capturer_with_configuration(
4997        &self,
4998        mut stream_type: &AudioStreamType,
4999        mut configuration: &AudioCapturerConfiguration,
5000        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5001    ) -> Result<(), fidl::Error> {
5002        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5003            (stream_type, configuration, audio_capturer_request),
5004            0x459de383b0d76d97,
5005            fidl::encoding::DynamicFlags::empty(),
5006        )
5007    }
5008
5009    /// Creates an AudioCapturer which either captures from the current default
5010    /// audio input device, or loops-back from the current default audio output
5011    /// device based on value passed for the loopback flag.
5012    pub fn r#create_audio_capturer(
5013        &self,
5014        mut loopback: bool,
5015        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5016    ) -> Result<(), fidl::Error> {
5017        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5018            (loopback, audio_in_request),
5019            0x787db169df99aed0,
5020            fidl::encoding::DynamicFlags::empty(),
5021        )
5022    }
5023
5024    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5025    pub fn r#set_render_usage_gain(
5026        &self,
5027        mut usage: AudioRenderUsage,
5028        mut gain_db: f32,
5029    ) -> Result<(), fidl::Error> {
5030        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5031            (usage, gain_db),
5032            0x48097f45f6e2b8e7,
5033            fidl::encoding::DynamicFlags::empty(),
5034        )
5035    }
5036
5037    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5038    pub fn r#set_render_usage_gain2(
5039        &self,
5040        mut usage: AudioRenderUsage2,
5041        mut gain_db: f32,
5042    ) -> Result<(), fidl::Error> {
5043        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5044            (usage, gain_db),
5045            0x779b1531dc9e64f4,
5046            fidl::encoding::DynamicFlags::FLEXIBLE,
5047        )
5048    }
5049
5050    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5051    pub fn r#set_capture_usage_gain(
5052        &self,
5053        mut usage: AudioCaptureUsage,
5054        mut gain_db: f32,
5055    ) -> Result<(), fidl::Error> {
5056        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5057            (usage, gain_db),
5058            0x457d29217d4ea248,
5059            fidl::encoding::DynamicFlags::empty(),
5060        )
5061    }
5062
5063    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5064    pub fn r#set_capture_usage_gain2(
5065        &self,
5066        mut usage: AudioCaptureUsage2,
5067        mut gain_db: f32,
5068    ) -> Result<(), fidl::Error> {
5069        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5070            (usage, gain_db),
5071            0x15065ee308f44af0,
5072            fidl::encoding::DynamicFlags::FLEXIBLE,
5073        )
5074    }
5075
5076    /// Binds to a volume control protocol for the given usage.
5077    pub fn r#bind_usage_volume_control(
5078        &self,
5079        mut usage: &Usage,
5080        mut volume_control: fidl::endpoints::ServerEnd<
5081            fidl_fuchsia_media_audio::VolumeControlMarker,
5082        >,
5083    ) -> Result<(), fidl::Error> {
5084        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5085            (usage, volume_control),
5086            0x7225be116aadc137,
5087            fidl::encoding::DynamicFlags::empty(),
5088        )
5089    }
5090
5091    /// Binds to a volume control protocol for the given usage.
5092    pub fn r#bind_usage_volume_control2(
5093        &self,
5094        mut usage: &Usage2,
5095        mut volume_control: fidl::endpoints::ServerEnd<
5096            fidl_fuchsia_media_audio::VolumeControlMarker,
5097        >,
5098    ) -> Result<(), fidl::Error> {
5099        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5100            (usage, volume_control),
5101            0x729dff93019d055,
5102            fidl::encoding::DynamicFlags::FLEXIBLE,
5103        )
5104    }
5105
5106    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5107    /// `usage`. This is the same mapping as used by the VolumeControl from
5108    /// `BindUsageVolumeControl`.
5109    pub fn r#get_volume_from_db(
5110        &self,
5111        mut usage: &Usage,
5112        mut gain_db: f32,
5113        ___deadline: zx::MonotonicInstant,
5114    ) -> Result<f32, fidl::Error> {
5115        let _response = self
5116            .client
5117            .send_query::<AudioCoreGetVolumeFromDbRequest, AudioCoreGetVolumeFromDbResponse>(
5118                (usage, gain_db),
5119                0x50e3ca45509770bf,
5120                fidl::encoding::DynamicFlags::empty(),
5121                ___deadline,
5122            )?;
5123        Ok(_response.volume)
5124    }
5125
5126    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5127    /// `usage`. This is the same mapping as used by the VolumeControl from
5128    /// `BindUsageVolumeControl`.
5129    pub fn r#get_volume_from_db2(
5130        &self,
5131        mut usage: &Usage2,
5132        mut gain_db: f32,
5133        ___deadline: zx::MonotonicInstant,
5134    ) -> Result<f32, fidl::Error> {
5135        let _response = self.client.send_query::<
5136            AudioCoreGetVolumeFromDb2Request,
5137            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5138        >(
5139            (usage, gain_db,),
5140            0x165c811091ef99da,
5141            fidl::encoding::DynamicFlags::FLEXIBLE,
5142            ___deadline,
5143        )?
5144        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5145        Ok(_response.volume)
5146    }
5147
5148    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5149    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5150    pub fn r#get_db_from_volume(
5151        &self,
5152        mut usage: &Usage,
5153        mut volume: f32,
5154        ___deadline: zx::MonotonicInstant,
5155    ) -> Result<f32, fidl::Error> {
5156        let _response = self
5157            .client
5158            .send_query::<AudioCoreGetDbFromVolumeRequest, AudioCoreGetDbFromVolumeResponse>(
5159                (usage, volume),
5160                0x3e8eec27dd5a8bda,
5161                fidl::encoding::DynamicFlags::empty(),
5162                ___deadline,
5163            )?;
5164        Ok(_response.gain_db)
5165    }
5166
5167    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5168    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5169    pub fn r#get_db_from_volume2(
5170        &self,
5171        mut usage: &Usage2,
5172        mut volume: f32,
5173        ___deadline: zx::MonotonicInstant,
5174    ) -> Result<f32, fidl::Error> {
5175        let _response = self.client.send_query::<
5176            AudioCoreGetDbFromVolume2Request,
5177            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5178        >(
5179            (usage, volume,),
5180            0x5f421a8ebf265bf3,
5181            fidl::encoding::DynamicFlags::FLEXIBLE,
5182            ___deadline,
5183        )?
5184        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5185        Ok(_response.gain_db)
5186    }
5187
5188    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5189    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5190    /// the Behavior specified will be applied to the streams of Usage `affected`.
5191    pub fn r#set_interaction(
5192        &self,
5193        mut active: &Usage,
5194        mut affected: &Usage,
5195        mut behavior: Behavior,
5196    ) -> Result<(), fidl::Error> {
5197        self.client.send::<AudioCoreSetInteractionRequest>(
5198            (active, affected, behavior),
5199            0x7bfed14345ece7b7,
5200            fidl::encoding::DynamicFlags::empty(),
5201        )
5202    }
5203
5204    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5205    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5206    /// the Behavior specified will be applied to the streams of Usage `affected`.
5207    pub fn r#set_interaction2(
5208        &self,
5209        mut active: &Usage2,
5210        mut affected: &Usage2,
5211        mut behavior: Behavior,
5212    ) -> Result<(), fidl::Error> {
5213        self.client.send::<AudioCoreSetInteraction2Request>(
5214            (active, affected, behavior),
5215            0x7226c7c6e6edc62f,
5216            fidl::encoding::DynamicFlags::FLEXIBLE,
5217        )
5218    }
5219
5220    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5221    /// audio_core. The default behavior is 'NONE'.
5222    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5223        self.client.send::<fidl::encoding::EmptyPayload>(
5224            (),
5225            0x65bd94d9d0a28b5e,
5226            fidl::encoding::DynamicFlags::empty(),
5227        )
5228    }
5229
5230    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5231    /// does not provide a config.
5232    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5233        self.client.send::<fidl::encoding::EmptyPayload>(
5234            (),
5235            0x54a0bebca85f6b31,
5236            fidl::encoding::DynamicFlags::empty(),
5237        )
5238    }
5239}
5240
5241#[cfg(target_os = "fuchsia")]
5242impl From<AudioCoreSynchronousProxy> for zx::Handle {
5243    fn from(value: AudioCoreSynchronousProxy) -> Self {
5244        value.into_channel().into()
5245    }
5246}
5247
5248#[cfg(target_os = "fuchsia")]
5249impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5250    fn from(value: fidl::Channel) -> Self {
5251        Self::new(value)
5252    }
5253}
5254
5255#[cfg(target_os = "fuchsia")]
5256impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5257    type Protocol = AudioCoreMarker;
5258
5259    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5260        Self::new(value.into_channel())
5261    }
5262}
5263
5264#[derive(Debug, Clone)]
5265pub struct AudioCoreProxy {
5266    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5267}
5268
5269impl fidl::endpoints::Proxy for AudioCoreProxy {
5270    type Protocol = AudioCoreMarker;
5271
5272    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5273        Self::new(inner)
5274    }
5275
5276    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5277        self.client.into_channel().map_err(|client| Self { client })
5278    }
5279
5280    fn as_channel(&self) -> &::fidl::AsyncChannel {
5281        self.client.as_channel()
5282    }
5283}
5284
5285impl AudioCoreProxy {
5286    /// Create a new Proxy for fuchsia.media/AudioCore.
5287    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5288        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5289        Self { client: fidl::client::Client::new(channel, protocol_name) }
5290    }
5291
5292    /// Get a Stream of events from the remote end of the protocol.
5293    ///
5294    /// # Panics
5295    ///
5296    /// Panics if the event stream was already taken.
5297    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5298        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5299    }
5300
5301    /// Creates an AudioRenderer which outputs audio to the default device.
5302    pub fn r#create_audio_renderer(
5303        &self,
5304        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5305    ) -> Result<(), fidl::Error> {
5306        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5307    }
5308
5309    /// Creates an AudioCapturer according to the given requirements.
5310    ///
5311    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5312    /// It causes the source material to be reformatted/resampled if needed
5313    /// in order to produce the requested stream type.
5314    ///
5315    /// `usage` is used by Fuchsia to make decisions about user experience.
5316    /// See `AudioCaptureUsage` for more details.
5317    ///
5318    /// `configuration` must be initialized to a variant, or no capturer
5319    /// can be created.
5320    pub fn r#create_audio_capturer_with_configuration(
5321        &self,
5322        mut stream_type: &AudioStreamType,
5323        mut configuration: &AudioCapturerConfiguration,
5324        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5325    ) -> Result<(), fidl::Error> {
5326        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5327            self,
5328            stream_type,
5329            configuration,
5330            audio_capturer_request,
5331        )
5332    }
5333
5334    /// Creates an AudioCapturer which either captures from the current default
5335    /// audio input device, or loops-back from the current default audio output
5336    /// device based on value passed for the loopback flag.
5337    pub fn r#create_audio_capturer(
5338        &self,
5339        mut loopback: bool,
5340        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5341    ) -> Result<(), fidl::Error> {
5342        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5343    }
5344
5345    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5346    pub fn r#set_render_usage_gain(
5347        &self,
5348        mut usage: AudioRenderUsage,
5349        mut gain_db: f32,
5350    ) -> Result<(), fidl::Error> {
5351        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5352    }
5353
5354    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5355    pub fn r#set_render_usage_gain2(
5356        &self,
5357        mut usage: AudioRenderUsage2,
5358        mut gain_db: f32,
5359    ) -> Result<(), fidl::Error> {
5360        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5361    }
5362
5363    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5364    pub fn r#set_capture_usage_gain(
5365        &self,
5366        mut usage: AudioCaptureUsage,
5367        mut gain_db: f32,
5368    ) -> Result<(), fidl::Error> {
5369        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5370    }
5371
5372    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5373    pub fn r#set_capture_usage_gain2(
5374        &self,
5375        mut usage: AudioCaptureUsage2,
5376        mut gain_db: f32,
5377    ) -> Result<(), fidl::Error> {
5378        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5379    }
5380
5381    /// Binds to a volume control protocol for the given usage.
5382    pub fn r#bind_usage_volume_control(
5383        &self,
5384        mut usage: &Usage,
5385        mut volume_control: fidl::endpoints::ServerEnd<
5386            fidl_fuchsia_media_audio::VolumeControlMarker,
5387        >,
5388    ) -> Result<(), fidl::Error> {
5389        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5390    }
5391
5392    /// Binds to a volume control protocol for the given usage.
5393    pub fn r#bind_usage_volume_control2(
5394        &self,
5395        mut usage: &Usage2,
5396        mut volume_control: fidl::endpoints::ServerEnd<
5397            fidl_fuchsia_media_audio::VolumeControlMarker,
5398        >,
5399    ) -> Result<(), fidl::Error> {
5400        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5401    }
5402
5403    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5404    /// `usage`. This is the same mapping as used by the VolumeControl from
5405    /// `BindUsageVolumeControl`.
5406    pub fn r#get_volume_from_db(
5407        &self,
5408        mut usage: &Usage,
5409        mut gain_db: f32,
5410    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5411        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5412    }
5413
5414    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5415    /// `usage`. This is the same mapping as used by the VolumeControl from
5416    /// `BindUsageVolumeControl`.
5417    pub fn r#get_volume_from_db2(
5418        &self,
5419        mut usage: &Usage2,
5420        mut gain_db: f32,
5421    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5422        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5423    }
5424
5425    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5426    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5427    pub fn r#get_db_from_volume(
5428        &self,
5429        mut usage: &Usage,
5430        mut volume: f32,
5431    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5432        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5433    }
5434
5435    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5436    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5437    pub fn r#get_db_from_volume2(
5438        &self,
5439        mut usage: &Usage2,
5440        mut volume: f32,
5441    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5442        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5443    }
5444
5445    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5446    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5447    /// the Behavior specified will be applied to the streams of Usage `affected`.
5448    pub fn r#set_interaction(
5449        &self,
5450        mut active: &Usage,
5451        mut affected: &Usage,
5452        mut behavior: Behavior,
5453    ) -> Result<(), fidl::Error> {
5454        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5455    }
5456
5457    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5458    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5459    /// the Behavior specified will be applied to the streams of Usage `affected`.
5460    pub fn r#set_interaction2(
5461        &self,
5462        mut active: &Usage2,
5463        mut affected: &Usage2,
5464        mut behavior: Behavior,
5465    ) -> Result<(), fidl::Error> {
5466        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5467    }
5468
5469    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5470    /// audio_core. The default behavior is 'NONE'.
5471    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5472        AudioCoreProxyInterface::r#reset_interactions(self)
5473    }
5474
5475    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5476    /// does not provide a config.
5477    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5478        AudioCoreProxyInterface::r#load_defaults(self)
5479    }
5480}
5481
5482impl AudioCoreProxyInterface for AudioCoreProxy {
5483    fn r#create_audio_renderer(
5484        &self,
5485        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5486    ) -> Result<(), fidl::Error> {
5487        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5488            (audio_out_request,),
5489            0x2ac9beba47f83435,
5490            fidl::encoding::DynamicFlags::empty(),
5491        )
5492    }
5493
5494    fn r#create_audio_capturer_with_configuration(
5495        &self,
5496        mut stream_type: &AudioStreamType,
5497        mut configuration: &AudioCapturerConfiguration,
5498        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5499    ) -> Result<(), fidl::Error> {
5500        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5501            (stream_type, configuration, audio_capturer_request),
5502            0x459de383b0d76d97,
5503            fidl::encoding::DynamicFlags::empty(),
5504        )
5505    }
5506
5507    fn r#create_audio_capturer(
5508        &self,
5509        mut loopback: bool,
5510        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5511    ) -> Result<(), fidl::Error> {
5512        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5513            (loopback, audio_in_request),
5514            0x787db169df99aed0,
5515            fidl::encoding::DynamicFlags::empty(),
5516        )
5517    }
5518
5519    fn r#set_render_usage_gain(
5520        &self,
5521        mut usage: AudioRenderUsage,
5522        mut gain_db: f32,
5523    ) -> Result<(), fidl::Error> {
5524        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5525            (usage, gain_db),
5526            0x48097f45f6e2b8e7,
5527            fidl::encoding::DynamicFlags::empty(),
5528        )
5529    }
5530
5531    fn r#set_render_usage_gain2(
5532        &self,
5533        mut usage: AudioRenderUsage2,
5534        mut gain_db: f32,
5535    ) -> Result<(), fidl::Error> {
5536        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5537            (usage, gain_db),
5538            0x779b1531dc9e64f4,
5539            fidl::encoding::DynamicFlags::FLEXIBLE,
5540        )
5541    }
5542
5543    fn r#set_capture_usage_gain(
5544        &self,
5545        mut usage: AudioCaptureUsage,
5546        mut gain_db: f32,
5547    ) -> Result<(), fidl::Error> {
5548        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5549            (usage, gain_db),
5550            0x457d29217d4ea248,
5551            fidl::encoding::DynamicFlags::empty(),
5552        )
5553    }
5554
5555    fn r#set_capture_usage_gain2(
5556        &self,
5557        mut usage: AudioCaptureUsage2,
5558        mut gain_db: f32,
5559    ) -> Result<(), fidl::Error> {
5560        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5561            (usage, gain_db),
5562            0x15065ee308f44af0,
5563            fidl::encoding::DynamicFlags::FLEXIBLE,
5564        )
5565    }
5566
5567    fn r#bind_usage_volume_control(
5568        &self,
5569        mut usage: &Usage,
5570        mut volume_control: fidl::endpoints::ServerEnd<
5571            fidl_fuchsia_media_audio::VolumeControlMarker,
5572        >,
5573    ) -> Result<(), fidl::Error> {
5574        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5575            (usage, volume_control),
5576            0x7225be116aadc137,
5577            fidl::encoding::DynamicFlags::empty(),
5578        )
5579    }
5580
5581    fn r#bind_usage_volume_control2(
5582        &self,
5583        mut usage: &Usage2,
5584        mut volume_control: fidl::endpoints::ServerEnd<
5585            fidl_fuchsia_media_audio::VolumeControlMarker,
5586        >,
5587    ) -> Result<(), fidl::Error> {
5588        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5589            (usage, volume_control),
5590            0x729dff93019d055,
5591            fidl::encoding::DynamicFlags::FLEXIBLE,
5592        )
5593    }
5594
5595    type GetVolumeFromDbResponseFut =
5596        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5597    fn r#get_volume_from_db(
5598        &self,
5599        mut usage: &Usage,
5600        mut gain_db: f32,
5601    ) -> Self::GetVolumeFromDbResponseFut {
5602        fn _decode(
5603            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5604        ) -> Result<f32, fidl::Error> {
5605            let _response = fidl::client::decode_transaction_body::<
5606                AudioCoreGetVolumeFromDbResponse,
5607                fidl::encoding::DefaultFuchsiaResourceDialect,
5608                0x50e3ca45509770bf,
5609            >(_buf?)?;
5610            Ok(_response.volume)
5611        }
5612        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5613            (usage, gain_db),
5614            0x50e3ca45509770bf,
5615            fidl::encoding::DynamicFlags::empty(),
5616            _decode,
5617        )
5618    }
5619
5620    type GetVolumeFromDb2ResponseFut =
5621        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5622    fn r#get_volume_from_db2(
5623        &self,
5624        mut usage: &Usage2,
5625        mut gain_db: f32,
5626    ) -> Self::GetVolumeFromDb2ResponseFut {
5627        fn _decode(
5628            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5629        ) -> Result<f32, fidl::Error> {
5630            let _response = fidl::client::decode_transaction_body::<
5631                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5632                fidl::encoding::DefaultFuchsiaResourceDialect,
5633                0x165c811091ef99da,
5634            >(_buf?)?
5635            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5636            Ok(_response.volume)
5637        }
5638        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5639            (usage, gain_db),
5640            0x165c811091ef99da,
5641            fidl::encoding::DynamicFlags::FLEXIBLE,
5642            _decode,
5643        )
5644    }
5645
5646    type GetDbFromVolumeResponseFut =
5647        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5648    fn r#get_db_from_volume(
5649        &self,
5650        mut usage: &Usage,
5651        mut volume: f32,
5652    ) -> Self::GetDbFromVolumeResponseFut {
5653        fn _decode(
5654            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5655        ) -> Result<f32, fidl::Error> {
5656            let _response = fidl::client::decode_transaction_body::<
5657                AudioCoreGetDbFromVolumeResponse,
5658                fidl::encoding::DefaultFuchsiaResourceDialect,
5659                0x3e8eec27dd5a8bda,
5660            >(_buf?)?;
5661            Ok(_response.gain_db)
5662        }
5663        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5664            (usage, volume),
5665            0x3e8eec27dd5a8bda,
5666            fidl::encoding::DynamicFlags::empty(),
5667            _decode,
5668        )
5669    }
5670
5671    type GetDbFromVolume2ResponseFut =
5672        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5673    fn r#get_db_from_volume2(
5674        &self,
5675        mut usage: &Usage2,
5676        mut volume: f32,
5677    ) -> Self::GetDbFromVolume2ResponseFut {
5678        fn _decode(
5679            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5680        ) -> Result<f32, fidl::Error> {
5681            let _response = fidl::client::decode_transaction_body::<
5682                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5683                fidl::encoding::DefaultFuchsiaResourceDialect,
5684                0x5f421a8ebf265bf3,
5685            >(_buf?)?
5686            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5687            Ok(_response.gain_db)
5688        }
5689        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
5690            (usage, volume),
5691            0x5f421a8ebf265bf3,
5692            fidl::encoding::DynamicFlags::FLEXIBLE,
5693            _decode,
5694        )
5695    }
5696
5697    fn r#set_interaction(
5698        &self,
5699        mut active: &Usage,
5700        mut affected: &Usage,
5701        mut behavior: Behavior,
5702    ) -> Result<(), fidl::Error> {
5703        self.client.send::<AudioCoreSetInteractionRequest>(
5704            (active, affected, behavior),
5705            0x7bfed14345ece7b7,
5706            fidl::encoding::DynamicFlags::empty(),
5707        )
5708    }
5709
5710    fn r#set_interaction2(
5711        &self,
5712        mut active: &Usage2,
5713        mut affected: &Usage2,
5714        mut behavior: Behavior,
5715    ) -> Result<(), fidl::Error> {
5716        self.client.send::<AudioCoreSetInteraction2Request>(
5717            (active, affected, behavior),
5718            0x7226c7c6e6edc62f,
5719            fidl::encoding::DynamicFlags::FLEXIBLE,
5720        )
5721    }
5722
5723    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5724        self.client.send::<fidl::encoding::EmptyPayload>(
5725            (),
5726            0x65bd94d9d0a28b5e,
5727            fidl::encoding::DynamicFlags::empty(),
5728        )
5729    }
5730
5731    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5732        self.client.send::<fidl::encoding::EmptyPayload>(
5733            (),
5734            0x54a0bebca85f6b31,
5735            fidl::encoding::DynamicFlags::empty(),
5736        )
5737    }
5738}
5739
5740pub struct AudioCoreEventStream {
5741    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5742}
5743
5744impl std::marker::Unpin for AudioCoreEventStream {}
5745
5746impl futures::stream::FusedStream for AudioCoreEventStream {
5747    fn is_terminated(&self) -> bool {
5748        self.event_receiver.is_terminated()
5749    }
5750}
5751
5752impl futures::Stream for AudioCoreEventStream {
5753    type Item = Result<AudioCoreEvent, fidl::Error>;
5754
5755    fn poll_next(
5756        mut self: std::pin::Pin<&mut Self>,
5757        cx: &mut std::task::Context<'_>,
5758    ) -> std::task::Poll<Option<Self::Item>> {
5759        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5760            &mut self.event_receiver,
5761            cx
5762        )?) {
5763            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
5764            None => std::task::Poll::Ready(None),
5765        }
5766    }
5767}
5768
5769#[derive(Debug)]
5770pub enum AudioCoreEvent {
5771    #[non_exhaustive]
5772    _UnknownEvent {
5773        /// Ordinal of the event that was sent.
5774        ordinal: u64,
5775    },
5776}
5777
5778impl AudioCoreEvent {
5779    /// Decodes a message buffer as a [`AudioCoreEvent`].
5780    fn decode(
5781        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5782    ) -> Result<AudioCoreEvent, fidl::Error> {
5783        let (bytes, _handles) = buf.split_mut();
5784        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5785        debug_assert_eq!(tx_header.tx_id, 0);
5786        match tx_header.ordinal {
5787            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5788                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5789            }
5790            _ => Err(fidl::Error::UnknownOrdinal {
5791                ordinal: tx_header.ordinal,
5792                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5793            }),
5794        }
5795    }
5796}
5797
5798/// A Stream of incoming requests for fuchsia.media/AudioCore.
5799pub struct AudioCoreRequestStream {
5800    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5801    is_terminated: bool,
5802}
5803
5804impl std::marker::Unpin for AudioCoreRequestStream {}
5805
5806impl futures::stream::FusedStream for AudioCoreRequestStream {
5807    fn is_terminated(&self) -> bool {
5808        self.is_terminated
5809    }
5810}
5811
5812impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
5813    type Protocol = AudioCoreMarker;
5814    type ControlHandle = AudioCoreControlHandle;
5815
5816    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5817        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5818    }
5819
5820    fn control_handle(&self) -> Self::ControlHandle {
5821        AudioCoreControlHandle { inner: self.inner.clone() }
5822    }
5823
5824    fn into_inner(
5825        self,
5826    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5827    {
5828        (self.inner, self.is_terminated)
5829    }
5830
5831    fn from_inner(
5832        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5833        is_terminated: bool,
5834    ) -> Self {
5835        Self { inner, is_terminated }
5836    }
5837}
5838
5839impl futures::Stream for AudioCoreRequestStream {
5840    type Item = Result<AudioCoreRequest, fidl::Error>;
5841
5842    fn poll_next(
5843        mut self: std::pin::Pin<&mut Self>,
5844        cx: &mut std::task::Context<'_>,
5845    ) -> std::task::Poll<Option<Self::Item>> {
5846        let this = &mut *self;
5847        if this.inner.check_shutdown(cx) {
5848            this.is_terminated = true;
5849            return std::task::Poll::Ready(None);
5850        }
5851        if this.is_terminated {
5852            panic!("polled AudioCoreRequestStream after completion");
5853        }
5854        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5855            |bytes, handles| {
5856                match this.inner.channel().read_etc(cx, bytes, handles) {
5857                    std::task::Poll::Ready(Ok(())) => {}
5858                    std::task::Poll::Pending => return std::task::Poll::Pending,
5859                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5860                        this.is_terminated = true;
5861                        return std::task::Poll::Ready(None);
5862                    }
5863                    std::task::Poll::Ready(Err(e)) => {
5864                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5865                            e.into(),
5866                        ))));
5867                    }
5868                }
5869
5870                // A message has been received from the channel
5871                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5872
5873                std::task::Poll::Ready(Some(match header.ordinal {
5874                    0x2ac9beba47f83435 => {
5875                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5876                        let mut req = fidl::new_empty!(
5877                            AudioCoreCreateAudioRendererRequest,
5878                            fidl::encoding::DefaultFuchsiaResourceDialect
5879                        );
5880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5881                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5882                        Ok(AudioCoreRequest::CreateAudioRenderer {
5883                            audio_out_request: req.audio_out_request,
5884
5885                            control_handle,
5886                        })
5887                    }
5888                    0x459de383b0d76d97 => {
5889                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5890                        let mut req = fidl::new_empty!(
5891                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5892                            fidl::encoding::DefaultFuchsiaResourceDialect
5893                        );
5894                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5895                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5896                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5897                            stream_type: req.stream_type,
5898                            configuration: req.configuration,
5899                            audio_capturer_request: req.audio_capturer_request,
5900
5901                            control_handle,
5902                        })
5903                    }
5904                    0x787db169df99aed0 => {
5905                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5906                        let mut req = fidl::new_empty!(
5907                            AudioCoreCreateAudioCapturerRequest,
5908                            fidl::encoding::DefaultFuchsiaResourceDialect
5909                        );
5910                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5911                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5912                        Ok(AudioCoreRequest::CreateAudioCapturer {
5913                            loopback: req.loopback,
5914                            audio_in_request: req.audio_in_request,
5915
5916                            control_handle,
5917                        })
5918                    }
5919                    0x48097f45f6e2b8e7 => {
5920                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5921                        let mut req = fidl::new_empty!(
5922                            AudioCoreSetRenderUsageGainRequest,
5923                            fidl::encoding::DefaultFuchsiaResourceDialect
5924                        );
5925                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5926                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5927                        Ok(AudioCoreRequest::SetRenderUsageGain {
5928                            usage: req.usage,
5929                            gain_db: req.gain_db,
5930
5931                            control_handle,
5932                        })
5933                    }
5934                    0x779b1531dc9e64f4 => {
5935                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5936                        let mut req = fidl::new_empty!(
5937                            AudioCoreSetRenderUsageGain2Request,
5938                            fidl::encoding::DefaultFuchsiaResourceDialect
5939                        );
5940                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5941                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5942                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5943                            usage: req.usage,
5944                            gain_db: req.gain_db,
5945
5946                            control_handle,
5947                        })
5948                    }
5949                    0x457d29217d4ea248 => {
5950                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5951                        let mut req = fidl::new_empty!(
5952                            AudioCoreSetCaptureUsageGainRequest,
5953                            fidl::encoding::DefaultFuchsiaResourceDialect
5954                        );
5955                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5956                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5957                        Ok(AudioCoreRequest::SetCaptureUsageGain {
5958                            usage: req.usage,
5959                            gain_db: req.gain_db,
5960
5961                            control_handle,
5962                        })
5963                    }
5964                    0x15065ee308f44af0 => {
5965                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5966                        let mut req = fidl::new_empty!(
5967                            AudioCoreSetCaptureUsageGain2Request,
5968                            fidl::encoding::DefaultFuchsiaResourceDialect
5969                        );
5970                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5971                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5972                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
5973                            usage: req.usage,
5974                            gain_db: req.gain_db,
5975
5976                            control_handle,
5977                        })
5978                    }
5979                    0x7225be116aadc137 => {
5980                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5981                        let mut req = fidl::new_empty!(
5982                            AudioCoreBindUsageVolumeControlRequest,
5983                            fidl::encoding::DefaultFuchsiaResourceDialect
5984                        );
5985                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
5986                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5987                        Ok(AudioCoreRequest::BindUsageVolumeControl {
5988                            usage: req.usage,
5989                            volume_control: req.volume_control,
5990
5991                            control_handle,
5992                        })
5993                    }
5994                    0x729dff93019d055 => {
5995                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5996                        let mut req = fidl::new_empty!(
5997                            AudioCoreBindUsageVolumeControl2Request,
5998                            fidl::encoding::DefaultFuchsiaResourceDialect
5999                        );
6000                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6001                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6002                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6003                            usage: req.usage,
6004                            volume_control: req.volume_control,
6005
6006                            control_handle,
6007                        })
6008                    }
6009                    0x50e3ca45509770bf => {
6010                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6011                        let mut req = fidl::new_empty!(
6012                            AudioCoreGetVolumeFromDbRequest,
6013                            fidl::encoding::DefaultFuchsiaResourceDialect
6014                        );
6015                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6016                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6017                        Ok(AudioCoreRequest::GetVolumeFromDb {
6018                            usage: req.usage,
6019                            gain_db: req.gain_db,
6020
6021                            responder: AudioCoreGetVolumeFromDbResponder {
6022                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6023                                tx_id: header.tx_id,
6024                            },
6025                        })
6026                    }
6027                    0x165c811091ef99da => {
6028                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6029                        let mut req = fidl::new_empty!(
6030                            AudioCoreGetVolumeFromDb2Request,
6031                            fidl::encoding::DefaultFuchsiaResourceDialect
6032                        );
6033                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6034                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6035                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6036                            usage: req.usage,
6037                            gain_db: req.gain_db,
6038
6039                            responder: AudioCoreGetVolumeFromDb2Responder {
6040                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6041                                tx_id: header.tx_id,
6042                            },
6043                        })
6044                    }
6045                    0x3e8eec27dd5a8bda => {
6046                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6047                        let mut req = fidl::new_empty!(
6048                            AudioCoreGetDbFromVolumeRequest,
6049                            fidl::encoding::DefaultFuchsiaResourceDialect
6050                        );
6051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6052                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6053                        Ok(AudioCoreRequest::GetDbFromVolume {
6054                            usage: req.usage,
6055                            volume: req.volume,
6056
6057                            responder: AudioCoreGetDbFromVolumeResponder {
6058                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6059                                tx_id: header.tx_id,
6060                            },
6061                        })
6062                    }
6063                    0x5f421a8ebf265bf3 => {
6064                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6065                        let mut req = fidl::new_empty!(
6066                            AudioCoreGetDbFromVolume2Request,
6067                            fidl::encoding::DefaultFuchsiaResourceDialect
6068                        );
6069                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6070                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6071                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6072                            usage: req.usage,
6073                            volume: req.volume,
6074
6075                            responder: AudioCoreGetDbFromVolume2Responder {
6076                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6077                                tx_id: header.tx_id,
6078                            },
6079                        })
6080                    }
6081                    0x7bfed14345ece7b7 => {
6082                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6083                        let mut req = fidl::new_empty!(
6084                            AudioCoreSetInteractionRequest,
6085                            fidl::encoding::DefaultFuchsiaResourceDialect
6086                        );
6087                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6088                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6089                        Ok(AudioCoreRequest::SetInteraction {
6090                            active: req.active,
6091                            affected: req.affected,
6092                            behavior: req.behavior,
6093
6094                            control_handle,
6095                        })
6096                    }
6097                    0x7226c7c6e6edc62f => {
6098                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6099                        let mut req = fidl::new_empty!(
6100                            AudioCoreSetInteraction2Request,
6101                            fidl::encoding::DefaultFuchsiaResourceDialect
6102                        );
6103                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6104                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6105                        Ok(AudioCoreRequest::SetInteraction2 {
6106                            active: req.active,
6107                            affected: req.affected,
6108                            behavior: req.behavior,
6109
6110                            control_handle,
6111                        })
6112                    }
6113                    0x65bd94d9d0a28b5e => {
6114                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6115                        let mut req = fidl::new_empty!(
6116                            fidl::encoding::EmptyPayload,
6117                            fidl::encoding::DefaultFuchsiaResourceDialect
6118                        );
6119                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6120                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6121                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6122                    }
6123                    0x54a0bebca85f6b31 => {
6124                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6125                        let mut req = fidl::new_empty!(
6126                            fidl::encoding::EmptyPayload,
6127                            fidl::encoding::DefaultFuchsiaResourceDialect
6128                        );
6129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6130                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6131                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6132                    }
6133                    _ if header.tx_id == 0
6134                        && header
6135                            .dynamic_flags()
6136                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6137                    {
6138                        Ok(AudioCoreRequest::_UnknownMethod {
6139                            ordinal: header.ordinal,
6140                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6141                            method_type: fidl::MethodType::OneWay,
6142                        })
6143                    }
6144                    _ if header
6145                        .dynamic_flags()
6146                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6147                    {
6148                        this.inner.send_framework_err(
6149                            fidl::encoding::FrameworkErr::UnknownMethod,
6150                            header.tx_id,
6151                            header.ordinal,
6152                            header.dynamic_flags(),
6153                            (bytes, handles),
6154                        )?;
6155                        Ok(AudioCoreRequest::_UnknownMethod {
6156                            ordinal: header.ordinal,
6157                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6158                            method_type: fidl::MethodType::TwoWay,
6159                        })
6160                    }
6161                    _ => Err(fidl::Error::UnknownOrdinal {
6162                        ordinal: header.ordinal,
6163                        protocol_name:
6164                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6165                    }),
6166                }))
6167            },
6168        )
6169    }
6170}
6171
6172#[derive(Debug)]
6173pub enum AudioCoreRequest {
6174    /// Creates an AudioRenderer which outputs audio to the default device.
6175    CreateAudioRenderer {
6176        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6177        control_handle: AudioCoreControlHandle,
6178    },
6179    /// Creates an AudioCapturer according to the given requirements.
6180    ///
6181    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6182    /// It causes the source material to be reformatted/resampled if needed
6183    /// in order to produce the requested stream type.
6184    ///
6185    /// `usage` is used by Fuchsia to make decisions about user experience.
6186    /// See `AudioCaptureUsage` for more details.
6187    ///
6188    /// `configuration` must be initialized to a variant, or no capturer
6189    /// can be created.
6190    CreateAudioCapturerWithConfiguration {
6191        stream_type: AudioStreamType,
6192        configuration: AudioCapturerConfiguration,
6193        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6194        control_handle: AudioCoreControlHandle,
6195    },
6196    /// Creates an AudioCapturer which either captures from the current default
6197    /// audio input device, or loops-back from the current default audio output
6198    /// device based on value passed for the loopback flag.
6199    CreateAudioCapturer {
6200        loopback: bool,
6201        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6202        control_handle: AudioCoreControlHandle,
6203    },
6204    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6205    SetRenderUsageGain {
6206        usage: AudioRenderUsage,
6207        gain_db: f32,
6208        control_handle: AudioCoreControlHandle,
6209    },
6210    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6211    SetRenderUsageGain2 {
6212        usage: AudioRenderUsage2,
6213        gain_db: f32,
6214        control_handle: AudioCoreControlHandle,
6215    },
6216    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6217    SetCaptureUsageGain {
6218        usage: AudioCaptureUsage,
6219        gain_db: f32,
6220        control_handle: AudioCoreControlHandle,
6221    },
6222    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6223    SetCaptureUsageGain2 {
6224        usage: AudioCaptureUsage2,
6225        gain_db: f32,
6226        control_handle: AudioCoreControlHandle,
6227    },
6228    /// Binds to a volume control protocol for the given usage.
6229    BindUsageVolumeControl {
6230        usage: Usage,
6231        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6232        control_handle: AudioCoreControlHandle,
6233    },
6234    /// Binds to a volume control protocol for the given usage.
6235    BindUsageVolumeControl2 {
6236        usage: Usage2,
6237        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6238        control_handle: AudioCoreControlHandle,
6239    },
6240    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6241    /// `usage`. This is the same mapping as used by the VolumeControl from
6242    /// `BindUsageVolumeControl`.
6243    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
6244    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6245    /// `usage`. This is the same mapping as used by the VolumeControl from
6246    /// `BindUsageVolumeControl`.
6247    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
6248    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6249    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6250    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
6251    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6252    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6253    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
6254    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6255    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6256    /// the Behavior specified will be applied to the streams of Usage `affected`.
6257    SetInteraction {
6258        active: Usage,
6259        affected: Usage,
6260        behavior: Behavior,
6261        control_handle: AudioCoreControlHandle,
6262    },
6263    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6264    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6265    /// the Behavior specified will be applied to the streams of Usage `affected`.
6266    SetInteraction2 {
6267        active: Usage2,
6268        affected: Usage2,
6269        behavior: Behavior,
6270        control_handle: AudioCoreControlHandle,
6271    },
6272    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6273    /// audio_core. The default behavior is 'NONE'.
6274    ResetInteractions { control_handle: AudioCoreControlHandle },
6275    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6276    /// does not provide a config.
6277    LoadDefaults { control_handle: AudioCoreControlHandle },
6278    /// An interaction was received which does not match any known method.
6279    #[non_exhaustive]
6280    _UnknownMethod {
6281        /// Ordinal of the method that was called.
6282        ordinal: u64,
6283        control_handle: AudioCoreControlHandle,
6284        method_type: fidl::MethodType,
6285    },
6286}
6287
6288impl AudioCoreRequest {
6289    #[allow(irrefutable_let_patterns)]
6290    pub fn into_create_audio_renderer(
6291        self,
6292    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6293        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6294            Some((audio_out_request, control_handle))
6295        } else {
6296            None
6297        }
6298    }
6299
6300    #[allow(irrefutable_let_patterns)]
6301    pub fn into_create_audio_capturer_with_configuration(
6302        self,
6303    ) -> Option<(
6304        AudioStreamType,
6305        AudioCapturerConfiguration,
6306        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6307        AudioCoreControlHandle,
6308    )> {
6309        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6310            stream_type,
6311            configuration,
6312            audio_capturer_request,
6313            control_handle,
6314        } = self
6315        {
6316            Some((stream_type, configuration, audio_capturer_request, control_handle))
6317        } else {
6318            None
6319        }
6320    }
6321
6322    #[allow(irrefutable_let_patterns)]
6323    pub fn into_create_audio_capturer(
6324        self,
6325    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6326    {
6327        if let AudioCoreRequest::CreateAudioCapturer {
6328            loopback,
6329            audio_in_request,
6330            control_handle,
6331        } = self
6332        {
6333            Some((loopback, audio_in_request, control_handle))
6334        } else {
6335            None
6336        }
6337    }
6338
6339    #[allow(irrefutable_let_patterns)]
6340    pub fn into_set_render_usage_gain(
6341        self,
6342    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6343        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6344            Some((usage, gain_db, control_handle))
6345        } else {
6346            None
6347        }
6348    }
6349
6350    #[allow(irrefutable_let_patterns)]
6351    pub fn into_set_render_usage_gain2(
6352        self,
6353    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6354        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6355            Some((usage, gain_db, control_handle))
6356        } else {
6357            None
6358        }
6359    }
6360
6361    #[allow(irrefutable_let_patterns)]
6362    pub fn into_set_capture_usage_gain(
6363        self,
6364    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6365        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6366            Some((usage, gain_db, control_handle))
6367        } else {
6368            None
6369        }
6370    }
6371
6372    #[allow(irrefutable_let_patterns)]
6373    pub fn into_set_capture_usage_gain2(
6374        self,
6375    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6376        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6377            Some((usage, gain_db, control_handle))
6378        } else {
6379            None
6380        }
6381    }
6382
6383    #[allow(irrefutable_let_patterns)]
6384    pub fn into_bind_usage_volume_control(
6385        self,
6386    ) -> Option<(
6387        Usage,
6388        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6389        AudioCoreControlHandle,
6390    )> {
6391        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6392            self
6393        {
6394            Some((usage, volume_control, control_handle))
6395        } else {
6396            None
6397        }
6398    }
6399
6400    #[allow(irrefutable_let_patterns)]
6401    pub fn into_bind_usage_volume_control2(
6402        self,
6403    ) -> Option<(
6404        Usage2,
6405        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6406        AudioCoreControlHandle,
6407    )> {
6408        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6409            self
6410        {
6411            Some((usage, volume_control, control_handle))
6412        } else {
6413            None
6414        }
6415    }
6416
6417    #[allow(irrefutable_let_patterns)]
6418    pub fn into_get_volume_from_db(
6419        self,
6420    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6421        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6422            Some((usage, gain_db, responder))
6423        } else {
6424            None
6425        }
6426    }
6427
6428    #[allow(irrefutable_let_patterns)]
6429    pub fn into_get_volume_from_db2(
6430        self,
6431    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6432        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6433            Some((usage, gain_db, responder))
6434        } else {
6435            None
6436        }
6437    }
6438
6439    #[allow(irrefutable_let_patterns)]
6440    pub fn into_get_db_from_volume(
6441        self,
6442    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6443        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6444            Some((usage, volume, responder))
6445        } else {
6446            None
6447        }
6448    }
6449
6450    #[allow(irrefutable_let_patterns)]
6451    pub fn into_get_db_from_volume2(
6452        self,
6453    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6454        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6455            Some((usage, volume, responder))
6456        } else {
6457            None
6458        }
6459    }
6460
6461    #[allow(irrefutable_let_patterns)]
6462    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6463        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6464            self
6465        {
6466            Some((active, affected, behavior, control_handle))
6467        } else {
6468            None
6469        }
6470    }
6471
6472    #[allow(irrefutable_let_patterns)]
6473    pub fn into_set_interaction2(
6474        self,
6475    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6476        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6477            self
6478        {
6479            Some((active, affected, behavior, control_handle))
6480        } else {
6481            None
6482        }
6483    }
6484
6485    #[allow(irrefutable_let_patterns)]
6486    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6487        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6488            Some((control_handle))
6489        } else {
6490            None
6491        }
6492    }
6493
6494    #[allow(irrefutable_let_patterns)]
6495    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6496        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6497            Some((control_handle))
6498        } else {
6499            None
6500        }
6501    }
6502
6503    /// Name of the method defined in FIDL
6504    pub fn method_name(&self) -> &'static str {
6505        match *self {
6506            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6507            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6508                "create_audio_capturer_with_configuration"
6509            }
6510            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6511            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6512            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6513            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6514            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6515            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6516            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6517            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6518            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6519            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6520            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6521            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6522            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6523            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6524            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6525            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6526                "unknown one-way method"
6527            }
6528            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6529                "unknown two-way method"
6530            }
6531        }
6532    }
6533}
6534
6535#[derive(Debug, Clone)]
6536pub struct AudioCoreControlHandle {
6537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6538}
6539
6540impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6541    fn shutdown(&self) {
6542        self.inner.shutdown()
6543    }
6544    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6545        self.inner.shutdown_with_epitaph(status)
6546    }
6547
6548    fn is_closed(&self) -> bool {
6549        self.inner.channel().is_closed()
6550    }
6551    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6552        self.inner.channel().on_closed()
6553    }
6554
6555    #[cfg(target_os = "fuchsia")]
6556    fn signal_peer(
6557        &self,
6558        clear_mask: zx::Signals,
6559        set_mask: zx::Signals,
6560    ) -> Result<(), zx_status::Status> {
6561        use fidl::Peered;
6562        self.inner.channel().signal_peer(clear_mask, set_mask)
6563    }
6564}
6565
6566impl AudioCoreControlHandle {}
6567
6568#[must_use = "FIDL methods require a response to be sent"]
6569#[derive(Debug)]
6570pub struct AudioCoreGetVolumeFromDbResponder {
6571    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6572    tx_id: u32,
6573}
6574
6575/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6576/// if the responder is dropped without sending a response, so that the client
6577/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6578impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6579    fn drop(&mut self) {
6580        self.control_handle.shutdown();
6581        // Safety: drops once, never accessed again
6582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6583    }
6584}
6585
6586impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6587    type ControlHandle = AudioCoreControlHandle;
6588
6589    fn control_handle(&self) -> &AudioCoreControlHandle {
6590        &self.control_handle
6591    }
6592
6593    fn drop_without_shutdown(mut self) {
6594        // Safety: drops once, never accessed again due to mem::forget
6595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6596        // Prevent Drop from running (which would shut down the channel)
6597        std::mem::forget(self);
6598    }
6599}
6600
6601impl AudioCoreGetVolumeFromDbResponder {
6602    /// Sends a response to the FIDL transaction.
6603    ///
6604    /// Sets the channel to shutdown if an error occurs.
6605    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6606        let _result = self.send_raw(volume);
6607        if _result.is_err() {
6608            self.control_handle.shutdown();
6609        }
6610        self.drop_without_shutdown();
6611        _result
6612    }
6613
6614    /// Similar to "send" but does not shutdown the channel if an error occurs.
6615    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6616        let _result = self.send_raw(volume);
6617        self.drop_without_shutdown();
6618        _result
6619    }
6620
6621    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6622        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6623            (volume,),
6624            self.tx_id,
6625            0x50e3ca45509770bf,
6626            fidl::encoding::DynamicFlags::empty(),
6627        )
6628    }
6629}
6630
6631#[must_use = "FIDL methods require a response to be sent"]
6632#[derive(Debug)]
6633pub struct AudioCoreGetVolumeFromDb2Responder {
6634    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6635    tx_id: u32,
6636}
6637
6638/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6639/// if the responder is dropped without sending a response, so that the client
6640/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6641impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6642    fn drop(&mut self) {
6643        self.control_handle.shutdown();
6644        // Safety: drops once, never accessed again
6645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6646    }
6647}
6648
6649impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6650    type ControlHandle = AudioCoreControlHandle;
6651
6652    fn control_handle(&self) -> &AudioCoreControlHandle {
6653        &self.control_handle
6654    }
6655
6656    fn drop_without_shutdown(mut self) {
6657        // Safety: drops once, never accessed again due to mem::forget
6658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6659        // Prevent Drop from running (which would shut down the channel)
6660        std::mem::forget(self);
6661    }
6662}
6663
6664impl AudioCoreGetVolumeFromDb2Responder {
6665    /// Sends a response to the FIDL transaction.
6666    ///
6667    /// Sets the channel to shutdown if an error occurs.
6668    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6669        let _result = self.send_raw(volume);
6670        if _result.is_err() {
6671            self.control_handle.shutdown();
6672        }
6673        self.drop_without_shutdown();
6674        _result
6675    }
6676
6677    /// Similar to "send" but does not shutdown the channel if an error occurs.
6678    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6679        let _result = self.send_raw(volume);
6680        self.drop_without_shutdown();
6681        _result
6682    }
6683
6684    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6685        self.control_handle
6686            .inner
6687            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
6688                fidl::encoding::Flexible::new((volume,)),
6689                self.tx_id,
6690                0x165c811091ef99da,
6691                fidl::encoding::DynamicFlags::FLEXIBLE,
6692            )
6693    }
6694}
6695
6696#[must_use = "FIDL methods require a response to be sent"]
6697#[derive(Debug)]
6698pub struct AudioCoreGetDbFromVolumeResponder {
6699    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6700    tx_id: u32,
6701}
6702
6703/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6704/// if the responder is dropped without sending a response, so that the client
6705/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6706impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
6707    fn drop(&mut self) {
6708        self.control_handle.shutdown();
6709        // Safety: drops once, never accessed again
6710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6711    }
6712}
6713
6714impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
6715    type ControlHandle = AudioCoreControlHandle;
6716
6717    fn control_handle(&self) -> &AudioCoreControlHandle {
6718        &self.control_handle
6719    }
6720
6721    fn drop_without_shutdown(mut self) {
6722        // Safety: drops once, never accessed again due to mem::forget
6723        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6724        // Prevent Drop from running (which would shut down the channel)
6725        std::mem::forget(self);
6726    }
6727}
6728
6729impl AudioCoreGetDbFromVolumeResponder {
6730    /// Sends a response to the FIDL transaction.
6731    ///
6732    /// Sets the channel to shutdown if an error occurs.
6733    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6734        let _result = self.send_raw(gain_db);
6735        if _result.is_err() {
6736            self.control_handle.shutdown();
6737        }
6738        self.drop_without_shutdown();
6739        _result
6740    }
6741
6742    /// Similar to "send" but does not shutdown the channel if an error occurs.
6743    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6744        let _result = self.send_raw(gain_db);
6745        self.drop_without_shutdown();
6746        _result
6747    }
6748
6749    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6750        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
6751            (gain_db,),
6752            self.tx_id,
6753            0x3e8eec27dd5a8bda,
6754            fidl::encoding::DynamicFlags::empty(),
6755        )
6756    }
6757}
6758
6759#[must_use = "FIDL methods require a response to be sent"]
6760#[derive(Debug)]
6761pub struct AudioCoreGetDbFromVolume2Responder {
6762    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6763    tx_id: u32,
6764}
6765
6766/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6767/// if the responder is dropped without sending a response, so that the client
6768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6769impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
6770    fn drop(&mut self) {
6771        self.control_handle.shutdown();
6772        // Safety: drops once, never accessed again
6773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6774    }
6775}
6776
6777impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
6778    type ControlHandle = AudioCoreControlHandle;
6779
6780    fn control_handle(&self) -> &AudioCoreControlHandle {
6781        &self.control_handle
6782    }
6783
6784    fn drop_without_shutdown(mut self) {
6785        // Safety: drops once, never accessed again due to mem::forget
6786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6787        // Prevent Drop from running (which would shut down the channel)
6788        std::mem::forget(self);
6789    }
6790}
6791
6792impl AudioCoreGetDbFromVolume2Responder {
6793    /// Sends a response to the FIDL transaction.
6794    ///
6795    /// Sets the channel to shutdown if an error occurs.
6796    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6797        let _result = self.send_raw(gain_db);
6798        if _result.is_err() {
6799            self.control_handle.shutdown();
6800        }
6801        self.drop_without_shutdown();
6802        _result
6803    }
6804
6805    /// Similar to "send" but does not shutdown the channel if an error occurs.
6806    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6807        let _result = self.send_raw(gain_db);
6808        self.drop_without_shutdown();
6809        _result
6810    }
6811
6812    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6813        self.control_handle
6814            .inner
6815            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
6816                fidl::encoding::Flexible::new((gain_db,)),
6817                self.tx_id,
6818                0x5f421a8ebf265bf3,
6819                fidl::encoding::DynamicFlags::FLEXIBLE,
6820            )
6821    }
6822}
6823
6824#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6825pub struct AudioDeviceEnumeratorMarker;
6826
6827impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
6828    type Proxy = AudioDeviceEnumeratorProxy;
6829    type RequestStream = AudioDeviceEnumeratorRequestStream;
6830    #[cfg(target_os = "fuchsia")]
6831    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
6832
6833    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
6834}
6835impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
6836
6837pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
6838    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
6839        + Send;
6840    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
6841    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
6842        + Send;
6843    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
6844    fn r#set_device_gain(
6845        &self,
6846        device_token: u64,
6847        gain_info: &AudioGainInfo,
6848        valid_flags: AudioGainValidFlags,
6849    ) -> Result<(), fidl::Error>;
6850    fn r#add_device_by_channel(
6851        &self,
6852        device_name: &str,
6853        is_input: bool,
6854        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6855    ) -> Result<(), fidl::Error>;
6856}
6857#[derive(Debug)]
6858#[cfg(target_os = "fuchsia")]
6859pub struct AudioDeviceEnumeratorSynchronousProxy {
6860    client: fidl::client::sync::Client,
6861}
6862
6863#[cfg(target_os = "fuchsia")]
6864impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
6865    type Proxy = AudioDeviceEnumeratorProxy;
6866    type Protocol = AudioDeviceEnumeratorMarker;
6867
6868    fn from_channel(inner: fidl::Channel) -> Self {
6869        Self::new(inner)
6870    }
6871
6872    fn into_channel(self) -> fidl::Channel {
6873        self.client.into_channel()
6874    }
6875
6876    fn as_channel(&self) -> &fidl::Channel {
6877        self.client.as_channel()
6878    }
6879}
6880
6881#[cfg(target_os = "fuchsia")]
6882impl AudioDeviceEnumeratorSynchronousProxy {
6883    pub fn new(channel: fidl::Channel) -> Self {
6884        let protocol_name =
6885            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6886        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6887    }
6888
6889    pub fn into_channel(self) -> fidl::Channel {
6890        self.client.into_channel()
6891    }
6892
6893    /// Waits until an event arrives and returns it. It is safe for other
6894    /// threads to make concurrent requests while waiting for an event.
6895    pub fn wait_for_event(
6896        &self,
6897        deadline: zx::MonotonicInstant,
6898    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6899        AudioDeviceEnumeratorEvent::decode(self.client.wait_for_event(deadline)?)
6900    }
6901
6902    /// Obtain the list of currently active audio devices.
6903    pub fn r#get_devices(
6904        &self,
6905        ___deadline: zx::MonotonicInstant,
6906    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6907        let _response = self
6908            .client
6909            .send_query::<fidl::encoding::EmptyPayload, AudioDeviceEnumeratorGetDevicesResponse>(
6910                (),
6911                0x4ce1aa218aeb12a6,
6912                fidl::encoding::DynamicFlags::empty(),
6913                ___deadline,
6914            )?;
6915        Ok(_response.devices)
6916    }
6917
6918    /// Gain/Mute/AGC control
6919    ///
6920    /// Note that each of these operations requires a device_token in order to
6921    /// target the proper input/output.
6922    ///
6923    /// The Get command returns the device_token of the device whose gain is
6924    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6925    /// device_token was invalid or the device had been removed from the system
6926    /// before the Get command could be processed.
6927    ///
6928    /// Set commands which are given an invalid device token are ignored and
6929    /// have no effect on the system. In addition, users do not need to control
6930    /// all of the gain settings for an audio device with each call. Only the
6931    /// settings with a corresponding flag set in the set_flags parameter will
6932    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6933    /// a SetDeviceGain call to care only about the mute setting in the
6934    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6935    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6936    /// status to be changed simultaneously.
6937    pub fn r#get_device_gain(
6938        &self,
6939        mut device_token: u64,
6940        ___deadline: zx::MonotonicInstant,
6941    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
6942        let _response = self.client.send_query::<
6943            AudioDeviceEnumeratorGetDeviceGainRequest,
6944            AudioDeviceEnumeratorGetDeviceGainResponse,
6945        >(
6946            (device_token,),
6947            0x25dd4723403c414b,
6948            fidl::encoding::DynamicFlags::empty(),
6949            ___deadline,
6950        )?;
6951        Ok((_response.device_token, _response.gain_info))
6952    }
6953
6954    pub fn r#set_device_gain(
6955        &self,
6956        mut device_token: u64,
6957        mut gain_info: &AudioGainInfo,
6958        mut valid_flags: AudioGainValidFlags,
6959    ) -> Result<(), fidl::Error> {
6960        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
6961            (device_token, gain_info, valid_flags),
6962            0x5bdabc8ebe83591,
6963            fidl::encoding::DynamicFlags::empty(),
6964        )
6965    }
6966
6967    /// # Deprecation
6968    ///
6969    /// StreamConfig is not supported anymore, instead use an
6970    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6971    /// , see
6972    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6973    pub fn r#add_device_by_channel(
6974        &self,
6975        mut device_name: &str,
6976        mut is_input: bool,
6977        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6978    ) -> Result<(), fidl::Error> {
6979        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
6980            (device_name, is_input, channel),
6981            0x72cdbada4d70ed67,
6982            fidl::encoding::DynamicFlags::empty(),
6983        )
6984    }
6985}
6986
6987#[cfg(target_os = "fuchsia")]
6988impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::Handle {
6989    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
6990        value.into_channel().into()
6991    }
6992}
6993
6994#[cfg(target_os = "fuchsia")]
6995impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
6996    fn from(value: fidl::Channel) -> Self {
6997        Self::new(value)
6998    }
6999}
7000
7001#[cfg(target_os = "fuchsia")]
7002impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7003    type Protocol = AudioDeviceEnumeratorMarker;
7004
7005    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7006        Self::new(value.into_channel())
7007    }
7008}
7009
7010#[derive(Debug, Clone)]
7011pub struct AudioDeviceEnumeratorProxy {
7012    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7013}
7014
7015impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7016    type Protocol = AudioDeviceEnumeratorMarker;
7017
7018    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7019        Self::new(inner)
7020    }
7021
7022    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7023        self.client.into_channel().map_err(|client| Self { client })
7024    }
7025
7026    fn as_channel(&self) -> &::fidl::AsyncChannel {
7027        self.client.as_channel()
7028    }
7029}
7030
7031impl AudioDeviceEnumeratorProxy {
7032    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7033    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7034        let protocol_name =
7035            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7036        Self { client: fidl::client::Client::new(channel, protocol_name) }
7037    }
7038
7039    /// Get a Stream of events from the remote end of the protocol.
7040    ///
7041    /// # Panics
7042    ///
7043    /// Panics if the event stream was already taken.
7044    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7045        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7046    }
7047
7048    /// Obtain the list of currently active audio devices.
7049    pub fn r#get_devices(
7050        &self,
7051    ) -> fidl::client::QueryResponseFut<
7052        Vec<AudioDeviceInfo>,
7053        fidl::encoding::DefaultFuchsiaResourceDialect,
7054    > {
7055        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7056    }
7057
7058    /// Gain/Mute/AGC control
7059    ///
7060    /// Note that each of these operations requires a device_token in order to
7061    /// target the proper input/output.
7062    ///
7063    /// The Get command returns the device_token of the device whose gain is
7064    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7065    /// device_token was invalid or the device had been removed from the system
7066    /// before the Get command could be processed.
7067    ///
7068    /// Set commands which are given an invalid device token are ignored and
7069    /// have no effect on the system. In addition, users do not need to control
7070    /// all of the gain settings for an audio device with each call. Only the
7071    /// settings with a corresponding flag set in the set_flags parameter will
7072    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7073    /// a SetDeviceGain call to care only about the mute setting in the
7074    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7075    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7076    /// status to be changed simultaneously.
7077    pub fn r#get_device_gain(
7078        &self,
7079        mut device_token: u64,
7080    ) -> fidl::client::QueryResponseFut<
7081        (u64, AudioGainInfo),
7082        fidl::encoding::DefaultFuchsiaResourceDialect,
7083    > {
7084        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7085    }
7086
7087    pub fn r#set_device_gain(
7088        &self,
7089        mut device_token: u64,
7090        mut gain_info: &AudioGainInfo,
7091        mut valid_flags: AudioGainValidFlags,
7092    ) -> Result<(), fidl::Error> {
7093        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7094            self,
7095            device_token,
7096            gain_info,
7097            valid_flags,
7098        )
7099    }
7100
7101    /// # Deprecation
7102    ///
7103    /// StreamConfig is not supported anymore, instead use an
7104    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7105    /// , see
7106    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7107    pub fn r#add_device_by_channel(
7108        &self,
7109        mut device_name: &str,
7110        mut is_input: bool,
7111        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7112    ) -> Result<(), fidl::Error> {
7113        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7114            self,
7115            device_name,
7116            is_input,
7117            channel,
7118        )
7119    }
7120}
7121
7122impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7123    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7124        Vec<AudioDeviceInfo>,
7125        fidl::encoding::DefaultFuchsiaResourceDialect,
7126    >;
7127    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7128        fn _decode(
7129            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7130        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7131            let _response = fidl::client::decode_transaction_body::<
7132                AudioDeviceEnumeratorGetDevicesResponse,
7133                fidl::encoding::DefaultFuchsiaResourceDialect,
7134                0x4ce1aa218aeb12a6,
7135            >(_buf?)?;
7136            Ok(_response.devices)
7137        }
7138        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7139            (),
7140            0x4ce1aa218aeb12a6,
7141            fidl::encoding::DynamicFlags::empty(),
7142            _decode,
7143        )
7144    }
7145
7146    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7147        (u64, AudioGainInfo),
7148        fidl::encoding::DefaultFuchsiaResourceDialect,
7149    >;
7150    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7151        fn _decode(
7152            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7153        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7154            let _response = fidl::client::decode_transaction_body::<
7155                AudioDeviceEnumeratorGetDeviceGainResponse,
7156                fidl::encoding::DefaultFuchsiaResourceDialect,
7157                0x25dd4723403c414b,
7158            >(_buf?)?;
7159            Ok((_response.device_token, _response.gain_info))
7160        }
7161        self.client.send_query_and_decode::<
7162            AudioDeviceEnumeratorGetDeviceGainRequest,
7163            (u64, AudioGainInfo),
7164        >(
7165            (device_token,),
7166            0x25dd4723403c414b,
7167            fidl::encoding::DynamicFlags::empty(),
7168            _decode,
7169        )
7170    }
7171
7172    fn r#set_device_gain(
7173        &self,
7174        mut device_token: u64,
7175        mut gain_info: &AudioGainInfo,
7176        mut valid_flags: AudioGainValidFlags,
7177    ) -> Result<(), fidl::Error> {
7178        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7179            (device_token, gain_info, valid_flags),
7180            0x5bdabc8ebe83591,
7181            fidl::encoding::DynamicFlags::empty(),
7182        )
7183    }
7184
7185    fn r#add_device_by_channel(
7186        &self,
7187        mut device_name: &str,
7188        mut is_input: bool,
7189        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7190    ) -> Result<(), fidl::Error> {
7191        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7192            (device_name, is_input, channel),
7193            0x72cdbada4d70ed67,
7194            fidl::encoding::DynamicFlags::empty(),
7195        )
7196    }
7197}
7198
7199pub struct AudioDeviceEnumeratorEventStream {
7200    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7201}
7202
7203impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7204
7205impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7206    fn is_terminated(&self) -> bool {
7207        self.event_receiver.is_terminated()
7208    }
7209}
7210
7211impl futures::Stream for AudioDeviceEnumeratorEventStream {
7212    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7213
7214    fn poll_next(
7215        mut self: std::pin::Pin<&mut Self>,
7216        cx: &mut std::task::Context<'_>,
7217    ) -> std::task::Poll<Option<Self::Item>> {
7218        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7219            &mut self.event_receiver,
7220            cx
7221        )?) {
7222            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7223            None => std::task::Poll::Ready(None),
7224        }
7225    }
7226}
7227
7228#[derive(Debug)]
7229pub enum AudioDeviceEnumeratorEvent {
7230    OnDeviceAdded { device: AudioDeviceInfo },
7231    OnDeviceRemoved { device_token: u64 },
7232    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7233    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7234}
7235
7236impl AudioDeviceEnumeratorEvent {
7237    #[allow(irrefutable_let_patterns)]
7238    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7239        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7240            Some((device))
7241        } else {
7242            None
7243        }
7244    }
7245    #[allow(irrefutable_let_patterns)]
7246    pub fn into_on_device_removed(self) -> Option<u64> {
7247        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7248            Some((device_token))
7249        } else {
7250            None
7251        }
7252    }
7253    #[allow(irrefutable_let_patterns)]
7254    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7255        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7256            Some((device_token, gain_info))
7257        } else {
7258            None
7259        }
7260    }
7261    #[allow(irrefutable_let_patterns)]
7262    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7263        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7264            old_default_token,
7265            new_default_token,
7266        } = self
7267        {
7268            Some((old_default_token, new_default_token))
7269        } else {
7270            None
7271        }
7272    }
7273
7274    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7275    fn decode(
7276        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7277    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7278        let (bytes, _handles) = buf.split_mut();
7279        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7280        debug_assert_eq!(tx_header.tx_id, 0);
7281        match tx_header.ordinal {
7282            0xe0fbe40057c4b44 => {
7283                let mut out = fidl::new_empty!(
7284                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7285                    fidl::encoding::DefaultFuchsiaResourceDialect
7286                );
7287                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7288                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7289            }
7290            0x6f3b7574463d9ff8 => {
7291                let mut out = fidl::new_empty!(
7292                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7293                    fidl::encoding::DefaultFuchsiaResourceDialect
7294                );
7295                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7296                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7297            }
7298            0x14aefcbbb076b0e9 => {
7299                let mut out = fidl::new_empty!(
7300                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7301                    fidl::encoding::DefaultFuchsiaResourceDialect
7302                );
7303                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7304                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7305                    device_token: out.device_token,
7306                    gain_info: out.gain_info,
7307                }))
7308            }
7309            0x16357b42d4c16e11 => {
7310                let mut out = fidl::new_empty!(
7311                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7312                    fidl::encoding::DefaultFuchsiaResourceDialect
7313                );
7314                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7315                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7316                    old_default_token: out.old_default_token,
7317                    new_default_token: out.new_default_token,
7318                }))
7319            }
7320            _ => Err(fidl::Error::UnknownOrdinal {
7321                ordinal: tx_header.ordinal,
7322                protocol_name:
7323                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7324            }),
7325        }
7326    }
7327}
7328
7329/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7330pub struct AudioDeviceEnumeratorRequestStream {
7331    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7332    is_terminated: bool,
7333}
7334
7335impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7336
7337impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7338    fn is_terminated(&self) -> bool {
7339        self.is_terminated
7340    }
7341}
7342
7343impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7344    type Protocol = AudioDeviceEnumeratorMarker;
7345    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7346
7347    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7348        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7349    }
7350
7351    fn control_handle(&self) -> Self::ControlHandle {
7352        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7353    }
7354
7355    fn into_inner(
7356        self,
7357    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7358    {
7359        (self.inner, self.is_terminated)
7360    }
7361
7362    fn from_inner(
7363        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7364        is_terminated: bool,
7365    ) -> Self {
7366        Self { inner, is_terminated }
7367    }
7368}
7369
7370impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7371    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7372
7373    fn poll_next(
7374        mut self: std::pin::Pin<&mut Self>,
7375        cx: &mut std::task::Context<'_>,
7376    ) -> std::task::Poll<Option<Self::Item>> {
7377        let this = &mut *self;
7378        if this.inner.check_shutdown(cx) {
7379            this.is_terminated = true;
7380            return std::task::Poll::Ready(None);
7381        }
7382        if this.is_terminated {
7383            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7384        }
7385        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7386            |bytes, handles| {
7387                match this.inner.channel().read_etc(cx, bytes, handles) {
7388                    std::task::Poll::Ready(Ok(())) => {}
7389                    std::task::Poll::Pending => return std::task::Poll::Pending,
7390                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7391                        this.is_terminated = true;
7392                        return std::task::Poll::Ready(None);
7393                    }
7394                    std::task::Poll::Ready(Err(e)) => {
7395                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7396                            e.into(),
7397                        ))));
7398                    }
7399                }
7400
7401                // A message has been received from the channel
7402                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7403
7404                std::task::Poll::Ready(Some(match header.ordinal {
7405                0x4ce1aa218aeb12a6 => {
7406                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7407                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7408                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7409                    let control_handle = AudioDeviceEnumeratorControlHandle {
7410                        inner: this.inner.clone(),
7411                    };
7412                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7413                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7414                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7415                            tx_id: header.tx_id,
7416                        },
7417                    })
7418                }
7419                0x25dd4723403c414b => {
7420                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7421                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7422                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7423                    let control_handle = AudioDeviceEnumeratorControlHandle {
7424                        inner: this.inner.clone(),
7425                    };
7426                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7427
7428                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7429                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7430                            tx_id: header.tx_id,
7431                        },
7432                    })
7433                }
7434                0x5bdabc8ebe83591 => {
7435                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7436                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7437                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7438                    let control_handle = AudioDeviceEnumeratorControlHandle {
7439                        inner: this.inner.clone(),
7440                    };
7441                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7442gain_info: req.gain_info,
7443valid_flags: req.valid_flags,
7444
7445                        control_handle,
7446                    })
7447                }
7448                0x72cdbada4d70ed67 => {
7449                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7450                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7451                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7452                    let control_handle = AudioDeviceEnumeratorControlHandle {
7453                        inner: this.inner.clone(),
7454                    };
7455                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7456is_input: req.is_input,
7457channel: req.channel,
7458
7459                        control_handle,
7460                    })
7461                }
7462                _ => Err(fidl::Error::UnknownOrdinal {
7463                    ordinal: header.ordinal,
7464                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7465                }),
7466            }))
7467            },
7468        )
7469    }
7470}
7471
7472#[derive(Debug)]
7473pub enum AudioDeviceEnumeratorRequest {
7474    /// Obtain the list of currently active audio devices.
7475    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7476    /// Gain/Mute/AGC control
7477    ///
7478    /// Note that each of these operations requires a device_token in order to
7479    /// target the proper input/output.
7480    ///
7481    /// The Get command returns the device_token of the device whose gain is
7482    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7483    /// device_token was invalid or the device had been removed from the system
7484    /// before the Get command could be processed.
7485    ///
7486    /// Set commands which are given an invalid device token are ignored and
7487    /// have no effect on the system. In addition, users do not need to control
7488    /// all of the gain settings for an audio device with each call. Only the
7489    /// settings with a corresponding flag set in the set_flags parameter will
7490    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7491    /// a SetDeviceGain call to care only about the mute setting in the
7492    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7493    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7494    /// status to be changed simultaneously.
7495    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7496    SetDeviceGain {
7497        device_token: u64,
7498        gain_info: AudioGainInfo,
7499        valid_flags: AudioGainValidFlags,
7500        control_handle: AudioDeviceEnumeratorControlHandle,
7501    },
7502    /// # Deprecation
7503    ///
7504    /// StreamConfig is not supported anymore, instead use an
7505    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7506    /// , see
7507    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7508    AddDeviceByChannel {
7509        device_name: String,
7510        is_input: bool,
7511        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7512        control_handle: AudioDeviceEnumeratorControlHandle,
7513    },
7514}
7515
7516impl AudioDeviceEnumeratorRequest {
7517    #[allow(irrefutable_let_patterns)]
7518    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7519        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7520            Some((responder))
7521        } else {
7522            None
7523        }
7524    }
7525
7526    #[allow(irrefutable_let_patterns)]
7527    pub fn into_get_device_gain(
7528        self,
7529    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7530        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7531            Some((device_token, responder))
7532        } else {
7533            None
7534        }
7535    }
7536
7537    #[allow(irrefutable_let_patterns)]
7538    pub fn into_set_device_gain(
7539        self,
7540    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7541        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7542            device_token,
7543            gain_info,
7544            valid_flags,
7545            control_handle,
7546        } = self
7547        {
7548            Some((device_token, gain_info, valid_flags, control_handle))
7549        } else {
7550            None
7551        }
7552    }
7553
7554    #[allow(irrefutable_let_patterns)]
7555    pub fn into_add_device_by_channel(
7556        self,
7557    ) -> Option<(
7558        String,
7559        bool,
7560        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7561        AudioDeviceEnumeratorControlHandle,
7562    )> {
7563        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7564            device_name,
7565            is_input,
7566            channel,
7567            control_handle,
7568        } = self
7569        {
7570            Some((device_name, is_input, channel, control_handle))
7571        } else {
7572            None
7573        }
7574    }
7575
7576    /// Name of the method defined in FIDL
7577    pub fn method_name(&self) -> &'static str {
7578        match *self {
7579            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7580            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7581            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7582            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7583        }
7584    }
7585}
7586
7587#[derive(Debug, Clone)]
7588pub struct AudioDeviceEnumeratorControlHandle {
7589    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7590}
7591
7592impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7593    fn shutdown(&self) {
7594        self.inner.shutdown()
7595    }
7596    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7597        self.inner.shutdown_with_epitaph(status)
7598    }
7599
7600    fn is_closed(&self) -> bool {
7601        self.inner.channel().is_closed()
7602    }
7603    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7604        self.inner.channel().on_closed()
7605    }
7606
7607    #[cfg(target_os = "fuchsia")]
7608    fn signal_peer(
7609        &self,
7610        clear_mask: zx::Signals,
7611        set_mask: zx::Signals,
7612    ) -> Result<(), zx_status::Status> {
7613        use fidl::Peered;
7614        self.inner.channel().signal_peer(clear_mask, set_mask)
7615    }
7616}
7617
7618impl AudioDeviceEnumeratorControlHandle {
7619    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7620        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7621            (device,),
7622            0,
7623            0xe0fbe40057c4b44,
7624            fidl::encoding::DynamicFlags::empty(),
7625        )
7626    }
7627
7628    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7629        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7630            (device_token,),
7631            0,
7632            0x6f3b7574463d9ff8,
7633            fidl::encoding::DynamicFlags::empty(),
7634        )
7635    }
7636
7637    pub fn send_on_device_gain_changed(
7638        &self,
7639        mut device_token: u64,
7640        mut gain_info: &AudioGainInfo,
7641    ) -> Result<(), fidl::Error> {
7642        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7643            (device_token, gain_info),
7644            0,
7645            0x14aefcbbb076b0e9,
7646            fidl::encoding::DynamicFlags::empty(),
7647        )
7648    }
7649
7650    pub fn send_on_default_device_changed(
7651        &self,
7652        mut old_default_token: u64,
7653        mut new_default_token: u64,
7654    ) -> Result<(), fidl::Error> {
7655        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
7656            (old_default_token, new_default_token),
7657            0,
7658            0x16357b42d4c16e11,
7659            fidl::encoding::DynamicFlags::empty(),
7660        )
7661    }
7662}
7663
7664#[must_use = "FIDL methods require a response to be sent"]
7665#[derive(Debug)]
7666pub struct AudioDeviceEnumeratorGetDevicesResponder {
7667    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7668    tx_id: u32,
7669}
7670
7671/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7672/// if the responder is dropped without sending a response, so that the client
7673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7674impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
7675    fn drop(&mut self) {
7676        self.control_handle.shutdown();
7677        // Safety: drops once, never accessed again
7678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7679    }
7680}
7681
7682impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
7683    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7684
7685    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7686        &self.control_handle
7687    }
7688
7689    fn drop_without_shutdown(mut self) {
7690        // Safety: drops once, never accessed again due to mem::forget
7691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7692        // Prevent Drop from running (which would shut down the channel)
7693        std::mem::forget(self);
7694    }
7695}
7696
7697impl AudioDeviceEnumeratorGetDevicesResponder {
7698    /// Sends a response to the FIDL transaction.
7699    ///
7700    /// Sets the channel to shutdown if an error occurs.
7701    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7702        let _result = self.send_raw(devices);
7703        if _result.is_err() {
7704            self.control_handle.shutdown();
7705        }
7706        self.drop_without_shutdown();
7707        _result
7708    }
7709
7710    /// Similar to "send" but does not shutdown the channel if an error occurs.
7711    pub fn send_no_shutdown_on_err(
7712        self,
7713        mut devices: &[AudioDeviceInfo],
7714    ) -> Result<(), fidl::Error> {
7715        let _result = self.send_raw(devices);
7716        self.drop_without_shutdown();
7717        _result
7718    }
7719
7720    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7721        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
7722            (devices,),
7723            self.tx_id,
7724            0x4ce1aa218aeb12a6,
7725            fidl::encoding::DynamicFlags::empty(),
7726        )
7727    }
7728}
7729
7730#[must_use = "FIDL methods require a response to be sent"]
7731#[derive(Debug)]
7732pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
7733    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7734    tx_id: u32,
7735}
7736
7737/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7738/// if the responder is dropped without sending a response, so that the client
7739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7740impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
7741    fn drop(&mut self) {
7742        self.control_handle.shutdown();
7743        // Safety: drops once, never accessed again
7744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7745    }
7746}
7747
7748impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
7749    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7750
7751    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7752        &self.control_handle
7753    }
7754
7755    fn drop_without_shutdown(mut self) {
7756        // Safety: drops once, never accessed again due to mem::forget
7757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7758        // Prevent Drop from running (which would shut down the channel)
7759        std::mem::forget(self);
7760    }
7761}
7762
7763impl AudioDeviceEnumeratorGetDeviceGainResponder {
7764    /// Sends a response to the FIDL transaction.
7765    ///
7766    /// Sets the channel to shutdown if an error occurs.
7767    pub fn send(
7768        self,
7769        mut device_token: u64,
7770        mut gain_info: &AudioGainInfo,
7771    ) -> Result<(), fidl::Error> {
7772        let _result = self.send_raw(device_token, gain_info);
7773        if _result.is_err() {
7774            self.control_handle.shutdown();
7775        }
7776        self.drop_without_shutdown();
7777        _result
7778    }
7779
7780    /// Similar to "send" but does not shutdown the channel if an error occurs.
7781    pub fn send_no_shutdown_on_err(
7782        self,
7783        mut device_token: u64,
7784        mut gain_info: &AudioGainInfo,
7785    ) -> Result<(), fidl::Error> {
7786        let _result = self.send_raw(device_token, gain_info);
7787        self.drop_without_shutdown();
7788        _result
7789    }
7790
7791    fn send_raw(
7792        &self,
7793        mut device_token: u64,
7794        mut gain_info: &AudioGainInfo,
7795    ) -> Result<(), fidl::Error> {
7796        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
7797            (device_token, gain_info),
7798            self.tx_id,
7799            0x25dd4723403c414b,
7800            fidl::encoding::DynamicFlags::empty(),
7801        )
7802    }
7803}
7804
7805#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7806pub struct AudioRendererMarker;
7807
7808impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
7809    type Proxy = AudioRendererProxy;
7810    type RequestStream = AudioRendererRequestStream;
7811    #[cfg(target_os = "fuchsia")]
7812    type SynchronousProxy = AudioRendererSynchronousProxy;
7813
7814    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
7815}
7816impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
7817
7818pub trait AudioRendererProxyInterface: Send + Sync {
7819    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
7820    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
7821    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7822    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
7823    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
7824    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
7825    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7826    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
7827    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
7828    fn r#bind_gain_control(
7829        &self,
7830        gain_control_request: fidl::endpoints::ServerEnd<
7831            fidl_fuchsia_media_audio::GainControlMarker,
7832        >,
7833    ) -> Result<(), fidl::Error>;
7834    fn r#set_pts_units(
7835        &self,
7836        tick_per_second_numerator: u32,
7837        tick_per_second_denominator: u32,
7838    ) -> Result<(), fidl::Error>;
7839    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
7840    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
7841        + Send;
7842    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
7843    fn r#set_reference_clock(
7844        &self,
7845        reference_clock: Option<fidl::Clock>,
7846    ) -> Result<(), fidl::Error>;
7847    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
7848    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
7849    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
7850    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
7851    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
7852    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
7853    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7854    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
7855    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
7856    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7857    fn r#pause(&self) -> Self::PauseResponseFut;
7858    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
7859}
7860#[derive(Debug)]
7861#[cfg(target_os = "fuchsia")]
7862pub struct AudioRendererSynchronousProxy {
7863    client: fidl::client::sync::Client,
7864}
7865
7866#[cfg(target_os = "fuchsia")]
7867impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
7868    type Proxy = AudioRendererProxy;
7869    type Protocol = AudioRendererMarker;
7870
7871    fn from_channel(inner: fidl::Channel) -> Self {
7872        Self::new(inner)
7873    }
7874
7875    fn into_channel(self) -> fidl::Channel {
7876        self.client.into_channel()
7877    }
7878
7879    fn as_channel(&self) -> &fidl::Channel {
7880        self.client.as_channel()
7881    }
7882}
7883
7884#[cfg(target_os = "fuchsia")]
7885impl AudioRendererSynchronousProxy {
7886    pub fn new(channel: fidl::Channel) -> Self {
7887        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7888        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7889    }
7890
7891    pub fn into_channel(self) -> fidl::Channel {
7892        self.client.into_channel()
7893    }
7894
7895    /// Waits until an event arrives and returns it. It is safe for other
7896    /// threads to make concurrent requests while waiting for an event.
7897    pub fn wait_for_event(
7898        &self,
7899        deadline: zx::MonotonicInstant,
7900    ) -> Result<AudioRendererEvent, fidl::Error> {
7901        AudioRendererEvent::decode(self.client.wait_for_event(deadline)?)
7902    }
7903
7904    /// Adds a payload buffer to the current buffer set associated with the
7905    /// connection. A `StreamPacket` struct reference a payload buffer in the
7906    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
7907    ///
7908    /// A buffer with ID `id` must not be in the current set when this method is
7909    /// invoked, otherwise the service will close the connection.
7910    pub fn r#add_payload_buffer(
7911        &self,
7912        mut id: u32,
7913        mut payload_buffer: fidl::Vmo,
7914    ) -> Result<(), fidl::Error> {
7915        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7916            (id, payload_buffer),
7917            0x3b3a37fc34fe5b56,
7918            fidl::encoding::DynamicFlags::empty(),
7919        )
7920    }
7921
7922    /// Removes a payload buffer from the current buffer set associated with the
7923    /// connection.
7924    ///
7925    /// A buffer with ID `id` must exist in the current set when this method is
7926    /// invoked, otherwise the service will will close the connection.
7927    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7928        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7929            (id,),
7930            0x5d1e4f74c3658262,
7931            fidl::encoding::DynamicFlags::empty(),
7932        )
7933    }
7934
7935    /// Sends a packet to the service. The response is sent when the service is
7936    /// done with the associated payload memory.
7937    ///
7938    /// `packet` must be valid for the current buffer set, otherwise the service
7939    /// will close the connection.
7940    pub fn r#send_packet(
7941        &self,
7942        mut packet: &StreamPacket,
7943        ___deadline: zx::MonotonicInstant,
7944    ) -> Result<(), fidl::Error> {
7945        let _response =
7946            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
7947                (packet,),
7948                0x67cddd607442775f,
7949                fidl::encoding::DynamicFlags::empty(),
7950                ___deadline,
7951            )?;
7952        Ok(_response)
7953    }
7954
7955    /// Sends a packet to the service. This interface doesn't define how the
7956    /// client knows when the sink is done with the associated payload memory.
7957    /// The inheriting interface must define that.
7958    ///
7959    /// `packet` must be valid for the current buffer set, otherwise the service
7960    /// will close the connection.
7961    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7962        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7963            (packet,),
7964            0x8d9b8b413ceba9d,
7965            fidl::encoding::DynamicFlags::empty(),
7966        )
7967    }
7968
7969    /// Indicates the stream has ended. The precise semantics of this method are
7970    /// determined by the inheriting interface.
7971    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
7972        self.client.send::<fidl::encoding::EmptyPayload>(
7973            (),
7974            0x6180fd6f7e793b71,
7975            fidl::encoding::DynamicFlags::empty(),
7976        )
7977    }
7978
7979    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
7980    /// and not yet released. The response is sent after all packets have been
7981    /// released.
7982    pub fn r#discard_all_packets(
7983        &self,
7984        ___deadline: zx::MonotonicInstant,
7985    ) -> Result<(), fidl::Error> {
7986        let _response =
7987            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7988                (),
7989                0x6f4dad7af2917665,
7990                fidl::encoding::DynamicFlags::empty(),
7991                ___deadline,
7992            )?;
7993        Ok(_response)
7994    }
7995
7996    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
7997    /// and not yet released.
7998    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
7999        self.client.send::<fidl::encoding::EmptyPayload>(
8000            (),
8001            0x50d36d0d23081bc4,
8002            fidl::encoding::DynamicFlags::empty(),
8003        )
8004    }
8005
8006    /// Binds to the gain control for this AudioRenderer.
8007    pub fn r#bind_gain_control(
8008        &self,
8009        mut gain_control_request: fidl::endpoints::ServerEnd<
8010            fidl_fuchsia_media_audio::GainControlMarker,
8011        >,
8012    ) -> Result<(), fidl::Error> {
8013        self.client.send::<AudioRendererBindGainControlRequest>(
8014            (gain_control_request,),
8015            0x293f5c7f8fba2bdc,
8016            fidl::encoding::DynamicFlags::empty(),
8017        )
8018    }
8019
8020    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8021    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8022    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8023    pub fn r#set_pts_units(
8024        &self,
8025        mut tick_per_second_numerator: u32,
8026        mut tick_per_second_denominator: u32,
8027    ) -> Result<(), fidl::Error> {
8028        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8029            (tick_per_second_numerator, tick_per_second_denominator),
8030            0xf68cd108785a27c,
8031            fidl::encoding::DynamicFlags::empty(),
8032        )
8033    }
8034
8035    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8036    /// and expected PTS (determined using interpolation). Beyond this threshold,
8037    /// a stream is no longer considered 'continuous' by the renderer.
8038    ///
8039    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8040    /// Most users should not need to change this value from its default.
8041    ///
8042    /// Example:
8043    /// A user is playing back 48KHz audio from a container, which also contains
8044    /// video and needs to be synchronized with the audio. The timestamps are
8045    /// provided explicitly per packet by the container, and expressed in mSec
8046    /// units. This means that a single tick of the media timeline (1 mSec)
8047    /// represents exactly 48 frames of audio. The application in this scenario
8048    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8049    /// frames of audio, and each with an explicit timestamp set to the best
8050    /// possible representation of the presentation time (given this media
8051    /// clock's resolution). So, starting from zero, the timestamps would be..
8052    ///
8053    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8054    ///
8055    /// In this example, attempting to use the presentation time to compute the
8056    /// starting frame number of the audio in the packet would be wrong the
8057    /// majority of the time. The first timestamp is correct (by definition), but
8058    /// it will be 24 packets before the timestamps and frame numbers come back
8059    /// into alignment (the 24th packet would start with the 11280th audio frame
8060    /// and have a PTS of exactly 235).
8061    ///
8062    /// One way to fix this situation is to set the PTS continuity threshold
8063    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8064    /// the number of frames contained within a single tick of the media clock,
8065    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8066    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8067    /// explicitly provided PTS would be considered to be a continuation of the
8068    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8069    /// would work well.
8070    ///
8071    /// Other possible uses:
8072    /// Users who are scheduling audio explicitly, relative to a clock which has
8073    /// not been configured as the reference clock, can use this value to control
8074    /// the maximum acceptable synchronization error before a discontinuity is
8075    /// introduced. E.g., if a user is scheduling audio based on a recovered
8076    /// common media clock, and has not published that clock as the reference
8077    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8078    /// can accumulate before the AudioRenderer deliberately inserts a
8079    /// presentation discontinuity to account for the error.
8080    ///
8081    /// Users whose need to deal with a container where their timestamps may be
8082    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8083    /// something larger. This should be the maximum level of inaccuracy present
8084    /// in the container timestamps, if known. Failing that, it could be set to
8085    /// the maximum tolerable level of drift error before absolute timestamps are
8086    /// explicitly obeyed. Finally, a user could set this number to a very large
8087    /// value (86400.0 seconds, for example) to effectively cause *all*
8088    /// timestamps to be ignored after the first, thus treating all audio as
8089    /// continuous with previously delivered packets. Conversely, users who wish
8090    /// to *always* explicitly schedule their audio packets exactly may specify
8091    /// a CT of 0.
8092    ///
8093    /// Note: explicitly specifying high-frequency PTS units reduces the default
8094    /// continuity threshold accordingly. Internally, this threshold is stored as an
8095    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8096    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8097    /// For this reason, specifying PTS units with a frequency greater than 8192x
8098    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8099    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8100    pub fn r#set_pts_continuity_threshold(
8101        &self,
8102        mut threshold_seconds: f32,
8103    ) -> Result<(), fidl::Error> {
8104        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8105            (threshold_seconds,),
8106            0x2849ba571d1971ba,
8107            fidl::encoding::DynamicFlags::empty(),
8108        )
8109    }
8110
8111    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8112    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8113    pub fn r#get_reference_clock(
8114        &self,
8115        ___deadline: zx::MonotonicInstant,
8116    ) -> Result<fidl::Clock, fidl::Error> {
8117        let _response = self
8118            .client
8119            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetReferenceClockResponse>(
8120                (),
8121                0x2f7a7f011a172f7e,
8122                fidl::encoding::DynamicFlags::empty(),
8123                ___deadline,
8124            )?;
8125        Ok(_response.reference_clock)
8126    }
8127
8128    /// Sets the reference clock that controls this renderer's playback rate. If the input
8129    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8130    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8131    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8132    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8133    ///
8134    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8135    /// cannot be called a second time (even if the renderer format has not yet been set).
8136    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8137    /// diverge at some later time, they should create a clone of the monotonic clock, set
8138    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8139    pub fn r#set_reference_clock(
8140        &self,
8141        mut reference_clock: Option<fidl::Clock>,
8142    ) -> Result<(), fidl::Error> {
8143        self.client.send::<AudioRendererSetReferenceClockRequest>(
8144            (reference_clock,),
8145            0x39acd05d832b5fed,
8146            fidl::encoding::DynamicFlags::empty(),
8147        )
8148    }
8149
8150    /// Sets the usage of the render stream. This method may not be called after
8151    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8152    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8153        self.client.send::<AudioRendererSetUsageRequest>(
8154            (usage,),
8155            0x3994bd23b55a733e,
8156            fidl::encoding::DynamicFlags::empty(),
8157        )
8158    }
8159
8160    /// Sets the usage of the render stream. This method may not be called after
8161    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8162    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8163        self.client.send::<AudioRendererSetUsage2Request>(
8164            (usage2,),
8165            0x2904035c7132b103,
8166            fidl::encoding::DynamicFlags::FLEXIBLE,
8167        )
8168    }
8169
8170    /// Sets the type of the stream to be delivered by the client. Using this method implies
8171    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8172    ///
8173    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8174    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8175    /// methods such as `SendPacket`/`SendPacketNoReply`.
8176    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8177        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8178            (type_,),
8179            0x27aa715d8901fa19,
8180            fidl::encoding::DynamicFlags::empty(),
8181        )
8182    }
8183
8184    /// Enables or disables notifications about changes to the minimum clock lead
8185    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8186    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8187    /// event with the current minimum lead time for the AudioRenderer. If the
8188    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8189    /// new value. This behavior will continue until the user calls
8190    /// `EnableMinLeadTimeEvents(false)`.
8191    ///
8192    /// The minimum clock lead time is the amount of time ahead of the reference
8193    /// clock's understanding of "now" that packets needs to arrive (relative to
8194    /// the playback clock transformation) in order for the mixer to be able to
8195    /// mix packet. For example...
8196    ///
8197    /// + Let the PTS of packet X be P(X)
8198    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8199    ///   function is determined by the call to Play(...)
8200    /// + Let the minimum lead time be MLT
8201    ///
8202    /// If R(P(X)) < RefClock.Now() + MLT
8203    /// Then the packet is late, and some (or all) of the packet's payload will
8204    /// need to be skipped in order to present the packet at the scheduled time.
8205    ///
8206    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8207    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8208    /// is called before the AudioRenderer is routed, any played packets will be
8209    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8210    /// calling `Play`.
8211    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8212        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8213            (enabled,),
8214            0x62808dfad72bf890,
8215            fidl::encoding::DynamicFlags::empty(),
8216        )
8217    }
8218
8219    ///
8220    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8221    /// there's little reason to do so. This is because lead time is a function
8222    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8223    /// If min lead time events are enabled before `SetPcmStreamType` (with
8224    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8225    /// response to `SetPcmStreamType`.
8226    pub fn r#get_min_lead_time(
8227        &self,
8228        ___deadline: zx::MonotonicInstant,
8229    ) -> Result<i64, fidl::Error> {
8230        let _response = self
8231            .client
8232            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetMinLeadTimeResponse>(
8233                (),
8234                0x1cf3c3ecd8fec26b,
8235                fidl::encoding::DynamicFlags::empty(),
8236                ___deadline,
8237            )?;
8238        Ok(_response.min_lead_time_nsec)
8239    }
8240
8241    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8242    /// of the media timeline, using specific values provided by the caller (or
8243    /// default values if not specified). In an optional callback, returns the
8244    /// timestamp values ultimately used -- these set the ongoing relationship
8245    /// between the media and reference timelines (i.e., how to translate between
8246    /// the domain of presentation timestamps, and the realm of local system
8247    /// time).
8248    ///
8249    /// Local system time is specified in units of nanoseconds; media_time is
8250    /// specified in the units defined by the user in the `SetPtsUnits` function,
8251    /// or nanoseconds if `SetPtsUnits` is not called.
8252    ///
8253    /// The act of placing an AudioRenderer into the playback state establishes a
8254    /// relationship between 1) the user-defined media (or presentation) timeline
8255    /// for this particular AudioRenderer, and 2) the real-world system reference
8256    /// timeline. To communicate how to translate between timelines, the Play()
8257    /// callback provides an equivalent timestamp in each time domain. The first
8258    /// value ('reference_time') is given in terms of this renderer's reference
8259    /// clock; the second value ('media_time') is what media instant exactly
8260    /// corresponds to that local time. Restated, the frame at 'media_time' in
8261    /// the audio stream should be presented at 'reference_time' according to
8262    /// the reference clock.
8263    ///
8264    /// Note: on calling this API, media_time immediately starts advancing. It is
8265    /// possible (if uncommon) for a caller to specify a system time that is
8266    /// far in the past, or far into the future. This, along with the specified
8267    /// media time, is simply used to determine what media time corresponds to
8268    /// 'now', and THAT media time is then intersected with presentation
8269    /// timestamps of packets already submitted, to determine which media frames
8270    /// should be presented next.
8271    ///
8272    /// With the corresponding reference_time and media_time values, a user can
8273    /// translate arbitrary time values from one timeline into the other. After
8274    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8275    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8276    /// any 'ref_time':
8277    ///
8278    /// media_time = ( (ref_time - ref_start) / 1e9
8279    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8280    ///              + media_start
8281    ///
8282    /// Conversely, for any presentation timestamp 'media_time':
8283    ///
8284    /// ref_time = ( (media_time - media_start)
8285    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8286    ///              * 1e9 )
8287    ///            + ref_start
8288    ///
8289    /// Users, depending on their use case, may optionally choose not to specify
8290    /// one or both of these timestamps. A timestamp may be omitted by supplying
8291    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8292    /// any omitted timestamp value using the following rules:
8293    ///
8294    /// Reference Time
8295    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8296    /// reference time to begin presentation, based on the minimum lead times for
8297    /// the output devices that are currently bound to this AudioRenderer. For
8298    /// example, if an AudioRenderer is bound to an internal audio output
8299    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8300    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8301    /// is omitted) select a reference time 80 mSec from now.
8302    ///
8303    /// Media Time
8304    /// If media_time is omitted, the AudioRenderer will select one of two
8305    /// values.
8306    /// - If the AudioRenderer is resuming from the paused state, and packets
8307    /// have not been discarded since being paused, then the AudioRenderer will
8308    /// use a media_time corresponding to the instant at which the presentation
8309    /// became paused.
8310    /// - If the AudioRenderer is being placed into a playing state for the first
8311    /// time following startup or a 'discard packets' operation, the initial
8312    /// media_time will be set to the PTS of the first payload in the pending
8313    /// packet queue. If the pending queue is empty, initial media_time will be
8314    /// set to zero.
8315    ///
8316    /// Return Value
8317    /// When requested, the AudioRenderer will return the 'reference_time' and
8318    /// 'media_time' which were selected and used (whether they were explicitly
8319    /// specified or not) in the return value of the play call.
8320    ///
8321    /// Examples
8322    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8323    /// to start playing as soon as possible. The user may call Play without
8324    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8325    ///
8326    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8327    /// playback at a specified 'reference_time', in sync with some other media
8328    /// stream, either initially or after discarding packets. The user would call
8329    /// `Play(reference_time, NO_TIMESTAMP)`.
8330    ///
8331    /// 3. A user has queued some audio using `SendPacket`. The first of these
8332    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8333    /// as possible, but wishes to skip all of the audio content between PTS 0
8334    /// and PTS 'media_time'. The user would call
8335    /// `Play(NO_TIMESTAMP, media_time)`.
8336    ///
8337    /// 4. A user has queued some audio using `SendPacket` and want to present
8338    /// this media in synch with another player in a different device. The
8339    /// coordinator of the group of distributed players sends an explicit
8340    /// message to each player telling them to begin presentation of audio at
8341    /// PTS 'media_time', at the time (based on the group's shared reference
8342    /// clock) 'reference_time'. Here the user would call
8343    /// `Play(reference_time, media_time)`.
8344    pub fn r#play(
8345        &self,
8346        mut reference_time: i64,
8347        mut media_time: i64,
8348        ___deadline: zx::MonotonicInstant,
8349    ) -> Result<(i64, i64), fidl::Error> {
8350        let _response =
8351            self.client.send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse>(
8352                (reference_time, media_time),
8353                0x3c0162db084f74a3,
8354                fidl::encoding::DynamicFlags::empty(),
8355                ___deadline,
8356            )?;
8357        Ok((_response.reference_time, _response.media_time))
8358    }
8359
8360    pub fn r#play_no_reply(
8361        &self,
8362        mut reference_time: i64,
8363        mut media_time: i64,
8364    ) -> Result<(), fidl::Error> {
8365        self.client.send::<AudioRendererPlayNoReplyRequest>(
8366            (reference_time, media_time),
8367            0x1b7fe832b68c22ef,
8368            fidl::encoding::DynamicFlags::empty(),
8369        )
8370    }
8371
8372    /// Immediately puts the AudioRenderer into the paused state and then report
8373    /// the relationship between the media and reference timelines which was
8374    /// established (if requested).
8375    ///
8376    /// If the AudioRenderer is already in the paused state when this called,
8377    /// the previously-established timeline values are returned (if requested).
8378    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8379        let _response =
8380            self.client.send_query::<fidl::encoding::EmptyPayload, AudioRendererPauseResponse>(
8381                (),
8382                0x41d557588d93d153,
8383                fidl::encoding::DynamicFlags::empty(),
8384                ___deadline,
8385            )?;
8386        Ok((_response.reference_time, _response.media_time))
8387    }
8388
8389    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8390        self.client.send::<fidl::encoding::EmptyPayload>(
8391            (),
8392            0x24cc45d4f3855ab,
8393            fidl::encoding::DynamicFlags::empty(),
8394        )
8395    }
8396}
8397
8398#[cfg(target_os = "fuchsia")]
8399impl From<AudioRendererSynchronousProxy> for zx::Handle {
8400    fn from(value: AudioRendererSynchronousProxy) -> Self {
8401        value.into_channel().into()
8402    }
8403}
8404
8405#[cfg(target_os = "fuchsia")]
8406impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8407    fn from(value: fidl::Channel) -> Self {
8408        Self::new(value)
8409    }
8410}
8411
8412#[cfg(target_os = "fuchsia")]
8413impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8414    type Protocol = AudioRendererMarker;
8415
8416    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8417        Self::new(value.into_channel())
8418    }
8419}
8420
8421#[derive(Debug, Clone)]
8422pub struct AudioRendererProxy {
8423    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8424}
8425
8426impl fidl::endpoints::Proxy for AudioRendererProxy {
8427    type Protocol = AudioRendererMarker;
8428
8429    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8430        Self::new(inner)
8431    }
8432
8433    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8434        self.client.into_channel().map_err(|client| Self { client })
8435    }
8436
8437    fn as_channel(&self) -> &::fidl::AsyncChannel {
8438        self.client.as_channel()
8439    }
8440}
8441
8442impl AudioRendererProxy {
8443    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8444    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8445        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8446        Self { client: fidl::client::Client::new(channel, protocol_name) }
8447    }
8448
8449    /// Get a Stream of events from the remote end of the protocol.
8450    ///
8451    /// # Panics
8452    ///
8453    /// Panics if the event stream was already taken.
8454    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8455        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8456    }
8457
8458    /// Adds a payload buffer to the current buffer set associated with the
8459    /// connection. A `StreamPacket` struct reference a payload buffer in the
8460    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8461    ///
8462    /// A buffer with ID `id` must not be in the current set when this method is
8463    /// invoked, otherwise the service will close the connection.
8464    pub fn r#add_payload_buffer(
8465        &self,
8466        mut id: u32,
8467        mut payload_buffer: fidl::Vmo,
8468    ) -> Result<(), fidl::Error> {
8469        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8470    }
8471
8472    /// Removes a payload buffer from the current buffer set associated with the
8473    /// connection.
8474    ///
8475    /// A buffer with ID `id` must exist in the current set when this method is
8476    /// invoked, otherwise the service will will close the connection.
8477    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8478        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8479    }
8480
8481    /// Sends a packet to the service. The response is sent when the service is
8482    /// done with the associated payload memory.
8483    ///
8484    /// `packet` must be valid for the current buffer set, otherwise the service
8485    /// will close the connection.
8486    pub fn r#send_packet(
8487        &self,
8488        mut packet: &StreamPacket,
8489    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8490        AudioRendererProxyInterface::r#send_packet(self, packet)
8491    }
8492
8493    /// Sends a packet to the service. This interface doesn't define how the
8494    /// client knows when the sink is done with the associated payload memory.
8495    /// The inheriting interface must define that.
8496    ///
8497    /// `packet` must be valid for the current buffer set, otherwise the service
8498    /// will close the connection.
8499    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8500        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8501    }
8502
8503    /// Indicates the stream has ended. The precise semantics of this method are
8504    /// determined by the inheriting interface.
8505    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8506        AudioRendererProxyInterface::r#end_of_stream(self)
8507    }
8508
8509    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8510    /// and not yet released. The response is sent after all packets have been
8511    /// released.
8512    pub fn r#discard_all_packets(
8513        &self,
8514    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8515        AudioRendererProxyInterface::r#discard_all_packets(self)
8516    }
8517
8518    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8519    /// and not yet released.
8520    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8521        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8522    }
8523
8524    /// Binds to the gain control for this AudioRenderer.
8525    pub fn r#bind_gain_control(
8526        &self,
8527        mut gain_control_request: fidl::endpoints::ServerEnd<
8528            fidl_fuchsia_media_audio::GainControlMarker,
8529        >,
8530    ) -> Result<(), fidl::Error> {
8531        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8532    }
8533
8534    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8535    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8536    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8537    pub fn r#set_pts_units(
8538        &self,
8539        mut tick_per_second_numerator: u32,
8540        mut tick_per_second_denominator: u32,
8541    ) -> Result<(), fidl::Error> {
8542        AudioRendererProxyInterface::r#set_pts_units(
8543            self,
8544            tick_per_second_numerator,
8545            tick_per_second_denominator,
8546        )
8547    }
8548
8549    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8550    /// and expected PTS (determined using interpolation). Beyond this threshold,
8551    /// a stream is no longer considered 'continuous' by the renderer.
8552    ///
8553    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8554    /// Most users should not need to change this value from its default.
8555    ///
8556    /// Example:
8557    /// A user is playing back 48KHz audio from a container, which also contains
8558    /// video and needs to be synchronized with the audio. The timestamps are
8559    /// provided explicitly per packet by the container, and expressed in mSec
8560    /// units. This means that a single tick of the media timeline (1 mSec)
8561    /// represents exactly 48 frames of audio. The application in this scenario
8562    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8563    /// frames of audio, and each with an explicit timestamp set to the best
8564    /// possible representation of the presentation time (given this media
8565    /// clock's resolution). So, starting from zero, the timestamps would be..
8566    ///
8567    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8568    ///
8569    /// In this example, attempting to use the presentation time to compute the
8570    /// starting frame number of the audio in the packet would be wrong the
8571    /// majority of the time. The first timestamp is correct (by definition), but
8572    /// it will be 24 packets before the timestamps and frame numbers come back
8573    /// into alignment (the 24th packet would start with the 11280th audio frame
8574    /// and have a PTS of exactly 235).
8575    ///
8576    /// One way to fix this situation is to set the PTS continuity threshold
8577    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8578    /// the number of frames contained within a single tick of the media clock,
8579    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8580    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8581    /// explicitly provided PTS would be considered to be a continuation of the
8582    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8583    /// would work well.
8584    ///
8585    /// Other possible uses:
8586    /// Users who are scheduling audio explicitly, relative to a clock which has
8587    /// not been configured as the reference clock, can use this value to control
8588    /// the maximum acceptable synchronization error before a discontinuity is
8589    /// introduced. E.g., if a user is scheduling audio based on a recovered
8590    /// common media clock, and has not published that clock as the reference
8591    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8592    /// can accumulate before the AudioRenderer deliberately inserts a
8593    /// presentation discontinuity to account for the error.
8594    ///
8595    /// Users whose need to deal with a container where their timestamps may be
8596    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8597    /// something larger. This should be the maximum level of inaccuracy present
8598    /// in the container timestamps, if known. Failing that, it could be set to
8599    /// the maximum tolerable level of drift error before absolute timestamps are
8600    /// explicitly obeyed. Finally, a user could set this number to a very large
8601    /// value (86400.0 seconds, for example) to effectively cause *all*
8602    /// timestamps to be ignored after the first, thus treating all audio as
8603    /// continuous with previously delivered packets. Conversely, users who wish
8604    /// to *always* explicitly schedule their audio packets exactly may specify
8605    /// a CT of 0.
8606    ///
8607    /// Note: explicitly specifying high-frequency PTS units reduces the default
8608    /// continuity threshold accordingly. Internally, this threshold is stored as an
8609    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8610    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8611    /// For this reason, specifying PTS units with a frequency greater than 8192x
8612    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8613    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8614    pub fn r#set_pts_continuity_threshold(
8615        &self,
8616        mut threshold_seconds: f32,
8617    ) -> Result<(), fidl::Error> {
8618        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8619    }
8620
8621    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8622    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8623    pub fn r#get_reference_clock(
8624        &self,
8625    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8626    {
8627        AudioRendererProxyInterface::r#get_reference_clock(self)
8628    }
8629
8630    /// Sets the reference clock that controls this renderer's playback rate. If the input
8631    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8632    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8633    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8634    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8635    ///
8636    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8637    /// cannot be called a second time (even if the renderer format has not yet been set).
8638    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8639    /// diverge at some later time, they should create a clone of the monotonic clock, set
8640    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8641    pub fn r#set_reference_clock(
8642        &self,
8643        mut reference_clock: Option<fidl::Clock>,
8644    ) -> Result<(), fidl::Error> {
8645        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
8646    }
8647
8648    /// Sets the usage of the render stream. This method may not be called after
8649    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8650    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8651        AudioRendererProxyInterface::r#set_usage(self, usage)
8652    }
8653
8654    /// Sets the usage of the render stream. This method may not be called after
8655    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8656    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8657        AudioRendererProxyInterface::r#set_usage2(self, usage2)
8658    }
8659
8660    /// Sets the type of the stream to be delivered by the client. Using this method implies
8661    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8662    ///
8663    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8664    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8665    /// methods such as `SendPacket`/`SendPacketNoReply`.
8666    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8667        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
8668    }
8669
8670    /// Enables or disables notifications about changes to the minimum clock lead
8671    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8672    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8673    /// event with the current minimum lead time for the AudioRenderer. If the
8674    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8675    /// new value. This behavior will continue until the user calls
8676    /// `EnableMinLeadTimeEvents(false)`.
8677    ///
8678    /// The minimum clock lead time is the amount of time ahead of the reference
8679    /// clock's understanding of "now" that packets needs to arrive (relative to
8680    /// the playback clock transformation) in order for the mixer to be able to
8681    /// mix packet. For example...
8682    ///
8683    /// + Let the PTS of packet X be P(X)
8684    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8685    ///   function is determined by the call to Play(...)
8686    /// + Let the minimum lead time be MLT
8687    ///
8688    /// If R(P(X)) < RefClock.Now() + MLT
8689    /// Then the packet is late, and some (or all) of the packet's payload will
8690    /// need to be skipped in order to present the packet at the scheduled time.
8691    ///
8692    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8693    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8694    /// is called before the AudioRenderer is routed, any played packets will be
8695    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8696    /// calling `Play`.
8697    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8698        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
8699    }
8700
8701    ///
8702    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8703    /// there's little reason to do so. This is because lead time is a function
8704    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8705    /// If min lead time events are enabled before `SetPcmStreamType` (with
8706    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8707    /// response to `SetPcmStreamType`.
8708    pub fn r#get_min_lead_time(
8709        &self,
8710    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
8711        AudioRendererProxyInterface::r#get_min_lead_time(self)
8712    }
8713
8714    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8715    /// of the media timeline, using specific values provided by the caller (or
8716    /// default values if not specified). In an optional callback, returns the
8717    /// timestamp values ultimately used -- these set the ongoing relationship
8718    /// between the media and reference timelines (i.e., how to translate between
8719    /// the domain of presentation timestamps, and the realm of local system
8720    /// time).
8721    ///
8722    /// Local system time is specified in units of nanoseconds; media_time is
8723    /// specified in the units defined by the user in the `SetPtsUnits` function,
8724    /// or nanoseconds if `SetPtsUnits` is not called.
8725    ///
8726    /// The act of placing an AudioRenderer into the playback state establishes a
8727    /// relationship between 1) the user-defined media (or presentation) timeline
8728    /// for this particular AudioRenderer, and 2) the real-world system reference
8729    /// timeline. To communicate how to translate between timelines, the Play()
8730    /// callback provides an equivalent timestamp in each time domain. The first
8731    /// value ('reference_time') is given in terms of this renderer's reference
8732    /// clock; the second value ('media_time') is what media instant exactly
8733    /// corresponds to that local time. Restated, the frame at 'media_time' in
8734    /// the audio stream should be presented at 'reference_time' according to
8735    /// the reference clock.
8736    ///
8737    /// Note: on calling this API, media_time immediately starts advancing. It is
8738    /// possible (if uncommon) for a caller to specify a system time that is
8739    /// far in the past, or far into the future. This, along with the specified
8740    /// media time, is simply used to determine what media time corresponds to
8741    /// 'now', and THAT media time is then intersected with presentation
8742    /// timestamps of packets already submitted, to determine which media frames
8743    /// should be presented next.
8744    ///
8745    /// With the corresponding reference_time and media_time values, a user can
8746    /// translate arbitrary time values from one timeline into the other. After
8747    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8748    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8749    /// any 'ref_time':
8750    ///
8751    /// media_time = ( (ref_time - ref_start) / 1e9
8752    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8753    ///              + media_start
8754    ///
8755    /// Conversely, for any presentation timestamp 'media_time':
8756    ///
8757    /// ref_time = ( (media_time - media_start)
8758    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8759    ///              * 1e9 )
8760    ///            + ref_start
8761    ///
8762    /// Users, depending on their use case, may optionally choose not to specify
8763    /// one or both of these timestamps. A timestamp may be omitted by supplying
8764    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8765    /// any omitted timestamp value using the following rules:
8766    ///
8767    /// Reference Time
8768    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8769    /// reference time to begin presentation, based on the minimum lead times for
8770    /// the output devices that are currently bound to this AudioRenderer. For
8771    /// example, if an AudioRenderer is bound to an internal audio output
8772    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8773    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8774    /// is omitted) select a reference time 80 mSec from now.
8775    ///
8776    /// Media Time
8777    /// If media_time is omitted, the AudioRenderer will select one of two
8778    /// values.
8779    /// - If the AudioRenderer is resuming from the paused state, and packets
8780    /// have not been discarded since being paused, then the AudioRenderer will
8781    /// use a media_time corresponding to the instant at which the presentation
8782    /// became paused.
8783    /// - If the AudioRenderer is being placed into a playing state for the first
8784    /// time following startup or a 'discard packets' operation, the initial
8785    /// media_time will be set to the PTS of the first payload in the pending
8786    /// packet queue. If the pending queue is empty, initial media_time will be
8787    /// set to zero.
8788    ///
8789    /// Return Value
8790    /// When requested, the AudioRenderer will return the 'reference_time' and
8791    /// 'media_time' which were selected and used (whether they were explicitly
8792    /// specified or not) in the return value of the play call.
8793    ///
8794    /// Examples
8795    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8796    /// to start playing as soon as possible. The user may call Play without
8797    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8798    ///
8799    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8800    /// playback at a specified 'reference_time', in sync with some other media
8801    /// stream, either initially or after discarding packets. The user would call
8802    /// `Play(reference_time, NO_TIMESTAMP)`.
8803    ///
8804    /// 3. A user has queued some audio using `SendPacket`. The first of these
8805    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8806    /// as possible, but wishes to skip all of the audio content between PTS 0
8807    /// and PTS 'media_time'. The user would call
8808    /// `Play(NO_TIMESTAMP, media_time)`.
8809    ///
8810    /// 4. A user has queued some audio using `SendPacket` and want to present
8811    /// this media in synch with another player in a different device. The
8812    /// coordinator of the group of distributed players sends an explicit
8813    /// message to each player telling them to begin presentation of audio at
8814    /// PTS 'media_time', at the time (based on the group's shared reference
8815    /// clock) 'reference_time'. Here the user would call
8816    /// `Play(reference_time, media_time)`.
8817    pub fn r#play(
8818        &self,
8819        mut reference_time: i64,
8820        mut media_time: i64,
8821    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8822    {
8823        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
8824    }
8825
8826    pub fn r#play_no_reply(
8827        &self,
8828        mut reference_time: i64,
8829        mut media_time: i64,
8830    ) -> Result<(), fidl::Error> {
8831        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
8832    }
8833
8834    /// Immediately puts the AudioRenderer into the paused state and then report
8835    /// the relationship between the media and reference timelines which was
8836    /// established (if requested).
8837    ///
8838    /// If the AudioRenderer is already in the paused state when this called,
8839    /// the previously-established timeline values are returned (if requested).
8840    pub fn r#pause(
8841        &self,
8842    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8843    {
8844        AudioRendererProxyInterface::r#pause(self)
8845    }
8846
8847    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8848        AudioRendererProxyInterface::r#pause_no_reply(self)
8849    }
8850}
8851
8852impl AudioRendererProxyInterface for AudioRendererProxy {
8853    fn r#add_payload_buffer(
8854        &self,
8855        mut id: u32,
8856        mut payload_buffer: fidl::Vmo,
8857    ) -> Result<(), fidl::Error> {
8858        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8859            (id, payload_buffer),
8860            0x3b3a37fc34fe5b56,
8861            fidl::encoding::DynamicFlags::empty(),
8862        )
8863    }
8864
8865    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8866        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8867            (id,),
8868            0x5d1e4f74c3658262,
8869            fidl::encoding::DynamicFlags::empty(),
8870        )
8871    }
8872
8873    type SendPacketResponseFut =
8874        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8875    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
8876        fn _decode(
8877            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8878        ) -> Result<(), fidl::Error> {
8879            let _response = fidl::client::decode_transaction_body::<
8880                fidl::encoding::EmptyPayload,
8881                fidl::encoding::DefaultFuchsiaResourceDialect,
8882                0x67cddd607442775f,
8883            >(_buf?)?;
8884            Ok(_response)
8885        }
8886        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
8887            (packet,),
8888            0x67cddd607442775f,
8889            fidl::encoding::DynamicFlags::empty(),
8890            _decode,
8891        )
8892    }
8893
8894    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8895        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8896            (packet,),
8897            0x8d9b8b413ceba9d,
8898            fidl::encoding::DynamicFlags::empty(),
8899        )
8900    }
8901
8902    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8903        self.client.send::<fidl::encoding::EmptyPayload>(
8904            (),
8905            0x6180fd6f7e793b71,
8906            fidl::encoding::DynamicFlags::empty(),
8907        )
8908    }
8909
8910    type DiscardAllPacketsResponseFut =
8911        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8912    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
8913        fn _decode(
8914            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8915        ) -> Result<(), fidl::Error> {
8916            let _response = fidl::client::decode_transaction_body::<
8917                fidl::encoding::EmptyPayload,
8918                fidl::encoding::DefaultFuchsiaResourceDialect,
8919                0x6f4dad7af2917665,
8920            >(_buf?)?;
8921            Ok(_response)
8922        }
8923        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8924            (),
8925            0x6f4dad7af2917665,
8926            fidl::encoding::DynamicFlags::empty(),
8927            _decode,
8928        )
8929    }
8930
8931    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8932        self.client.send::<fidl::encoding::EmptyPayload>(
8933            (),
8934            0x50d36d0d23081bc4,
8935            fidl::encoding::DynamicFlags::empty(),
8936        )
8937    }
8938
8939    fn r#bind_gain_control(
8940        &self,
8941        mut gain_control_request: fidl::endpoints::ServerEnd<
8942            fidl_fuchsia_media_audio::GainControlMarker,
8943        >,
8944    ) -> Result<(), fidl::Error> {
8945        self.client.send::<AudioRendererBindGainControlRequest>(
8946            (gain_control_request,),
8947            0x293f5c7f8fba2bdc,
8948            fidl::encoding::DynamicFlags::empty(),
8949        )
8950    }
8951
8952    fn r#set_pts_units(
8953        &self,
8954        mut tick_per_second_numerator: u32,
8955        mut tick_per_second_denominator: u32,
8956    ) -> Result<(), fidl::Error> {
8957        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8958            (tick_per_second_numerator, tick_per_second_denominator),
8959            0xf68cd108785a27c,
8960            fidl::encoding::DynamicFlags::empty(),
8961        )
8962    }
8963
8964    fn r#set_pts_continuity_threshold(
8965        &self,
8966        mut threshold_seconds: f32,
8967    ) -> Result<(), fidl::Error> {
8968        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8969            (threshold_seconds,),
8970            0x2849ba571d1971ba,
8971            fidl::encoding::DynamicFlags::empty(),
8972        )
8973    }
8974
8975    type GetReferenceClockResponseFut =
8976        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
8977    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
8978        fn _decode(
8979            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8980        ) -> Result<fidl::Clock, fidl::Error> {
8981            let _response = fidl::client::decode_transaction_body::<
8982                AudioRendererGetReferenceClockResponse,
8983                fidl::encoding::DefaultFuchsiaResourceDialect,
8984                0x2f7a7f011a172f7e,
8985            >(_buf?)?;
8986            Ok(_response.reference_clock)
8987        }
8988        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
8989            (),
8990            0x2f7a7f011a172f7e,
8991            fidl::encoding::DynamicFlags::empty(),
8992            _decode,
8993        )
8994    }
8995
8996    fn r#set_reference_clock(
8997        &self,
8998        mut reference_clock: Option<fidl::Clock>,
8999    ) -> Result<(), fidl::Error> {
9000        self.client.send::<AudioRendererSetReferenceClockRequest>(
9001            (reference_clock,),
9002            0x39acd05d832b5fed,
9003            fidl::encoding::DynamicFlags::empty(),
9004        )
9005    }
9006
9007    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9008        self.client.send::<AudioRendererSetUsageRequest>(
9009            (usage,),
9010            0x3994bd23b55a733e,
9011            fidl::encoding::DynamicFlags::empty(),
9012        )
9013    }
9014
9015    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9016        self.client.send::<AudioRendererSetUsage2Request>(
9017            (usage2,),
9018            0x2904035c7132b103,
9019            fidl::encoding::DynamicFlags::FLEXIBLE,
9020        )
9021    }
9022
9023    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9024        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9025            (type_,),
9026            0x27aa715d8901fa19,
9027            fidl::encoding::DynamicFlags::empty(),
9028        )
9029    }
9030
9031    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9032        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9033            (enabled,),
9034            0x62808dfad72bf890,
9035            fidl::encoding::DynamicFlags::empty(),
9036        )
9037    }
9038
9039    type GetMinLeadTimeResponseFut =
9040        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9041    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9042        fn _decode(
9043            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9044        ) -> Result<i64, fidl::Error> {
9045            let _response = fidl::client::decode_transaction_body::<
9046                AudioRendererGetMinLeadTimeResponse,
9047                fidl::encoding::DefaultFuchsiaResourceDialect,
9048                0x1cf3c3ecd8fec26b,
9049            >(_buf?)?;
9050            Ok(_response.min_lead_time_nsec)
9051        }
9052        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9053            (),
9054            0x1cf3c3ecd8fec26b,
9055            fidl::encoding::DynamicFlags::empty(),
9056            _decode,
9057        )
9058    }
9059
9060    type PlayResponseFut =
9061        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9062    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9063        fn _decode(
9064            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9065        ) -> Result<(i64, i64), fidl::Error> {
9066            let _response = fidl::client::decode_transaction_body::<
9067                AudioRendererPlayResponse,
9068                fidl::encoding::DefaultFuchsiaResourceDialect,
9069                0x3c0162db084f74a3,
9070            >(_buf?)?;
9071            Ok((_response.reference_time, _response.media_time))
9072        }
9073        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9074            (reference_time, media_time),
9075            0x3c0162db084f74a3,
9076            fidl::encoding::DynamicFlags::empty(),
9077            _decode,
9078        )
9079    }
9080
9081    fn r#play_no_reply(
9082        &self,
9083        mut reference_time: i64,
9084        mut media_time: i64,
9085    ) -> Result<(), fidl::Error> {
9086        self.client.send::<AudioRendererPlayNoReplyRequest>(
9087            (reference_time, media_time),
9088            0x1b7fe832b68c22ef,
9089            fidl::encoding::DynamicFlags::empty(),
9090        )
9091    }
9092
9093    type PauseResponseFut =
9094        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9095    fn r#pause(&self) -> Self::PauseResponseFut {
9096        fn _decode(
9097            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9098        ) -> Result<(i64, i64), fidl::Error> {
9099            let _response = fidl::client::decode_transaction_body::<
9100                AudioRendererPauseResponse,
9101                fidl::encoding::DefaultFuchsiaResourceDialect,
9102                0x41d557588d93d153,
9103            >(_buf?)?;
9104            Ok((_response.reference_time, _response.media_time))
9105        }
9106        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9107            (),
9108            0x41d557588d93d153,
9109            fidl::encoding::DynamicFlags::empty(),
9110            _decode,
9111        )
9112    }
9113
9114    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9115        self.client.send::<fidl::encoding::EmptyPayload>(
9116            (),
9117            0x24cc45d4f3855ab,
9118            fidl::encoding::DynamicFlags::empty(),
9119        )
9120    }
9121}
9122
9123pub struct AudioRendererEventStream {
9124    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9125}
9126
9127impl std::marker::Unpin for AudioRendererEventStream {}
9128
9129impl futures::stream::FusedStream for AudioRendererEventStream {
9130    fn is_terminated(&self) -> bool {
9131        self.event_receiver.is_terminated()
9132    }
9133}
9134
9135impl futures::Stream for AudioRendererEventStream {
9136    type Item = Result<AudioRendererEvent, fidl::Error>;
9137
9138    fn poll_next(
9139        mut self: std::pin::Pin<&mut Self>,
9140        cx: &mut std::task::Context<'_>,
9141    ) -> std::task::Poll<Option<Self::Item>> {
9142        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9143            &mut self.event_receiver,
9144            cx
9145        )?) {
9146            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9147            None => std::task::Poll::Ready(None),
9148        }
9149    }
9150}
9151
9152#[derive(Debug)]
9153pub enum AudioRendererEvent {
9154    OnMinLeadTimeChanged {
9155        min_lead_time_nsec: i64,
9156    },
9157    #[non_exhaustive]
9158    _UnknownEvent {
9159        /// Ordinal of the event that was sent.
9160        ordinal: u64,
9161    },
9162}
9163
9164impl AudioRendererEvent {
9165    #[allow(irrefutable_let_patterns)]
9166    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9167        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9168            Some((min_lead_time_nsec))
9169        } else {
9170            None
9171        }
9172    }
9173
9174    /// Decodes a message buffer as a [`AudioRendererEvent`].
9175    fn decode(
9176        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9177    ) -> Result<AudioRendererEvent, fidl::Error> {
9178        let (bytes, _handles) = buf.split_mut();
9179        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9180        debug_assert_eq!(tx_header.tx_id, 0);
9181        match tx_header.ordinal {
9182            0x4feff7d278978c4e => {
9183                let mut out = fidl::new_empty!(
9184                    AudioRendererOnMinLeadTimeChangedRequest,
9185                    fidl::encoding::DefaultFuchsiaResourceDialect
9186                );
9187                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9188                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9189                    min_lead_time_nsec: out.min_lead_time_nsec,
9190                }))
9191            }
9192            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9193                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9194            }
9195            _ => Err(fidl::Error::UnknownOrdinal {
9196                ordinal: tx_header.ordinal,
9197                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9198            }),
9199        }
9200    }
9201}
9202
9203/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9204pub struct AudioRendererRequestStream {
9205    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9206    is_terminated: bool,
9207}
9208
9209impl std::marker::Unpin for AudioRendererRequestStream {}
9210
9211impl futures::stream::FusedStream for AudioRendererRequestStream {
9212    fn is_terminated(&self) -> bool {
9213        self.is_terminated
9214    }
9215}
9216
9217impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9218    type Protocol = AudioRendererMarker;
9219    type ControlHandle = AudioRendererControlHandle;
9220
9221    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9222        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9223    }
9224
9225    fn control_handle(&self) -> Self::ControlHandle {
9226        AudioRendererControlHandle { inner: self.inner.clone() }
9227    }
9228
9229    fn into_inner(
9230        self,
9231    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9232    {
9233        (self.inner, self.is_terminated)
9234    }
9235
9236    fn from_inner(
9237        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9238        is_terminated: bool,
9239    ) -> Self {
9240        Self { inner, is_terminated }
9241    }
9242}
9243
9244impl futures::Stream for AudioRendererRequestStream {
9245    type Item = Result<AudioRendererRequest, fidl::Error>;
9246
9247    fn poll_next(
9248        mut self: std::pin::Pin<&mut Self>,
9249        cx: &mut std::task::Context<'_>,
9250    ) -> std::task::Poll<Option<Self::Item>> {
9251        let this = &mut *self;
9252        if this.inner.check_shutdown(cx) {
9253            this.is_terminated = true;
9254            return std::task::Poll::Ready(None);
9255        }
9256        if this.is_terminated {
9257            panic!("polled AudioRendererRequestStream after completion");
9258        }
9259        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9260            |bytes, handles| {
9261                match this.inner.channel().read_etc(cx, bytes, handles) {
9262                    std::task::Poll::Ready(Ok(())) => {}
9263                    std::task::Poll::Pending => return std::task::Poll::Pending,
9264                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9265                        this.is_terminated = true;
9266                        return std::task::Poll::Ready(None);
9267                    }
9268                    std::task::Poll::Ready(Err(e)) => {
9269                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9270                            e.into(),
9271                        ))));
9272                    }
9273                }
9274
9275                // A message has been received from the channel
9276                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9277
9278                std::task::Poll::Ready(Some(match header.ordinal {
9279                    0x3b3a37fc34fe5b56 => {
9280                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9281                        let mut req = fidl::new_empty!(
9282                            StreamBufferSetAddPayloadBufferRequest,
9283                            fidl::encoding::DefaultFuchsiaResourceDialect
9284                        );
9285                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9286                        let control_handle =
9287                            AudioRendererControlHandle { inner: this.inner.clone() };
9288                        Ok(AudioRendererRequest::AddPayloadBuffer {
9289                            id: req.id,
9290                            payload_buffer: req.payload_buffer,
9291
9292                            control_handle,
9293                        })
9294                    }
9295                    0x5d1e4f74c3658262 => {
9296                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9297                        let mut req = fidl::new_empty!(
9298                            StreamBufferSetRemovePayloadBufferRequest,
9299                            fidl::encoding::DefaultFuchsiaResourceDialect
9300                        );
9301                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9302                        let control_handle =
9303                            AudioRendererControlHandle { inner: this.inner.clone() };
9304                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9305                    }
9306                    0x67cddd607442775f => {
9307                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9308                        let mut req = fidl::new_empty!(
9309                            StreamSinkSendPacketRequest,
9310                            fidl::encoding::DefaultFuchsiaResourceDialect
9311                        );
9312                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9313                        let control_handle =
9314                            AudioRendererControlHandle { inner: this.inner.clone() };
9315                        Ok(AudioRendererRequest::SendPacket {
9316                            packet: req.packet,
9317
9318                            responder: AudioRendererSendPacketResponder {
9319                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9320                                tx_id: header.tx_id,
9321                            },
9322                        })
9323                    }
9324                    0x8d9b8b413ceba9d => {
9325                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9326                        let mut req = fidl::new_empty!(
9327                            StreamSinkSendPacketNoReplyRequest,
9328                            fidl::encoding::DefaultFuchsiaResourceDialect
9329                        );
9330                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9331                        let control_handle =
9332                            AudioRendererControlHandle { inner: this.inner.clone() };
9333                        Ok(AudioRendererRequest::SendPacketNoReply {
9334                            packet: req.packet,
9335
9336                            control_handle,
9337                        })
9338                    }
9339                    0x6180fd6f7e793b71 => {
9340                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9341                        let mut req = fidl::new_empty!(
9342                            fidl::encoding::EmptyPayload,
9343                            fidl::encoding::DefaultFuchsiaResourceDialect
9344                        );
9345                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9346                        let control_handle =
9347                            AudioRendererControlHandle { inner: this.inner.clone() };
9348                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9349                    }
9350                    0x6f4dad7af2917665 => {
9351                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9352                        let mut req = fidl::new_empty!(
9353                            fidl::encoding::EmptyPayload,
9354                            fidl::encoding::DefaultFuchsiaResourceDialect
9355                        );
9356                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9357                        let control_handle =
9358                            AudioRendererControlHandle { inner: this.inner.clone() };
9359                        Ok(AudioRendererRequest::DiscardAllPackets {
9360                            responder: AudioRendererDiscardAllPacketsResponder {
9361                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9362                                tx_id: header.tx_id,
9363                            },
9364                        })
9365                    }
9366                    0x50d36d0d23081bc4 => {
9367                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9368                        let mut req = fidl::new_empty!(
9369                            fidl::encoding::EmptyPayload,
9370                            fidl::encoding::DefaultFuchsiaResourceDialect
9371                        );
9372                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9373                        let control_handle =
9374                            AudioRendererControlHandle { inner: this.inner.clone() };
9375                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9376                    }
9377                    0x293f5c7f8fba2bdc => {
9378                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9379                        let mut req = fidl::new_empty!(
9380                            AudioRendererBindGainControlRequest,
9381                            fidl::encoding::DefaultFuchsiaResourceDialect
9382                        );
9383                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9384                        let control_handle =
9385                            AudioRendererControlHandle { inner: this.inner.clone() };
9386                        Ok(AudioRendererRequest::BindGainControl {
9387                            gain_control_request: req.gain_control_request,
9388
9389                            control_handle,
9390                        })
9391                    }
9392                    0xf68cd108785a27c => {
9393                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9394                        let mut req = fidl::new_empty!(
9395                            AudioRendererSetPtsUnitsRequest,
9396                            fidl::encoding::DefaultFuchsiaResourceDialect
9397                        );
9398                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9399                        let control_handle =
9400                            AudioRendererControlHandle { inner: this.inner.clone() };
9401                        Ok(AudioRendererRequest::SetPtsUnits {
9402                            tick_per_second_numerator: req.tick_per_second_numerator,
9403                            tick_per_second_denominator: req.tick_per_second_denominator,
9404
9405                            control_handle,
9406                        })
9407                    }
9408                    0x2849ba571d1971ba => {
9409                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9410                        let mut req = fidl::new_empty!(
9411                            AudioRendererSetPtsContinuityThresholdRequest,
9412                            fidl::encoding::DefaultFuchsiaResourceDialect
9413                        );
9414                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9415                        let control_handle =
9416                            AudioRendererControlHandle { inner: this.inner.clone() };
9417                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9418                            threshold_seconds: req.threshold_seconds,
9419
9420                            control_handle,
9421                        })
9422                    }
9423                    0x2f7a7f011a172f7e => {
9424                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9425                        let mut req = fidl::new_empty!(
9426                            fidl::encoding::EmptyPayload,
9427                            fidl::encoding::DefaultFuchsiaResourceDialect
9428                        );
9429                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9430                        let control_handle =
9431                            AudioRendererControlHandle { inner: this.inner.clone() };
9432                        Ok(AudioRendererRequest::GetReferenceClock {
9433                            responder: AudioRendererGetReferenceClockResponder {
9434                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9435                                tx_id: header.tx_id,
9436                            },
9437                        })
9438                    }
9439                    0x39acd05d832b5fed => {
9440                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9441                        let mut req = fidl::new_empty!(
9442                            AudioRendererSetReferenceClockRequest,
9443                            fidl::encoding::DefaultFuchsiaResourceDialect
9444                        );
9445                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9446                        let control_handle =
9447                            AudioRendererControlHandle { inner: this.inner.clone() };
9448                        Ok(AudioRendererRequest::SetReferenceClock {
9449                            reference_clock: req.reference_clock,
9450
9451                            control_handle,
9452                        })
9453                    }
9454                    0x3994bd23b55a733e => {
9455                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9456                        let mut req = fidl::new_empty!(
9457                            AudioRendererSetUsageRequest,
9458                            fidl::encoding::DefaultFuchsiaResourceDialect
9459                        );
9460                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9461                        let control_handle =
9462                            AudioRendererControlHandle { inner: this.inner.clone() };
9463                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9464                    }
9465                    0x2904035c7132b103 => {
9466                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9467                        let mut req = fidl::new_empty!(
9468                            AudioRendererSetUsage2Request,
9469                            fidl::encoding::DefaultFuchsiaResourceDialect
9470                        );
9471                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9472                        let control_handle =
9473                            AudioRendererControlHandle { inner: this.inner.clone() };
9474                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9475                    }
9476                    0x27aa715d8901fa19 => {
9477                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9478                        let mut req = fidl::new_empty!(
9479                            AudioRendererSetPcmStreamTypeRequest,
9480                            fidl::encoding::DefaultFuchsiaResourceDialect
9481                        );
9482                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9483                        let control_handle =
9484                            AudioRendererControlHandle { inner: this.inner.clone() };
9485                        Ok(AudioRendererRequest::SetPcmStreamType {
9486                            type_: req.type_,
9487
9488                            control_handle,
9489                        })
9490                    }
9491                    0x62808dfad72bf890 => {
9492                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9493                        let mut req = fidl::new_empty!(
9494                            AudioRendererEnableMinLeadTimeEventsRequest,
9495                            fidl::encoding::DefaultFuchsiaResourceDialect
9496                        );
9497                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9498                        let control_handle =
9499                            AudioRendererControlHandle { inner: this.inner.clone() };
9500                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9501                            enabled: req.enabled,
9502
9503                            control_handle,
9504                        })
9505                    }
9506                    0x1cf3c3ecd8fec26b => {
9507                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9508                        let mut req = fidl::new_empty!(
9509                            fidl::encoding::EmptyPayload,
9510                            fidl::encoding::DefaultFuchsiaResourceDialect
9511                        );
9512                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9513                        let control_handle =
9514                            AudioRendererControlHandle { inner: this.inner.clone() };
9515                        Ok(AudioRendererRequest::GetMinLeadTime {
9516                            responder: AudioRendererGetMinLeadTimeResponder {
9517                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9518                                tx_id: header.tx_id,
9519                            },
9520                        })
9521                    }
9522                    0x3c0162db084f74a3 => {
9523                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9524                        let mut req = fidl::new_empty!(
9525                            AudioRendererPlayRequest,
9526                            fidl::encoding::DefaultFuchsiaResourceDialect
9527                        );
9528                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9529                        let control_handle =
9530                            AudioRendererControlHandle { inner: this.inner.clone() };
9531                        Ok(AudioRendererRequest::Play {
9532                            reference_time: req.reference_time,
9533                            media_time: req.media_time,
9534
9535                            responder: AudioRendererPlayResponder {
9536                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9537                                tx_id: header.tx_id,
9538                            },
9539                        })
9540                    }
9541                    0x1b7fe832b68c22ef => {
9542                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9543                        let mut req = fidl::new_empty!(
9544                            AudioRendererPlayNoReplyRequest,
9545                            fidl::encoding::DefaultFuchsiaResourceDialect
9546                        );
9547                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9548                        let control_handle =
9549                            AudioRendererControlHandle { inner: this.inner.clone() };
9550                        Ok(AudioRendererRequest::PlayNoReply {
9551                            reference_time: req.reference_time,
9552                            media_time: req.media_time,
9553
9554                            control_handle,
9555                        })
9556                    }
9557                    0x41d557588d93d153 => {
9558                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9559                        let mut req = fidl::new_empty!(
9560                            fidl::encoding::EmptyPayload,
9561                            fidl::encoding::DefaultFuchsiaResourceDialect
9562                        );
9563                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9564                        let control_handle =
9565                            AudioRendererControlHandle { inner: this.inner.clone() };
9566                        Ok(AudioRendererRequest::Pause {
9567                            responder: AudioRendererPauseResponder {
9568                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9569                                tx_id: header.tx_id,
9570                            },
9571                        })
9572                    }
9573                    0x24cc45d4f3855ab => {
9574                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9575                        let mut req = fidl::new_empty!(
9576                            fidl::encoding::EmptyPayload,
9577                            fidl::encoding::DefaultFuchsiaResourceDialect
9578                        );
9579                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9580                        let control_handle =
9581                            AudioRendererControlHandle { inner: this.inner.clone() };
9582                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9583                    }
9584                    _ if header.tx_id == 0
9585                        && header
9586                            .dynamic_flags()
9587                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9588                    {
9589                        Ok(AudioRendererRequest::_UnknownMethod {
9590                            ordinal: header.ordinal,
9591                            control_handle: AudioRendererControlHandle {
9592                                inner: this.inner.clone(),
9593                            },
9594                            method_type: fidl::MethodType::OneWay,
9595                        })
9596                    }
9597                    _ if header
9598                        .dynamic_flags()
9599                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9600                    {
9601                        this.inner.send_framework_err(
9602                            fidl::encoding::FrameworkErr::UnknownMethod,
9603                            header.tx_id,
9604                            header.ordinal,
9605                            header.dynamic_flags(),
9606                            (bytes, handles),
9607                        )?;
9608                        Ok(AudioRendererRequest::_UnknownMethod {
9609                            ordinal: header.ordinal,
9610                            control_handle: AudioRendererControlHandle {
9611                                inner: this.inner.clone(),
9612                            },
9613                            method_type: fidl::MethodType::TwoWay,
9614                        })
9615                    }
9616                    _ => Err(fidl::Error::UnknownOrdinal {
9617                        ordinal: header.ordinal,
9618                        protocol_name:
9619                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9620                    }),
9621                }))
9622            },
9623        )
9624    }
9625}
9626
9627/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9628/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9629/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9630/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9631/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9632/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9633///
9634/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9635/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9636/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9637/// to reconfiguring the renderer.
9638#[derive(Debug)]
9639pub enum AudioRendererRequest {
9640    /// Adds a payload buffer to the current buffer set associated with the
9641    /// connection. A `StreamPacket` struct reference a payload buffer in the
9642    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
9643    ///
9644    /// A buffer with ID `id` must not be in the current set when this method is
9645    /// invoked, otherwise the service will close the connection.
9646    AddPayloadBuffer {
9647        id: u32,
9648        payload_buffer: fidl::Vmo,
9649        control_handle: AudioRendererControlHandle,
9650    },
9651    /// Removes a payload buffer from the current buffer set associated with the
9652    /// connection.
9653    ///
9654    /// A buffer with ID `id` must exist in the current set when this method is
9655    /// invoked, otherwise the service will will close the connection.
9656    RemovePayloadBuffer {
9657        id: u32,
9658        control_handle: AudioRendererControlHandle,
9659    },
9660    /// Sends a packet to the service. The response is sent when the service is
9661    /// done with the associated payload memory.
9662    ///
9663    /// `packet` must be valid for the current buffer set, otherwise the service
9664    /// will close the connection.
9665    SendPacket {
9666        packet: StreamPacket,
9667        responder: AudioRendererSendPacketResponder,
9668    },
9669    /// Sends a packet to the service. This interface doesn't define how the
9670    /// client knows when the sink is done with the associated payload memory.
9671    /// The inheriting interface must define that.
9672    ///
9673    /// `packet` must be valid for the current buffer set, otherwise the service
9674    /// will close the connection.
9675    SendPacketNoReply {
9676        packet: StreamPacket,
9677        control_handle: AudioRendererControlHandle,
9678    },
9679    /// Indicates the stream has ended. The precise semantics of this method are
9680    /// determined by the inheriting interface.
9681    EndOfStream {
9682        control_handle: AudioRendererControlHandle,
9683    },
9684    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9685    /// and not yet released. The response is sent after all packets have been
9686    /// released.
9687    DiscardAllPackets {
9688        responder: AudioRendererDiscardAllPacketsResponder,
9689    },
9690    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9691    /// and not yet released.
9692    DiscardAllPacketsNoReply {
9693        control_handle: AudioRendererControlHandle,
9694    },
9695    /// Binds to the gain control for this AudioRenderer.
9696    BindGainControl {
9697        gain_control_request:
9698            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
9699        control_handle: AudioRendererControlHandle,
9700    },
9701    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
9702    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
9703    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
9704    SetPtsUnits {
9705        tick_per_second_numerator: u32,
9706        tick_per_second_denominator: u32,
9707        control_handle: AudioRendererControlHandle,
9708    },
9709    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
9710    /// and expected PTS (determined using interpolation). Beyond this threshold,
9711    /// a stream is no longer considered 'continuous' by the renderer.
9712    ///
9713    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
9714    /// Most users should not need to change this value from its default.
9715    ///
9716    /// Example:
9717    /// A user is playing back 48KHz audio from a container, which also contains
9718    /// video and needs to be synchronized with the audio. The timestamps are
9719    /// provided explicitly per packet by the container, and expressed in mSec
9720    /// units. This means that a single tick of the media timeline (1 mSec)
9721    /// represents exactly 48 frames of audio. The application in this scenario
9722    /// delivers packets of audio to the AudioRenderer, each with exactly 470
9723    /// frames of audio, and each with an explicit timestamp set to the best
9724    /// possible representation of the presentation time (given this media
9725    /// clock's resolution). So, starting from zero, the timestamps would be..
9726    ///
9727    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
9728    ///
9729    /// In this example, attempting to use the presentation time to compute the
9730    /// starting frame number of the audio in the packet would be wrong the
9731    /// majority of the time. The first timestamp is correct (by definition), but
9732    /// it will be 24 packets before the timestamps and frame numbers come back
9733    /// into alignment (the 24th packet would start with the 11280th audio frame
9734    /// and have a PTS of exactly 235).
9735    ///
9736    /// One way to fix this situation is to set the PTS continuity threshold
9737    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
9738    /// the number of frames contained within a single tick of the media clock,
9739    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
9740    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
9741    /// explicitly provided PTS would be considered to be a continuation of the
9742    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
9743    /// would work well.
9744    ///
9745    /// Other possible uses:
9746    /// Users who are scheduling audio explicitly, relative to a clock which has
9747    /// not been configured as the reference clock, can use this value to control
9748    /// the maximum acceptable synchronization error before a discontinuity is
9749    /// introduced. E.g., if a user is scheduling audio based on a recovered
9750    /// common media clock, and has not published that clock as the reference
9751    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
9752    /// can accumulate before the AudioRenderer deliberately inserts a
9753    /// presentation discontinuity to account for the error.
9754    ///
9755    /// Users whose need to deal with a container where their timestamps may be
9756    /// even less correct than +/- 1/2 of a PTS tick may set this value to
9757    /// something larger. This should be the maximum level of inaccuracy present
9758    /// in the container timestamps, if known. Failing that, it could be set to
9759    /// the maximum tolerable level of drift error before absolute timestamps are
9760    /// explicitly obeyed. Finally, a user could set this number to a very large
9761    /// value (86400.0 seconds, for example) to effectively cause *all*
9762    /// timestamps to be ignored after the first, thus treating all audio as
9763    /// continuous with previously delivered packets. Conversely, users who wish
9764    /// to *always* explicitly schedule their audio packets exactly may specify
9765    /// a CT of 0.
9766    ///
9767    /// Note: explicitly specifying high-frequency PTS units reduces the default
9768    /// continuity threshold accordingly. Internally, this threshold is stored as an
9769    /// integer of 1/8192 subframes. The default threshold is computed as follows:
9770    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
9771    /// For this reason, specifying PTS units with a frequency greater than 8192x
9772    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
9773    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
9774    SetPtsContinuityThreshold {
9775        threshold_seconds: f32,
9776        control_handle: AudioRendererControlHandle,
9777    },
9778    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
9779    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
9780    GetReferenceClock {
9781        responder: AudioRendererGetReferenceClockResponder,
9782    },
9783    /// Sets the reference clock that controls this renderer's playback rate. If the input
9784    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
9785    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
9786    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
9787    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
9788    ///
9789    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
9790    /// cannot be called a second time (even if the renderer format has not yet been set).
9791    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
9792    /// diverge at some later time, they should create a clone of the monotonic clock, set
9793    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
9794    SetReferenceClock {
9795        reference_clock: Option<fidl::Clock>,
9796        control_handle: AudioRendererControlHandle,
9797    },
9798    /// Sets the usage of the render stream. This method may not be called after
9799    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9800    SetUsage {
9801        usage: AudioRenderUsage,
9802        control_handle: AudioRendererControlHandle,
9803    },
9804    /// Sets the usage of the render stream. This method may not be called after
9805    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9806    SetUsage2 {
9807        usage2: AudioRenderUsage2,
9808        control_handle: AudioRendererControlHandle,
9809    },
9810    /// Sets the type of the stream to be delivered by the client. Using this method implies
9811    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
9812    ///
9813    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
9814    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
9815    /// methods such as `SendPacket`/`SendPacketNoReply`.
9816    SetPcmStreamType {
9817        type_: AudioStreamType,
9818        control_handle: AudioRendererControlHandle,
9819    },
9820    /// Enables or disables notifications about changes to the minimum clock lead
9821    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
9822    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
9823    /// event with the current minimum lead time for the AudioRenderer. If the
9824    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
9825    /// new value. This behavior will continue until the user calls
9826    /// `EnableMinLeadTimeEvents(false)`.
9827    ///
9828    /// The minimum clock lead time is the amount of time ahead of the reference
9829    /// clock's understanding of "now" that packets needs to arrive (relative to
9830    /// the playback clock transformation) in order for the mixer to be able to
9831    /// mix packet. For example...
9832    ///
9833    /// + Let the PTS of packet X be P(X)
9834    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9835    ///   function is determined by the call to Play(...)
9836    /// + Let the minimum lead time be MLT
9837    ///
9838    /// If R(P(X)) < RefClock.Now() + MLT
9839    /// Then the packet is late, and some (or all) of the packet's payload will
9840    /// need to be skipped in order to present the packet at the scheduled time.
9841    ///
9842    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9843    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9844    /// is called before the AudioRenderer is routed, any played packets will be
9845    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9846    /// calling `Play`.
9847    EnableMinLeadTimeEvents {
9848        enabled: bool,
9849        control_handle: AudioRendererControlHandle,
9850    },
9851    ///
9852    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9853    /// there's little reason to do so. This is because lead time is a function
9854    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9855    /// If min lead time events are enabled before `SetPcmStreamType` (with
9856    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9857    /// response to `SetPcmStreamType`.
9858    GetMinLeadTime {
9859        responder: AudioRendererGetMinLeadTimeResponder,
9860    },
9861    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9862    /// of the media timeline, using specific values provided by the caller (or
9863    /// default values if not specified). In an optional callback, returns the
9864    /// timestamp values ultimately used -- these set the ongoing relationship
9865    /// between the media and reference timelines (i.e., how to translate between
9866    /// the domain of presentation timestamps, and the realm of local system
9867    /// time).
9868    ///
9869    /// Local system time is specified in units of nanoseconds; media_time is
9870    /// specified in the units defined by the user in the `SetPtsUnits` function,
9871    /// or nanoseconds if `SetPtsUnits` is not called.
9872    ///
9873    /// The act of placing an AudioRenderer into the playback state establishes a
9874    /// relationship between 1) the user-defined media (or presentation) timeline
9875    /// for this particular AudioRenderer, and 2) the real-world system reference
9876    /// timeline. To communicate how to translate between timelines, the Play()
9877    /// callback provides an equivalent timestamp in each time domain. The first
9878    /// value ('reference_time') is given in terms of this renderer's reference
9879    /// clock; the second value ('media_time') is what media instant exactly
9880    /// corresponds to that local time. Restated, the frame at 'media_time' in
9881    /// the audio stream should be presented at 'reference_time' according to
9882    /// the reference clock.
9883    ///
9884    /// Note: on calling this API, media_time immediately starts advancing. It is
9885    /// possible (if uncommon) for a caller to specify a system time that is
9886    /// far in the past, or far into the future. This, along with the specified
9887    /// media time, is simply used to determine what media time corresponds to
9888    /// 'now', and THAT media time is then intersected with presentation
9889    /// timestamps of packets already submitted, to determine which media frames
9890    /// should be presented next.
9891    ///
9892    /// With the corresponding reference_time and media_time values, a user can
9893    /// translate arbitrary time values from one timeline into the other. After
9894    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9895    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9896    /// any 'ref_time':
9897    ///
9898    /// media_time = ( (ref_time - ref_start) / 1e9
9899    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9900    ///              + media_start
9901    ///
9902    /// Conversely, for any presentation timestamp 'media_time':
9903    ///
9904    /// ref_time = ( (media_time - media_start)
9905    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9906    ///              * 1e9 )
9907    ///            + ref_start
9908    ///
9909    /// Users, depending on their use case, may optionally choose not to specify
9910    /// one or both of these timestamps. A timestamp may be omitted by supplying
9911    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9912    /// any omitted timestamp value using the following rules:
9913    ///
9914    /// Reference Time
9915    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9916    /// reference time to begin presentation, based on the minimum lead times for
9917    /// the output devices that are currently bound to this AudioRenderer. For
9918    /// example, if an AudioRenderer is bound to an internal audio output
9919    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9920    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9921    /// is omitted) select a reference time 80 mSec from now.
9922    ///
9923    /// Media Time
9924    /// If media_time is omitted, the AudioRenderer will select one of two
9925    /// values.
9926    /// - If the AudioRenderer is resuming from the paused state, and packets
9927    /// have not been discarded since being paused, then the AudioRenderer will
9928    /// use a media_time corresponding to the instant at which the presentation
9929    /// became paused.
9930    /// - If the AudioRenderer is being placed into a playing state for the first
9931    /// time following startup or a 'discard packets' operation, the initial
9932    /// media_time will be set to the PTS of the first payload in the pending
9933    /// packet queue. If the pending queue is empty, initial media_time will be
9934    /// set to zero.
9935    ///
9936    /// Return Value
9937    /// When requested, the AudioRenderer will return the 'reference_time' and
9938    /// 'media_time' which were selected and used (whether they were explicitly
9939    /// specified or not) in the return value of the play call.
9940    ///
9941    /// Examples
9942    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
9943    /// to start playing as soon as possible. The user may call Play without
9944    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
9945    ///
9946    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
9947    /// playback at a specified 'reference_time', in sync with some other media
9948    /// stream, either initially or after discarding packets. The user would call
9949    /// `Play(reference_time, NO_TIMESTAMP)`.
9950    ///
9951    /// 3. A user has queued some audio using `SendPacket`. The first of these
9952    /// packets has a PTS of zero, and the user wishes playback to begin as soon
9953    /// as possible, but wishes to skip all of the audio content between PTS 0
9954    /// and PTS 'media_time'. The user would call
9955    /// `Play(NO_TIMESTAMP, media_time)`.
9956    ///
9957    /// 4. A user has queued some audio using `SendPacket` and want to present
9958    /// this media in synch with another player in a different device. The
9959    /// coordinator of the group of distributed players sends an explicit
9960    /// message to each player telling them to begin presentation of audio at
9961    /// PTS 'media_time', at the time (based on the group's shared reference
9962    /// clock) 'reference_time'. Here the user would call
9963    /// `Play(reference_time, media_time)`.
9964    Play {
9965        reference_time: i64,
9966        media_time: i64,
9967        responder: AudioRendererPlayResponder,
9968    },
9969    PlayNoReply {
9970        reference_time: i64,
9971        media_time: i64,
9972        control_handle: AudioRendererControlHandle,
9973    },
9974    /// Immediately puts the AudioRenderer into the paused state and then report
9975    /// the relationship between the media and reference timelines which was
9976    /// established (if requested).
9977    ///
9978    /// If the AudioRenderer is already in the paused state when this called,
9979    /// the previously-established timeline values are returned (if requested).
9980    Pause {
9981        responder: AudioRendererPauseResponder,
9982    },
9983    PauseNoReply {
9984        control_handle: AudioRendererControlHandle,
9985    },
9986    /// An interaction was received which does not match any known method.
9987    #[non_exhaustive]
9988    _UnknownMethod {
9989        /// Ordinal of the method that was called.
9990        ordinal: u64,
9991        control_handle: AudioRendererControlHandle,
9992        method_type: fidl::MethodType,
9993    },
9994}
9995
9996impl AudioRendererRequest {
9997    #[allow(irrefutable_let_patterns)]
9998    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
9999        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10000        {
10001            Some((id, payload_buffer, control_handle))
10002        } else {
10003            None
10004        }
10005    }
10006
10007    #[allow(irrefutable_let_patterns)]
10008    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10009        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10010            Some((id, control_handle))
10011        } else {
10012            None
10013        }
10014    }
10015
10016    #[allow(irrefutable_let_patterns)]
10017    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10018        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10019            Some((packet, responder))
10020        } else {
10021            None
10022        }
10023    }
10024
10025    #[allow(irrefutable_let_patterns)]
10026    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10027        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10028            Some((packet, control_handle))
10029        } else {
10030            None
10031        }
10032    }
10033
10034    #[allow(irrefutable_let_patterns)]
10035    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10036        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10037            Some((control_handle))
10038        } else {
10039            None
10040        }
10041    }
10042
10043    #[allow(irrefutable_let_patterns)]
10044    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10045        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10046            Some((responder))
10047        } else {
10048            None
10049        }
10050    }
10051
10052    #[allow(irrefutable_let_patterns)]
10053    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10054        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10055            Some((control_handle))
10056        } else {
10057            None
10058        }
10059    }
10060
10061    #[allow(irrefutable_let_patterns)]
10062    pub fn into_bind_gain_control(
10063        self,
10064    ) -> Option<(
10065        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10066        AudioRendererControlHandle,
10067    )> {
10068        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10069        {
10070            Some((gain_control_request, control_handle))
10071        } else {
10072            None
10073        }
10074    }
10075
10076    #[allow(irrefutable_let_patterns)]
10077    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10078        if let AudioRendererRequest::SetPtsUnits {
10079            tick_per_second_numerator,
10080            tick_per_second_denominator,
10081            control_handle,
10082        } = self
10083        {
10084            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10085        } else {
10086            None
10087        }
10088    }
10089
10090    #[allow(irrefutable_let_patterns)]
10091    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10092        if let AudioRendererRequest::SetPtsContinuityThreshold {
10093            threshold_seconds,
10094            control_handle,
10095        } = self
10096        {
10097            Some((threshold_seconds, control_handle))
10098        } else {
10099            None
10100        }
10101    }
10102
10103    #[allow(irrefutable_let_patterns)]
10104    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10105        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10106            Some((responder))
10107        } else {
10108            None
10109        }
10110    }
10111
10112    #[allow(irrefutable_let_patterns)]
10113    pub fn into_set_reference_clock(
10114        self,
10115    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10116        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10117            Some((reference_clock, control_handle))
10118        } else {
10119            None
10120        }
10121    }
10122
10123    #[allow(irrefutable_let_patterns)]
10124    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10125        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10126            Some((usage, control_handle))
10127        } else {
10128            None
10129        }
10130    }
10131
10132    #[allow(irrefutable_let_patterns)]
10133    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10134        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10135            Some((usage2, control_handle))
10136        } else {
10137            None
10138        }
10139    }
10140
10141    #[allow(irrefutable_let_patterns)]
10142    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10143        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10144            Some((type_, control_handle))
10145        } else {
10146            None
10147        }
10148    }
10149
10150    #[allow(irrefutable_let_patterns)]
10151    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10152        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10153            Some((enabled, control_handle))
10154        } else {
10155            None
10156        }
10157    }
10158
10159    #[allow(irrefutable_let_patterns)]
10160    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10161        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10162            Some((responder))
10163        } else {
10164            None
10165        }
10166    }
10167
10168    #[allow(irrefutable_let_patterns)]
10169    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10170        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10171            Some((reference_time, media_time, responder))
10172        } else {
10173            None
10174        }
10175    }
10176
10177    #[allow(irrefutable_let_patterns)]
10178    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10179        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10180            self
10181        {
10182            Some((reference_time, media_time, control_handle))
10183        } else {
10184            None
10185        }
10186    }
10187
10188    #[allow(irrefutable_let_patterns)]
10189    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10190        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
10191    }
10192
10193    #[allow(irrefutable_let_patterns)]
10194    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10195        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10196            Some((control_handle))
10197        } else {
10198            None
10199        }
10200    }
10201
10202    /// Name of the method defined in FIDL
10203    pub fn method_name(&self) -> &'static str {
10204        match *self {
10205            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10206            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10207            AudioRendererRequest::SendPacket { .. } => "send_packet",
10208            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10209            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10210            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10211            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10212            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10213            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10214            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10215                "set_pts_continuity_threshold"
10216            }
10217            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10218            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10219            AudioRendererRequest::SetUsage { .. } => "set_usage",
10220            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10221            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10222            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10223            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10224            AudioRendererRequest::Play { .. } => "play",
10225            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10226            AudioRendererRequest::Pause { .. } => "pause",
10227            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10228            AudioRendererRequest::_UnknownMethod {
10229                method_type: fidl::MethodType::OneWay, ..
10230            } => "unknown one-way method",
10231            AudioRendererRequest::_UnknownMethod {
10232                method_type: fidl::MethodType::TwoWay, ..
10233            } => "unknown two-way method",
10234        }
10235    }
10236}
10237
10238#[derive(Debug, Clone)]
10239pub struct AudioRendererControlHandle {
10240    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10241}
10242
10243impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10244    fn shutdown(&self) {
10245        self.inner.shutdown()
10246    }
10247    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10248        self.inner.shutdown_with_epitaph(status)
10249    }
10250
10251    fn is_closed(&self) -> bool {
10252        self.inner.channel().is_closed()
10253    }
10254    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10255        self.inner.channel().on_closed()
10256    }
10257
10258    #[cfg(target_os = "fuchsia")]
10259    fn signal_peer(
10260        &self,
10261        clear_mask: zx::Signals,
10262        set_mask: zx::Signals,
10263    ) -> Result<(), zx_status::Status> {
10264        use fidl::Peered;
10265        self.inner.channel().signal_peer(clear_mask, set_mask)
10266    }
10267}
10268
10269impl AudioRendererControlHandle {
10270    pub fn send_on_min_lead_time_changed(
10271        &self,
10272        mut min_lead_time_nsec: i64,
10273    ) -> Result<(), fidl::Error> {
10274        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10275            (min_lead_time_nsec,),
10276            0,
10277            0x4feff7d278978c4e,
10278            fidl::encoding::DynamicFlags::empty(),
10279        )
10280    }
10281}
10282
10283#[must_use = "FIDL methods require a response to be sent"]
10284#[derive(Debug)]
10285pub struct AudioRendererSendPacketResponder {
10286    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10287    tx_id: u32,
10288}
10289
10290/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10291/// if the responder is dropped without sending a response, so that the client
10292/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10293impl std::ops::Drop for AudioRendererSendPacketResponder {
10294    fn drop(&mut self) {
10295        self.control_handle.shutdown();
10296        // Safety: drops once, never accessed again
10297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10298    }
10299}
10300
10301impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10302    type ControlHandle = AudioRendererControlHandle;
10303
10304    fn control_handle(&self) -> &AudioRendererControlHandle {
10305        &self.control_handle
10306    }
10307
10308    fn drop_without_shutdown(mut self) {
10309        // Safety: drops once, never accessed again due to mem::forget
10310        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10311        // Prevent Drop from running (which would shut down the channel)
10312        std::mem::forget(self);
10313    }
10314}
10315
10316impl AudioRendererSendPacketResponder {
10317    /// Sends a response to the FIDL transaction.
10318    ///
10319    /// Sets the channel to shutdown if an error occurs.
10320    pub fn send(self) -> Result<(), fidl::Error> {
10321        let _result = self.send_raw();
10322        if _result.is_err() {
10323            self.control_handle.shutdown();
10324        }
10325        self.drop_without_shutdown();
10326        _result
10327    }
10328
10329    /// Similar to "send" but does not shutdown the channel if an error occurs.
10330    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10331        let _result = self.send_raw();
10332        self.drop_without_shutdown();
10333        _result
10334    }
10335
10336    fn send_raw(&self) -> Result<(), fidl::Error> {
10337        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10338            (),
10339            self.tx_id,
10340            0x67cddd607442775f,
10341            fidl::encoding::DynamicFlags::empty(),
10342        )
10343    }
10344}
10345
10346#[must_use = "FIDL methods require a response to be sent"]
10347#[derive(Debug)]
10348pub struct AudioRendererDiscardAllPacketsResponder {
10349    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10350    tx_id: u32,
10351}
10352
10353/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10354/// if the responder is dropped without sending a response, so that the client
10355/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10356impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10357    fn drop(&mut self) {
10358        self.control_handle.shutdown();
10359        // Safety: drops once, never accessed again
10360        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10361    }
10362}
10363
10364impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10365    type ControlHandle = AudioRendererControlHandle;
10366
10367    fn control_handle(&self) -> &AudioRendererControlHandle {
10368        &self.control_handle
10369    }
10370
10371    fn drop_without_shutdown(mut self) {
10372        // Safety: drops once, never accessed again due to mem::forget
10373        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10374        // Prevent Drop from running (which would shut down the channel)
10375        std::mem::forget(self);
10376    }
10377}
10378
10379impl AudioRendererDiscardAllPacketsResponder {
10380    /// Sends a response to the FIDL transaction.
10381    ///
10382    /// Sets the channel to shutdown if an error occurs.
10383    pub fn send(self) -> Result<(), fidl::Error> {
10384        let _result = self.send_raw();
10385        if _result.is_err() {
10386            self.control_handle.shutdown();
10387        }
10388        self.drop_without_shutdown();
10389        _result
10390    }
10391
10392    /// Similar to "send" but does not shutdown the channel if an error occurs.
10393    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10394        let _result = self.send_raw();
10395        self.drop_without_shutdown();
10396        _result
10397    }
10398
10399    fn send_raw(&self) -> Result<(), fidl::Error> {
10400        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10401            (),
10402            self.tx_id,
10403            0x6f4dad7af2917665,
10404            fidl::encoding::DynamicFlags::empty(),
10405        )
10406    }
10407}
10408
10409#[must_use = "FIDL methods require a response to be sent"]
10410#[derive(Debug)]
10411pub struct AudioRendererGetReferenceClockResponder {
10412    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10413    tx_id: u32,
10414}
10415
10416/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10417/// if the responder is dropped without sending a response, so that the client
10418/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10419impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10420    fn drop(&mut self) {
10421        self.control_handle.shutdown();
10422        // Safety: drops once, never accessed again
10423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10424    }
10425}
10426
10427impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10428    type ControlHandle = AudioRendererControlHandle;
10429
10430    fn control_handle(&self) -> &AudioRendererControlHandle {
10431        &self.control_handle
10432    }
10433
10434    fn drop_without_shutdown(mut self) {
10435        // Safety: drops once, never accessed again due to mem::forget
10436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10437        // Prevent Drop from running (which would shut down the channel)
10438        std::mem::forget(self);
10439    }
10440}
10441
10442impl AudioRendererGetReferenceClockResponder {
10443    /// Sends a response to the FIDL transaction.
10444    ///
10445    /// Sets the channel to shutdown if an error occurs.
10446    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10447        let _result = self.send_raw(reference_clock);
10448        if _result.is_err() {
10449            self.control_handle.shutdown();
10450        }
10451        self.drop_without_shutdown();
10452        _result
10453    }
10454
10455    /// Similar to "send" but does not shutdown the channel if an error occurs.
10456    pub fn send_no_shutdown_on_err(
10457        self,
10458        mut reference_clock: fidl::Clock,
10459    ) -> Result<(), fidl::Error> {
10460        let _result = self.send_raw(reference_clock);
10461        self.drop_without_shutdown();
10462        _result
10463    }
10464
10465    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10466        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10467            (reference_clock,),
10468            self.tx_id,
10469            0x2f7a7f011a172f7e,
10470            fidl::encoding::DynamicFlags::empty(),
10471        )
10472    }
10473}
10474
10475#[must_use = "FIDL methods require a response to be sent"]
10476#[derive(Debug)]
10477pub struct AudioRendererGetMinLeadTimeResponder {
10478    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10479    tx_id: u32,
10480}
10481
10482/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10483/// if the responder is dropped without sending a response, so that the client
10484/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10485impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10486    fn drop(&mut self) {
10487        self.control_handle.shutdown();
10488        // Safety: drops once, never accessed again
10489        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10490    }
10491}
10492
10493impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10494    type ControlHandle = AudioRendererControlHandle;
10495
10496    fn control_handle(&self) -> &AudioRendererControlHandle {
10497        &self.control_handle
10498    }
10499
10500    fn drop_without_shutdown(mut self) {
10501        // Safety: drops once, never accessed again due to mem::forget
10502        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10503        // Prevent Drop from running (which would shut down the channel)
10504        std::mem::forget(self);
10505    }
10506}
10507
10508impl AudioRendererGetMinLeadTimeResponder {
10509    /// Sends a response to the FIDL transaction.
10510    ///
10511    /// Sets the channel to shutdown if an error occurs.
10512    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10513        let _result = self.send_raw(min_lead_time_nsec);
10514        if _result.is_err() {
10515            self.control_handle.shutdown();
10516        }
10517        self.drop_without_shutdown();
10518        _result
10519    }
10520
10521    /// Similar to "send" but does not shutdown the channel if an error occurs.
10522    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10523        let _result = self.send_raw(min_lead_time_nsec);
10524        self.drop_without_shutdown();
10525        _result
10526    }
10527
10528    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10529        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10530            (min_lead_time_nsec,),
10531            self.tx_id,
10532            0x1cf3c3ecd8fec26b,
10533            fidl::encoding::DynamicFlags::empty(),
10534        )
10535    }
10536}
10537
10538#[must_use = "FIDL methods require a response to be sent"]
10539#[derive(Debug)]
10540pub struct AudioRendererPlayResponder {
10541    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10542    tx_id: u32,
10543}
10544
10545/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10546/// if the responder is dropped without sending a response, so that the client
10547/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10548impl std::ops::Drop for AudioRendererPlayResponder {
10549    fn drop(&mut self) {
10550        self.control_handle.shutdown();
10551        // Safety: drops once, never accessed again
10552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10553    }
10554}
10555
10556impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10557    type ControlHandle = AudioRendererControlHandle;
10558
10559    fn control_handle(&self) -> &AudioRendererControlHandle {
10560        &self.control_handle
10561    }
10562
10563    fn drop_without_shutdown(mut self) {
10564        // Safety: drops once, never accessed again due to mem::forget
10565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10566        // Prevent Drop from running (which would shut down the channel)
10567        std::mem::forget(self);
10568    }
10569}
10570
10571impl AudioRendererPlayResponder {
10572    /// Sends a response to the FIDL transaction.
10573    ///
10574    /// Sets the channel to shutdown if an error occurs.
10575    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10576        let _result = self.send_raw(reference_time, media_time);
10577        if _result.is_err() {
10578            self.control_handle.shutdown();
10579        }
10580        self.drop_without_shutdown();
10581        _result
10582    }
10583
10584    /// Similar to "send" but does not shutdown the channel if an error occurs.
10585    pub fn send_no_shutdown_on_err(
10586        self,
10587        mut reference_time: i64,
10588        mut media_time: i64,
10589    ) -> Result<(), fidl::Error> {
10590        let _result = self.send_raw(reference_time, media_time);
10591        self.drop_without_shutdown();
10592        _result
10593    }
10594
10595    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10596        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10597            (reference_time, media_time),
10598            self.tx_id,
10599            0x3c0162db084f74a3,
10600            fidl::encoding::DynamicFlags::empty(),
10601        )
10602    }
10603}
10604
10605#[must_use = "FIDL methods require a response to be sent"]
10606#[derive(Debug)]
10607pub struct AudioRendererPauseResponder {
10608    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10609    tx_id: u32,
10610}
10611
10612/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10613/// if the responder is dropped without sending a response, so that the client
10614/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10615impl std::ops::Drop for AudioRendererPauseResponder {
10616    fn drop(&mut self) {
10617        self.control_handle.shutdown();
10618        // Safety: drops once, never accessed again
10619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10620    }
10621}
10622
10623impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10624    type ControlHandle = AudioRendererControlHandle;
10625
10626    fn control_handle(&self) -> &AudioRendererControlHandle {
10627        &self.control_handle
10628    }
10629
10630    fn drop_without_shutdown(mut self) {
10631        // Safety: drops once, never accessed again due to mem::forget
10632        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10633        // Prevent Drop from running (which would shut down the channel)
10634        std::mem::forget(self);
10635    }
10636}
10637
10638impl AudioRendererPauseResponder {
10639    /// Sends a response to the FIDL transaction.
10640    ///
10641    /// Sets the channel to shutdown if an error occurs.
10642    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10643        let _result = self.send_raw(reference_time, media_time);
10644        if _result.is_err() {
10645            self.control_handle.shutdown();
10646        }
10647        self.drop_without_shutdown();
10648        _result
10649    }
10650
10651    /// Similar to "send" but does not shutdown the channel if an error occurs.
10652    pub fn send_no_shutdown_on_err(
10653        self,
10654        mut reference_time: i64,
10655        mut media_time: i64,
10656    ) -> Result<(), fidl::Error> {
10657        let _result = self.send_raw(reference_time, media_time);
10658        self.drop_without_shutdown();
10659        _result
10660    }
10661
10662    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10663        self.control_handle.inner.send::<AudioRendererPauseResponse>(
10664            (reference_time, media_time),
10665            self.tx_id,
10666            0x41d557588d93d153,
10667            fidl::encoding::DynamicFlags::empty(),
10668        )
10669    }
10670}
10671
10672#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10673pub struct ProfileProviderMarker;
10674
10675impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
10676    type Proxy = ProfileProviderProxy;
10677    type RequestStream = ProfileProviderRequestStream;
10678    #[cfg(target_os = "fuchsia")]
10679    type SynchronousProxy = ProfileProviderSynchronousProxy;
10680
10681    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
10682}
10683impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
10684
10685pub trait ProfileProviderProxyInterface: Send + Sync {
10686    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
10687        + Send;
10688    fn r#register_handler_with_capacity(
10689        &self,
10690        thread_handle: fidl::Thread,
10691        name: &str,
10692        period: i64,
10693        capacity: f32,
10694    ) -> Self::RegisterHandlerWithCapacityResponseFut;
10695    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10696    fn r#unregister_handler(
10697        &self,
10698        thread_handle: fidl::Thread,
10699        name: &str,
10700    ) -> Self::UnregisterHandlerResponseFut;
10701    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10702        + Send;
10703    fn r#register_memory_range(
10704        &self,
10705        vmar_handle: fidl::Vmar,
10706        name: &str,
10707    ) -> Self::RegisterMemoryRangeResponseFut;
10708    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10709        + Send;
10710    fn r#unregister_memory_range(
10711        &self,
10712        vmar_handle: fidl::Vmar,
10713    ) -> Self::UnregisterMemoryRangeResponseFut;
10714}
10715#[derive(Debug)]
10716#[cfg(target_os = "fuchsia")]
10717pub struct ProfileProviderSynchronousProxy {
10718    client: fidl::client::sync::Client,
10719}
10720
10721#[cfg(target_os = "fuchsia")]
10722impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
10723    type Proxy = ProfileProviderProxy;
10724    type Protocol = ProfileProviderMarker;
10725
10726    fn from_channel(inner: fidl::Channel) -> Self {
10727        Self::new(inner)
10728    }
10729
10730    fn into_channel(self) -> fidl::Channel {
10731        self.client.into_channel()
10732    }
10733
10734    fn as_channel(&self) -> &fidl::Channel {
10735        self.client.as_channel()
10736    }
10737}
10738
10739#[cfg(target_os = "fuchsia")]
10740impl ProfileProviderSynchronousProxy {
10741    pub fn new(channel: fidl::Channel) -> Self {
10742        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10743        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10744    }
10745
10746    pub fn into_channel(self) -> fidl::Channel {
10747        self.client.into_channel()
10748    }
10749
10750    /// Waits until an event arrives and returns it. It is safe for other
10751    /// threads to make concurrent requests while waiting for an event.
10752    pub fn wait_for_event(
10753        &self,
10754        deadline: zx::MonotonicInstant,
10755    ) -> Result<ProfileProviderEvent, fidl::Error> {
10756        ProfileProviderEvent::decode(self.client.wait_for_event(deadline)?)
10757    }
10758
10759    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10760    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10761    /// deadlines.
10762    ///
10763    /// `name` is the name of a system scheduling role to apply to the thread given by
10764    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10765    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10766    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10767    /// the scheduling interval the thread needs to be running to achieve good performance or to
10768    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10769    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10770    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10771    /// be rejected or result in scaling back the performance of other threads to fit resource
10772    /// limits.
10773    ///
10774    /// Capacity, max runtime, and period have the following relationship:
10775    ///
10776    ///   capacity = max runtime / period
10777    ///
10778    /// Where:
10779    ///
10780    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10781    ///
10782    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10783    /// performance processor(s) in the system. The system will automatically adjust the effective
10784    /// capacity to account for slower processors and operating points and will avoid processors and
10785    /// operating points that are too slow to meet the requested scheduling parameters (provided
10786    /// they are reasonable).
10787    ///
10788    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10789    /// may be zero to indicate not applicable.
10790    pub fn r#register_handler_with_capacity(
10791        &self,
10792        mut thread_handle: fidl::Thread,
10793        mut name: &str,
10794        mut period: i64,
10795        mut capacity: f32,
10796        ___deadline: zx::MonotonicInstant,
10797    ) -> Result<(i64, i64), fidl::Error> {
10798        let _response = self.client.send_query::<
10799            ProfileProviderRegisterHandlerWithCapacityRequest,
10800            ProfileProviderRegisterHandlerWithCapacityResponse,
10801        >(
10802            (thread_handle, name, period, capacity,),
10803            0x60459ecef7458176,
10804            fidl::encoding::DynamicFlags::empty(),
10805            ___deadline,
10806        )?;
10807        Ok((_response.period, _response.capacity))
10808    }
10809
10810    /// Reset a thread's scheduling profile to the default.
10811    pub fn r#unregister_handler(
10812        &self,
10813        mut thread_handle: fidl::Thread,
10814        mut name: &str,
10815        ___deadline: zx::MonotonicInstant,
10816    ) -> Result<(), fidl::Error> {
10817        let _response = self
10818            .client
10819            .send_query::<ProfileProviderUnregisterHandlerRequest, fidl::encoding::EmptyPayload>(
10820                (thread_handle, name),
10821                0x724d9d5fd8ef544c,
10822                fidl::encoding::DynamicFlags::empty(),
10823                ___deadline,
10824            )?;
10825        Ok(_response)
10826    }
10827
10828    /// Register a memory range as being used for media processing. This notifies the media
10829    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10830    /// meet audio or video deadlines.
10831    ///
10832    /// `name` is the name of a system memory role to apply to the memory given by
10833    /// `vmar_handle` -- different products may customize the underlying memory strategy based
10834    /// on the requested role.
10835    pub fn r#register_memory_range(
10836        &self,
10837        mut vmar_handle: fidl::Vmar,
10838        mut name: &str,
10839        ___deadline: zx::MonotonicInstant,
10840    ) -> Result<(), fidl::Error> {
10841        let _response = self
10842            .client
10843            .send_query::<ProfileProviderRegisterMemoryRangeRequest, fidl::encoding::EmptyPayload>(
10844                (vmar_handle, name),
10845                0x2f509d3523e9562d,
10846                fidl::encoding::DynamicFlags::empty(),
10847                ___deadline,
10848            )?;
10849        Ok(_response)
10850    }
10851
10852    /// Reset a memory range's memory profile.
10853    pub fn r#unregister_memory_range(
10854        &self,
10855        mut vmar_handle: fidl::Vmar,
10856        ___deadline: zx::MonotonicInstant,
10857    ) -> Result<(), fidl::Error> {
10858        let _response = self.client.send_query::<
10859            ProfileProviderUnregisterMemoryRangeRequest,
10860            fidl::encoding::EmptyPayload,
10861        >(
10862            (vmar_handle,),
10863            0x2dc313d6aa81ad27,
10864            fidl::encoding::DynamicFlags::empty(),
10865            ___deadline,
10866        )?;
10867        Ok(_response)
10868    }
10869}
10870
10871#[cfg(target_os = "fuchsia")]
10872impl From<ProfileProviderSynchronousProxy> for zx::Handle {
10873    fn from(value: ProfileProviderSynchronousProxy) -> Self {
10874        value.into_channel().into()
10875    }
10876}
10877
10878#[cfg(target_os = "fuchsia")]
10879impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
10880    fn from(value: fidl::Channel) -> Self {
10881        Self::new(value)
10882    }
10883}
10884
10885#[cfg(target_os = "fuchsia")]
10886impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
10887    type Protocol = ProfileProviderMarker;
10888
10889    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
10890        Self::new(value.into_channel())
10891    }
10892}
10893
10894#[derive(Debug, Clone)]
10895pub struct ProfileProviderProxy {
10896    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10897}
10898
10899impl fidl::endpoints::Proxy for ProfileProviderProxy {
10900    type Protocol = ProfileProviderMarker;
10901
10902    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10903        Self::new(inner)
10904    }
10905
10906    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10907        self.client.into_channel().map_err(|client| Self { client })
10908    }
10909
10910    fn as_channel(&self) -> &::fidl::AsyncChannel {
10911        self.client.as_channel()
10912    }
10913}
10914
10915impl ProfileProviderProxy {
10916    /// Create a new Proxy for fuchsia.media/ProfileProvider.
10917    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10918        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10919        Self { client: fidl::client::Client::new(channel, protocol_name) }
10920    }
10921
10922    /// Get a Stream of events from the remote end of the protocol.
10923    ///
10924    /// # Panics
10925    ///
10926    /// Panics if the event stream was already taken.
10927    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
10928        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
10929    }
10930
10931    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10932    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10933    /// deadlines.
10934    ///
10935    /// `name` is the name of a system scheduling role to apply to the thread given by
10936    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10937    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10938    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10939    /// the scheduling interval the thread needs to be running to achieve good performance or to
10940    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10941    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10942    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10943    /// be rejected or result in scaling back the performance of other threads to fit resource
10944    /// limits.
10945    ///
10946    /// Capacity, max runtime, and period have the following relationship:
10947    ///
10948    ///   capacity = max runtime / period
10949    ///
10950    /// Where:
10951    ///
10952    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10953    ///
10954    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10955    /// performance processor(s) in the system. The system will automatically adjust the effective
10956    /// capacity to account for slower processors and operating points and will avoid processors and
10957    /// operating points that are too slow to meet the requested scheduling parameters (provided
10958    /// they are reasonable).
10959    ///
10960    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10961    /// may be zero to indicate not applicable.
10962    pub fn r#register_handler_with_capacity(
10963        &self,
10964        mut thread_handle: fidl::Thread,
10965        mut name: &str,
10966        mut period: i64,
10967        mut capacity: f32,
10968    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
10969    {
10970        ProfileProviderProxyInterface::r#register_handler_with_capacity(
10971            self,
10972            thread_handle,
10973            name,
10974            period,
10975            capacity,
10976        )
10977    }
10978
10979    /// Reset a thread's scheduling profile to the default.
10980    pub fn r#unregister_handler(
10981        &self,
10982        mut thread_handle: fidl::Thread,
10983        mut name: &str,
10984    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10985        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
10986    }
10987
10988    /// Register a memory range as being used for media processing. This notifies the media
10989    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10990    /// meet audio or video deadlines.
10991    ///
10992    /// `name` is the name of a system memory role to apply to the memory given by
10993    /// `vmar_handle` -- different products may customize the underlying memory strategy based
10994    /// on the requested role.
10995    pub fn r#register_memory_range(
10996        &self,
10997        mut vmar_handle: fidl::Vmar,
10998        mut name: &str,
10999    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11000        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11001    }
11002
11003    /// Reset a memory range's memory profile.
11004    pub fn r#unregister_memory_range(
11005        &self,
11006        mut vmar_handle: fidl::Vmar,
11007    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11008        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11009    }
11010}
11011
11012impl ProfileProviderProxyInterface for ProfileProviderProxy {
11013    type RegisterHandlerWithCapacityResponseFut =
11014        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11015    fn r#register_handler_with_capacity(
11016        &self,
11017        mut thread_handle: fidl::Thread,
11018        mut name: &str,
11019        mut period: i64,
11020        mut capacity: f32,
11021    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11022        fn _decode(
11023            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11024        ) -> Result<(i64, i64), fidl::Error> {
11025            let _response = fidl::client::decode_transaction_body::<
11026                ProfileProviderRegisterHandlerWithCapacityResponse,
11027                fidl::encoding::DefaultFuchsiaResourceDialect,
11028                0x60459ecef7458176,
11029            >(_buf?)?;
11030            Ok((_response.period, _response.capacity))
11031        }
11032        self.client
11033            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11034                (thread_handle, name, period, capacity),
11035                0x60459ecef7458176,
11036                fidl::encoding::DynamicFlags::empty(),
11037                _decode,
11038            )
11039    }
11040
11041    type UnregisterHandlerResponseFut =
11042        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11043    fn r#unregister_handler(
11044        &self,
11045        mut thread_handle: fidl::Thread,
11046        mut name: &str,
11047    ) -> Self::UnregisterHandlerResponseFut {
11048        fn _decode(
11049            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11050        ) -> Result<(), fidl::Error> {
11051            let _response = fidl::client::decode_transaction_body::<
11052                fidl::encoding::EmptyPayload,
11053                fidl::encoding::DefaultFuchsiaResourceDialect,
11054                0x724d9d5fd8ef544c,
11055            >(_buf?)?;
11056            Ok(_response)
11057        }
11058        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11059            (thread_handle, name),
11060            0x724d9d5fd8ef544c,
11061            fidl::encoding::DynamicFlags::empty(),
11062            _decode,
11063        )
11064    }
11065
11066    type RegisterMemoryRangeResponseFut =
11067        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11068    fn r#register_memory_range(
11069        &self,
11070        mut vmar_handle: fidl::Vmar,
11071        mut name: &str,
11072    ) -> Self::RegisterMemoryRangeResponseFut {
11073        fn _decode(
11074            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11075        ) -> Result<(), fidl::Error> {
11076            let _response = fidl::client::decode_transaction_body::<
11077                fidl::encoding::EmptyPayload,
11078                fidl::encoding::DefaultFuchsiaResourceDialect,
11079                0x2f509d3523e9562d,
11080            >(_buf?)?;
11081            Ok(_response)
11082        }
11083        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11084            (vmar_handle, name),
11085            0x2f509d3523e9562d,
11086            fidl::encoding::DynamicFlags::empty(),
11087            _decode,
11088        )
11089    }
11090
11091    type UnregisterMemoryRangeResponseFut =
11092        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11093    fn r#unregister_memory_range(
11094        &self,
11095        mut vmar_handle: fidl::Vmar,
11096    ) -> Self::UnregisterMemoryRangeResponseFut {
11097        fn _decode(
11098            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11099        ) -> Result<(), fidl::Error> {
11100            let _response = fidl::client::decode_transaction_body::<
11101                fidl::encoding::EmptyPayload,
11102                fidl::encoding::DefaultFuchsiaResourceDialect,
11103                0x2dc313d6aa81ad27,
11104            >(_buf?)?;
11105            Ok(_response)
11106        }
11107        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11108            (vmar_handle,),
11109            0x2dc313d6aa81ad27,
11110            fidl::encoding::DynamicFlags::empty(),
11111            _decode,
11112        )
11113    }
11114}
11115
11116pub struct ProfileProviderEventStream {
11117    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11118}
11119
11120impl std::marker::Unpin for ProfileProviderEventStream {}
11121
11122impl futures::stream::FusedStream for ProfileProviderEventStream {
11123    fn is_terminated(&self) -> bool {
11124        self.event_receiver.is_terminated()
11125    }
11126}
11127
11128impl futures::Stream for ProfileProviderEventStream {
11129    type Item = Result<ProfileProviderEvent, fidl::Error>;
11130
11131    fn poll_next(
11132        mut self: std::pin::Pin<&mut Self>,
11133        cx: &mut std::task::Context<'_>,
11134    ) -> std::task::Poll<Option<Self::Item>> {
11135        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11136            &mut self.event_receiver,
11137            cx
11138        )?) {
11139            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11140            None => std::task::Poll::Ready(None),
11141        }
11142    }
11143}
11144
11145#[derive(Debug)]
11146pub enum ProfileProviderEvent {}
11147
11148impl ProfileProviderEvent {
11149    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11150    fn decode(
11151        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11152    ) -> Result<ProfileProviderEvent, fidl::Error> {
11153        let (bytes, _handles) = buf.split_mut();
11154        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11155        debug_assert_eq!(tx_header.tx_id, 0);
11156        match tx_header.ordinal {
11157            _ => Err(fidl::Error::UnknownOrdinal {
11158                ordinal: tx_header.ordinal,
11159                protocol_name:
11160                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11161            }),
11162        }
11163    }
11164}
11165
11166/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11167pub struct ProfileProviderRequestStream {
11168    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11169    is_terminated: bool,
11170}
11171
11172impl std::marker::Unpin for ProfileProviderRequestStream {}
11173
11174impl futures::stream::FusedStream for ProfileProviderRequestStream {
11175    fn is_terminated(&self) -> bool {
11176        self.is_terminated
11177    }
11178}
11179
11180impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11181    type Protocol = ProfileProviderMarker;
11182    type ControlHandle = ProfileProviderControlHandle;
11183
11184    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11185        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11186    }
11187
11188    fn control_handle(&self) -> Self::ControlHandle {
11189        ProfileProviderControlHandle { inner: self.inner.clone() }
11190    }
11191
11192    fn into_inner(
11193        self,
11194    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11195    {
11196        (self.inner, self.is_terminated)
11197    }
11198
11199    fn from_inner(
11200        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11201        is_terminated: bool,
11202    ) -> Self {
11203        Self { inner, is_terminated }
11204    }
11205}
11206
11207impl futures::Stream for ProfileProviderRequestStream {
11208    type Item = Result<ProfileProviderRequest, fidl::Error>;
11209
11210    fn poll_next(
11211        mut self: std::pin::Pin<&mut Self>,
11212        cx: &mut std::task::Context<'_>,
11213    ) -> std::task::Poll<Option<Self::Item>> {
11214        let this = &mut *self;
11215        if this.inner.check_shutdown(cx) {
11216            this.is_terminated = true;
11217            return std::task::Poll::Ready(None);
11218        }
11219        if this.is_terminated {
11220            panic!("polled ProfileProviderRequestStream after completion");
11221        }
11222        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11223            |bytes, handles| {
11224                match this.inner.channel().read_etc(cx, bytes, handles) {
11225                    std::task::Poll::Ready(Ok(())) => {}
11226                    std::task::Poll::Pending => return std::task::Poll::Pending,
11227                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11228                        this.is_terminated = true;
11229                        return std::task::Poll::Ready(None);
11230                    }
11231                    std::task::Poll::Ready(Err(e)) => {
11232                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11233                            e.into(),
11234                        ))));
11235                    }
11236                }
11237
11238                // A message has been received from the channel
11239                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11240
11241                std::task::Poll::Ready(Some(match header.ordinal {
11242                    0x60459ecef7458176 => {
11243                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11244                        let mut req = fidl::new_empty!(
11245                            ProfileProviderRegisterHandlerWithCapacityRequest,
11246                            fidl::encoding::DefaultFuchsiaResourceDialect
11247                        );
11248                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11249                        let control_handle =
11250                            ProfileProviderControlHandle { inner: this.inner.clone() };
11251                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11252                            thread_handle: req.thread_handle,
11253                            name: req.name,
11254                            period: req.period,
11255                            capacity: req.capacity,
11256
11257                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11258                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11259                                tx_id: header.tx_id,
11260                            },
11261                        })
11262                    }
11263                    0x724d9d5fd8ef544c => {
11264                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11265                        let mut req = fidl::new_empty!(
11266                            ProfileProviderUnregisterHandlerRequest,
11267                            fidl::encoding::DefaultFuchsiaResourceDialect
11268                        );
11269                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11270                        let control_handle =
11271                            ProfileProviderControlHandle { inner: this.inner.clone() };
11272                        Ok(ProfileProviderRequest::UnregisterHandler {
11273                            thread_handle: req.thread_handle,
11274                            name: req.name,
11275
11276                            responder: ProfileProviderUnregisterHandlerResponder {
11277                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11278                                tx_id: header.tx_id,
11279                            },
11280                        })
11281                    }
11282                    0x2f509d3523e9562d => {
11283                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11284                        let mut req = fidl::new_empty!(
11285                            ProfileProviderRegisterMemoryRangeRequest,
11286                            fidl::encoding::DefaultFuchsiaResourceDialect
11287                        );
11288                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11289                        let control_handle =
11290                            ProfileProviderControlHandle { inner: this.inner.clone() };
11291                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11292                            vmar_handle: req.vmar_handle,
11293                            name: req.name,
11294
11295                            responder: ProfileProviderRegisterMemoryRangeResponder {
11296                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11297                                tx_id: header.tx_id,
11298                            },
11299                        })
11300                    }
11301                    0x2dc313d6aa81ad27 => {
11302                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11303                        let mut req = fidl::new_empty!(
11304                            ProfileProviderUnregisterMemoryRangeRequest,
11305                            fidl::encoding::DefaultFuchsiaResourceDialect
11306                        );
11307                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11308                        let control_handle =
11309                            ProfileProviderControlHandle { inner: this.inner.clone() };
11310                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11311                            vmar_handle: req.vmar_handle,
11312
11313                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11314                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11315                                tx_id: header.tx_id,
11316                            },
11317                        })
11318                    }
11319                    _ => Err(fidl::Error::UnknownOrdinal {
11320                        ordinal: header.ordinal,
11321                        protocol_name:
11322                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11323                    }),
11324                }))
11325            },
11326        )
11327    }
11328}
11329
11330#[derive(Debug)]
11331pub enum ProfileProviderRequest {
11332    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11333    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11334    /// deadlines.
11335    ///
11336    /// `name` is the name of a system scheduling role to apply to the thread given by
11337    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11338    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11339    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11340    /// the scheduling interval the thread needs to be running to achieve good performance or to
11341    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11342    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11343    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11344    /// be rejected or result in scaling back the performance of other threads to fit resource
11345    /// limits.
11346    ///
11347    /// Capacity, max runtime, and period have the following relationship:
11348    ///
11349    ///   capacity = max runtime / period
11350    ///
11351    /// Where:
11352    ///
11353    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11354    ///
11355    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11356    /// performance processor(s) in the system. The system will automatically adjust the effective
11357    /// capacity to account for slower processors and operating points and will avoid processors and
11358    /// operating points that are too slow to meet the requested scheduling parameters (provided
11359    /// they are reasonable).
11360    ///
11361    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11362    /// may be zero to indicate not applicable.
11363    RegisterHandlerWithCapacity {
11364        thread_handle: fidl::Thread,
11365        name: String,
11366        period: i64,
11367        capacity: f32,
11368        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11369    },
11370    /// Reset a thread's scheduling profile to the default.
11371    UnregisterHandler {
11372        thread_handle: fidl::Thread,
11373        name: String,
11374        responder: ProfileProviderUnregisterHandlerResponder,
11375    },
11376    /// Register a memory range as being used for media processing. This notifies the media
11377    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11378    /// meet audio or video deadlines.
11379    ///
11380    /// `name` is the name of a system memory role to apply to the memory given by
11381    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11382    /// on the requested role.
11383    RegisterMemoryRange {
11384        vmar_handle: fidl::Vmar,
11385        name: String,
11386        responder: ProfileProviderRegisterMemoryRangeResponder,
11387    },
11388    /// Reset a memory range's memory profile.
11389    UnregisterMemoryRange {
11390        vmar_handle: fidl::Vmar,
11391        responder: ProfileProviderUnregisterMemoryRangeResponder,
11392    },
11393}
11394
11395impl ProfileProviderRequest {
11396    #[allow(irrefutable_let_patterns)]
11397    pub fn into_register_handler_with_capacity(
11398        self,
11399    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11400    {
11401        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11402            thread_handle,
11403            name,
11404            period,
11405            capacity,
11406            responder,
11407        } = self
11408        {
11409            Some((thread_handle, name, period, capacity, responder))
11410        } else {
11411            None
11412        }
11413    }
11414
11415    #[allow(irrefutable_let_patterns)]
11416    pub fn into_unregister_handler(
11417        self,
11418    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11419        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11420            Some((thread_handle, name, responder))
11421        } else {
11422            None
11423        }
11424    }
11425
11426    #[allow(irrefutable_let_patterns)]
11427    pub fn into_register_memory_range(
11428        self,
11429    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11430        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11431            Some((vmar_handle, name, responder))
11432        } else {
11433            None
11434        }
11435    }
11436
11437    #[allow(irrefutable_let_patterns)]
11438    pub fn into_unregister_memory_range(
11439        self,
11440    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11441        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11442            Some((vmar_handle, responder))
11443        } else {
11444            None
11445        }
11446    }
11447
11448    /// Name of the method defined in FIDL
11449    pub fn method_name(&self) -> &'static str {
11450        match *self {
11451            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11452                "register_handler_with_capacity"
11453            }
11454            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11455            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11456            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11457        }
11458    }
11459}
11460
11461#[derive(Debug, Clone)]
11462pub struct ProfileProviderControlHandle {
11463    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11464}
11465
11466impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11467    fn shutdown(&self) {
11468        self.inner.shutdown()
11469    }
11470    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11471        self.inner.shutdown_with_epitaph(status)
11472    }
11473
11474    fn is_closed(&self) -> bool {
11475        self.inner.channel().is_closed()
11476    }
11477    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11478        self.inner.channel().on_closed()
11479    }
11480
11481    #[cfg(target_os = "fuchsia")]
11482    fn signal_peer(
11483        &self,
11484        clear_mask: zx::Signals,
11485        set_mask: zx::Signals,
11486    ) -> Result<(), zx_status::Status> {
11487        use fidl::Peered;
11488        self.inner.channel().signal_peer(clear_mask, set_mask)
11489    }
11490}
11491
11492impl ProfileProviderControlHandle {}
11493
11494#[must_use = "FIDL methods require a response to be sent"]
11495#[derive(Debug)]
11496pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11497    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11498    tx_id: u32,
11499}
11500
11501/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11502/// if the responder is dropped without sending a response, so that the client
11503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11504impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11505    fn drop(&mut self) {
11506        self.control_handle.shutdown();
11507        // Safety: drops once, never accessed again
11508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11509    }
11510}
11511
11512impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11513    type ControlHandle = ProfileProviderControlHandle;
11514
11515    fn control_handle(&self) -> &ProfileProviderControlHandle {
11516        &self.control_handle
11517    }
11518
11519    fn drop_without_shutdown(mut self) {
11520        // Safety: drops once, never accessed again due to mem::forget
11521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11522        // Prevent Drop from running (which would shut down the channel)
11523        std::mem::forget(self);
11524    }
11525}
11526
11527impl ProfileProviderRegisterHandlerWithCapacityResponder {
11528    /// Sends a response to the FIDL transaction.
11529    ///
11530    /// Sets the channel to shutdown if an error occurs.
11531    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11532        let _result = self.send_raw(period, capacity);
11533        if _result.is_err() {
11534            self.control_handle.shutdown();
11535        }
11536        self.drop_without_shutdown();
11537        _result
11538    }
11539
11540    /// Similar to "send" but does not shutdown the channel if an error occurs.
11541    pub fn send_no_shutdown_on_err(
11542        self,
11543        mut period: i64,
11544        mut capacity: i64,
11545    ) -> Result<(), fidl::Error> {
11546        let _result = self.send_raw(period, capacity);
11547        self.drop_without_shutdown();
11548        _result
11549    }
11550
11551    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11552        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11553            (period, capacity),
11554            self.tx_id,
11555            0x60459ecef7458176,
11556            fidl::encoding::DynamicFlags::empty(),
11557        )
11558    }
11559}
11560
11561#[must_use = "FIDL methods require a response to be sent"]
11562#[derive(Debug)]
11563pub struct ProfileProviderUnregisterHandlerResponder {
11564    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11565    tx_id: u32,
11566}
11567
11568/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11569/// if the responder is dropped without sending a response, so that the client
11570/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11571impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11572    fn drop(&mut self) {
11573        self.control_handle.shutdown();
11574        // Safety: drops once, never accessed again
11575        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11576    }
11577}
11578
11579impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11580    type ControlHandle = ProfileProviderControlHandle;
11581
11582    fn control_handle(&self) -> &ProfileProviderControlHandle {
11583        &self.control_handle
11584    }
11585
11586    fn drop_without_shutdown(mut self) {
11587        // Safety: drops once, never accessed again due to mem::forget
11588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11589        // Prevent Drop from running (which would shut down the channel)
11590        std::mem::forget(self);
11591    }
11592}
11593
11594impl ProfileProviderUnregisterHandlerResponder {
11595    /// Sends a response to the FIDL transaction.
11596    ///
11597    /// Sets the channel to shutdown if an error occurs.
11598    pub fn send(self) -> Result<(), fidl::Error> {
11599        let _result = self.send_raw();
11600        if _result.is_err() {
11601            self.control_handle.shutdown();
11602        }
11603        self.drop_without_shutdown();
11604        _result
11605    }
11606
11607    /// Similar to "send" but does not shutdown the channel if an error occurs.
11608    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11609        let _result = self.send_raw();
11610        self.drop_without_shutdown();
11611        _result
11612    }
11613
11614    fn send_raw(&self) -> Result<(), fidl::Error> {
11615        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11616            (),
11617            self.tx_id,
11618            0x724d9d5fd8ef544c,
11619            fidl::encoding::DynamicFlags::empty(),
11620        )
11621    }
11622}
11623
11624#[must_use = "FIDL methods require a response to be sent"]
11625#[derive(Debug)]
11626pub struct ProfileProviderRegisterMemoryRangeResponder {
11627    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11628    tx_id: u32,
11629}
11630
11631/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11632/// if the responder is dropped without sending a response, so that the client
11633/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11634impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
11635    fn drop(&mut self) {
11636        self.control_handle.shutdown();
11637        // Safety: drops once, never accessed again
11638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11639    }
11640}
11641
11642impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
11643    type ControlHandle = ProfileProviderControlHandle;
11644
11645    fn control_handle(&self) -> &ProfileProviderControlHandle {
11646        &self.control_handle
11647    }
11648
11649    fn drop_without_shutdown(mut self) {
11650        // Safety: drops once, never accessed again due to mem::forget
11651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11652        // Prevent Drop from running (which would shut down the channel)
11653        std::mem::forget(self);
11654    }
11655}
11656
11657impl ProfileProviderRegisterMemoryRangeResponder {
11658    /// Sends a response to the FIDL transaction.
11659    ///
11660    /// Sets the channel to shutdown if an error occurs.
11661    pub fn send(self) -> Result<(), fidl::Error> {
11662        let _result = self.send_raw();
11663        if _result.is_err() {
11664            self.control_handle.shutdown();
11665        }
11666        self.drop_without_shutdown();
11667        _result
11668    }
11669
11670    /// Similar to "send" but does not shutdown the channel if an error occurs.
11671    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11672        let _result = self.send_raw();
11673        self.drop_without_shutdown();
11674        _result
11675    }
11676
11677    fn send_raw(&self) -> Result<(), fidl::Error> {
11678        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11679            (),
11680            self.tx_id,
11681            0x2f509d3523e9562d,
11682            fidl::encoding::DynamicFlags::empty(),
11683        )
11684    }
11685}
11686
11687#[must_use = "FIDL methods require a response to be sent"]
11688#[derive(Debug)]
11689pub struct ProfileProviderUnregisterMemoryRangeResponder {
11690    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11691    tx_id: u32,
11692}
11693
11694/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11695/// if the responder is dropped without sending a response, so that the client
11696/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11697impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
11698    fn drop(&mut self) {
11699        self.control_handle.shutdown();
11700        // Safety: drops once, never accessed again
11701        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11702    }
11703}
11704
11705impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
11706    type ControlHandle = ProfileProviderControlHandle;
11707
11708    fn control_handle(&self) -> &ProfileProviderControlHandle {
11709        &self.control_handle
11710    }
11711
11712    fn drop_without_shutdown(mut self) {
11713        // Safety: drops once, never accessed again due to mem::forget
11714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11715        // Prevent Drop from running (which would shut down the channel)
11716        std::mem::forget(self);
11717    }
11718}
11719
11720impl ProfileProviderUnregisterMemoryRangeResponder {
11721    /// Sends a response to the FIDL transaction.
11722    ///
11723    /// Sets the channel to shutdown if an error occurs.
11724    pub fn send(self) -> Result<(), fidl::Error> {
11725        let _result = self.send_raw();
11726        if _result.is_err() {
11727            self.control_handle.shutdown();
11728        }
11729        self.drop_without_shutdown();
11730        _result
11731    }
11732
11733    /// Similar to "send" but does not shutdown the channel if an error occurs.
11734    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11735        let _result = self.send_raw();
11736        self.drop_without_shutdown();
11737        _result
11738    }
11739
11740    fn send_raw(&self) -> Result<(), fidl::Error> {
11741        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11742            (),
11743            self.tx_id,
11744            0x2dc313d6aa81ad27,
11745            fidl::encoding::DynamicFlags::empty(),
11746        )
11747    }
11748}
11749
11750#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11751pub struct SessionAudioConsumerFactoryMarker;
11752
11753impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
11754    type Proxy = SessionAudioConsumerFactoryProxy;
11755    type RequestStream = SessionAudioConsumerFactoryRequestStream;
11756    #[cfg(target_os = "fuchsia")]
11757    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
11758
11759    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
11760}
11761impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
11762
11763pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
11764    fn r#create_audio_consumer(
11765        &self,
11766        session_id: u64,
11767        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11768    ) -> Result<(), fidl::Error>;
11769}
11770#[derive(Debug)]
11771#[cfg(target_os = "fuchsia")]
11772pub struct SessionAudioConsumerFactorySynchronousProxy {
11773    client: fidl::client::sync::Client,
11774}
11775
11776#[cfg(target_os = "fuchsia")]
11777impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
11778    type Proxy = SessionAudioConsumerFactoryProxy;
11779    type Protocol = SessionAudioConsumerFactoryMarker;
11780
11781    fn from_channel(inner: fidl::Channel) -> Self {
11782        Self::new(inner)
11783    }
11784
11785    fn into_channel(self) -> fidl::Channel {
11786        self.client.into_channel()
11787    }
11788
11789    fn as_channel(&self) -> &fidl::Channel {
11790        self.client.as_channel()
11791    }
11792}
11793
11794#[cfg(target_os = "fuchsia")]
11795impl SessionAudioConsumerFactorySynchronousProxy {
11796    pub fn new(channel: fidl::Channel) -> Self {
11797        let protocol_name =
11798            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11799        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
11800    }
11801
11802    pub fn into_channel(self) -> fidl::Channel {
11803        self.client.into_channel()
11804    }
11805
11806    /// Waits until an event arrives and returns it. It is safe for other
11807    /// threads to make concurrent requests while waiting for an event.
11808    pub fn wait_for_event(
11809        &self,
11810        deadline: zx::MonotonicInstant,
11811    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11812        SessionAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
11813    }
11814
11815    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11816    /// to a particular session. `session_id` is the identifier of the media session
11817    /// for which audio is to be rendered.
11818    pub fn r#create_audio_consumer(
11819        &self,
11820        mut session_id: u64,
11821        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11822    ) -> Result<(), fidl::Error> {
11823        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11824            (session_id, audio_consumer_request),
11825            0x6fab96f988e7d7fb,
11826            fidl::encoding::DynamicFlags::empty(),
11827        )
11828    }
11829}
11830
11831#[cfg(target_os = "fuchsia")]
11832impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::Handle {
11833    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
11834        value.into_channel().into()
11835    }
11836}
11837
11838#[cfg(target_os = "fuchsia")]
11839impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
11840    fn from(value: fidl::Channel) -> Self {
11841        Self::new(value)
11842    }
11843}
11844
11845#[cfg(target_os = "fuchsia")]
11846impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
11847    type Protocol = SessionAudioConsumerFactoryMarker;
11848
11849    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
11850        Self::new(value.into_channel())
11851    }
11852}
11853
11854#[derive(Debug, Clone)]
11855pub struct SessionAudioConsumerFactoryProxy {
11856    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11857}
11858
11859impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
11860    type Protocol = SessionAudioConsumerFactoryMarker;
11861
11862    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11863        Self::new(inner)
11864    }
11865
11866    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11867        self.client.into_channel().map_err(|client| Self { client })
11868    }
11869
11870    fn as_channel(&self) -> &::fidl::AsyncChannel {
11871        self.client.as_channel()
11872    }
11873}
11874
11875impl SessionAudioConsumerFactoryProxy {
11876    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
11877    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11878        let protocol_name =
11879            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11880        Self { client: fidl::client::Client::new(channel, protocol_name) }
11881    }
11882
11883    /// Get a Stream of events from the remote end of the protocol.
11884    ///
11885    /// # Panics
11886    ///
11887    /// Panics if the event stream was already taken.
11888    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
11889        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
11890    }
11891
11892    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11893    /// to a particular session. `session_id` is the identifier of the media session
11894    /// for which audio is to be rendered.
11895    pub fn r#create_audio_consumer(
11896        &self,
11897        mut session_id: u64,
11898        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11899    ) -> Result<(), fidl::Error> {
11900        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
11901            self,
11902            session_id,
11903            audio_consumer_request,
11904        )
11905    }
11906}
11907
11908impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
11909    fn r#create_audio_consumer(
11910        &self,
11911        mut session_id: u64,
11912        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11913    ) -> Result<(), fidl::Error> {
11914        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11915            (session_id, audio_consumer_request),
11916            0x6fab96f988e7d7fb,
11917            fidl::encoding::DynamicFlags::empty(),
11918        )
11919    }
11920}
11921
11922pub struct SessionAudioConsumerFactoryEventStream {
11923    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11924}
11925
11926impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
11927
11928impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
11929    fn is_terminated(&self) -> bool {
11930        self.event_receiver.is_terminated()
11931    }
11932}
11933
11934impl futures::Stream for SessionAudioConsumerFactoryEventStream {
11935    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
11936
11937    fn poll_next(
11938        mut self: std::pin::Pin<&mut Self>,
11939        cx: &mut std::task::Context<'_>,
11940    ) -> std::task::Poll<Option<Self::Item>> {
11941        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11942            &mut self.event_receiver,
11943            cx
11944        )?) {
11945            Some(buf) => {
11946                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
11947            }
11948            None => std::task::Poll::Ready(None),
11949        }
11950    }
11951}
11952
11953#[derive(Debug)]
11954pub enum SessionAudioConsumerFactoryEvent {}
11955
11956impl SessionAudioConsumerFactoryEvent {
11957    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
11958    fn decode(
11959        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11960    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11961        let (bytes, _handles) = buf.split_mut();
11962        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11963        debug_assert_eq!(tx_header.tx_id, 0);
11964        match tx_header.ordinal {
11965            _ => Err(fidl::Error::UnknownOrdinal {
11966                ordinal: tx_header.ordinal,
11967                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11968            })
11969        }
11970    }
11971}
11972
11973/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
11974pub struct SessionAudioConsumerFactoryRequestStream {
11975    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11976    is_terminated: bool,
11977}
11978
11979impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
11980
11981impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
11982    fn is_terminated(&self) -> bool {
11983        self.is_terminated
11984    }
11985}
11986
11987impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
11988    type Protocol = SessionAudioConsumerFactoryMarker;
11989    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
11990
11991    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11992        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11993    }
11994
11995    fn control_handle(&self) -> Self::ControlHandle {
11996        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
11997    }
11998
11999    fn into_inner(
12000        self,
12001    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12002    {
12003        (self.inner, self.is_terminated)
12004    }
12005
12006    fn from_inner(
12007        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12008        is_terminated: bool,
12009    ) -> Self {
12010        Self { inner, is_terminated }
12011    }
12012}
12013
12014impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12015    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12016
12017    fn poll_next(
12018        mut self: std::pin::Pin<&mut Self>,
12019        cx: &mut std::task::Context<'_>,
12020    ) -> std::task::Poll<Option<Self::Item>> {
12021        let this = &mut *self;
12022        if this.inner.check_shutdown(cx) {
12023            this.is_terminated = true;
12024            return std::task::Poll::Ready(None);
12025        }
12026        if this.is_terminated {
12027            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12028        }
12029        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12030            |bytes, handles| {
12031                match this.inner.channel().read_etc(cx, bytes, handles) {
12032                    std::task::Poll::Ready(Ok(())) => {}
12033                    std::task::Poll::Pending => return std::task::Poll::Pending,
12034                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12035                        this.is_terminated = true;
12036                        return std::task::Poll::Ready(None);
12037                    }
12038                    std::task::Poll::Ready(Err(e)) => {
12039                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12040                            e.into(),
12041                        ))));
12042                    }
12043                }
12044
12045                // A message has been received from the channel
12046                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12047
12048                std::task::Poll::Ready(Some(match header.ordinal {
12049                0x6fab96f988e7d7fb => {
12050                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12051                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12052                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12053                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12054                        inner: this.inner.clone(),
12055                    };
12056                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12057audio_consumer_request: req.audio_consumer_request,
12058
12059                        control_handle,
12060                    })
12061                }
12062                _ => Err(fidl::Error::UnknownOrdinal {
12063                    ordinal: header.ordinal,
12064                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12065                }),
12066            }))
12067            },
12068        )
12069    }
12070}
12071
12072/// Interface for creating audio consumers bound to a session.
12073#[derive(Debug)]
12074pub enum SessionAudioConsumerFactoryRequest {
12075    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12076    /// to a particular session. `session_id` is the identifier of the media session
12077    /// for which audio is to be rendered.
12078    CreateAudioConsumer {
12079        session_id: u64,
12080        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12081        control_handle: SessionAudioConsumerFactoryControlHandle,
12082    },
12083}
12084
12085impl SessionAudioConsumerFactoryRequest {
12086    #[allow(irrefutable_let_patterns)]
12087    pub fn into_create_audio_consumer(
12088        self,
12089    ) -> Option<(
12090        u64,
12091        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12092        SessionAudioConsumerFactoryControlHandle,
12093    )> {
12094        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12095            session_id,
12096            audio_consumer_request,
12097            control_handle,
12098        } = self
12099        {
12100            Some((session_id, audio_consumer_request, control_handle))
12101        } else {
12102            None
12103        }
12104    }
12105
12106    /// Name of the method defined in FIDL
12107    pub fn method_name(&self) -> &'static str {
12108        match *self {
12109            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12110                "create_audio_consumer"
12111            }
12112        }
12113    }
12114}
12115
12116#[derive(Debug, Clone)]
12117pub struct SessionAudioConsumerFactoryControlHandle {
12118    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12119}
12120
12121impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12122    fn shutdown(&self) {
12123        self.inner.shutdown()
12124    }
12125    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12126        self.inner.shutdown_with_epitaph(status)
12127    }
12128
12129    fn is_closed(&self) -> bool {
12130        self.inner.channel().is_closed()
12131    }
12132    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12133        self.inner.channel().on_closed()
12134    }
12135
12136    #[cfg(target_os = "fuchsia")]
12137    fn signal_peer(
12138        &self,
12139        clear_mask: zx::Signals,
12140        set_mask: zx::Signals,
12141    ) -> Result<(), zx_status::Status> {
12142        use fidl::Peered;
12143        self.inner.channel().signal_peer(clear_mask, set_mask)
12144    }
12145}
12146
12147impl SessionAudioConsumerFactoryControlHandle {}
12148
12149#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12150pub struct SimpleStreamSinkMarker;
12151
12152impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12153    type Proxy = SimpleStreamSinkProxy;
12154    type RequestStream = SimpleStreamSinkRequestStream;
12155    #[cfg(target_os = "fuchsia")]
12156    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12157
12158    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12159}
12160
12161pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12162    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12163    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12164    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12165    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12166    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12167    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12168    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12169    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12170    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12171}
12172#[derive(Debug)]
12173#[cfg(target_os = "fuchsia")]
12174pub struct SimpleStreamSinkSynchronousProxy {
12175    client: fidl::client::sync::Client,
12176}
12177
12178#[cfg(target_os = "fuchsia")]
12179impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12180    type Proxy = SimpleStreamSinkProxy;
12181    type Protocol = SimpleStreamSinkMarker;
12182
12183    fn from_channel(inner: fidl::Channel) -> Self {
12184        Self::new(inner)
12185    }
12186
12187    fn into_channel(self) -> fidl::Channel {
12188        self.client.into_channel()
12189    }
12190
12191    fn as_channel(&self) -> &fidl::Channel {
12192        self.client.as_channel()
12193    }
12194}
12195
12196#[cfg(target_os = "fuchsia")]
12197impl SimpleStreamSinkSynchronousProxy {
12198    pub fn new(channel: fidl::Channel) -> Self {
12199        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12200        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
12201    }
12202
12203    pub fn into_channel(self) -> fidl::Channel {
12204        self.client.into_channel()
12205    }
12206
12207    /// Waits until an event arrives and returns it. It is safe for other
12208    /// threads to make concurrent requests while waiting for an event.
12209    pub fn wait_for_event(
12210        &self,
12211        deadline: zx::MonotonicInstant,
12212    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12213        SimpleStreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
12214    }
12215
12216    /// Adds a payload buffer to the current buffer set associated with the
12217    /// connection. A `StreamPacket` struct reference a payload buffer in the
12218    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12219    ///
12220    /// A buffer with ID `id` must not be in the current set when this method is
12221    /// invoked, otherwise the service will close the connection.
12222    pub fn r#add_payload_buffer(
12223        &self,
12224        mut id: u32,
12225        mut payload_buffer: fidl::Vmo,
12226    ) -> Result<(), fidl::Error> {
12227        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12228            (id, payload_buffer),
12229            0x3b3a37fc34fe5b56,
12230            fidl::encoding::DynamicFlags::empty(),
12231        )
12232    }
12233
12234    /// Removes a payload buffer from the current buffer set associated with the
12235    /// connection.
12236    ///
12237    /// A buffer with ID `id` must exist in the current set when this method is
12238    /// invoked, otherwise the service will will close the connection.
12239    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12240        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12241            (id,),
12242            0x5d1e4f74c3658262,
12243            fidl::encoding::DynamicFlags::empty(),
12244        )
12245    }
12246
12247    /// Sends a packet to the service. The response is sent when the service is
12248    /// done with the associated payload memory.
12249    ///
12250    /// `packet` must be valid for the current buffer set, otherwise the service
12251    /// will close the connection.
12252    pub fn r#send_packet(
12253        &self,
12254        mut packet: &StreamPacket,
12255        ___deadline: zx::MonotonicInstant,
12256    ) -> Result<(), fidl::Error> {
12257        let _response =
12258            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
12259                (packet,),
12260                0x67cddd607442775f,
12261                fidl::encoding::DynamicFlags::empty(),
12262                ___deadline,
12263            )?;
12264        Ok(_response)
12265    }
12266
12267    /// Sends a packet to the service. This interface doesn't define how the
12268    /// client knows when the sink is done with the associated payload memory.
12269    /// The inheriting interface must define that.
12270    ///
12271    /// `packet` must be valid for the current buffer set, otherwise the service
12272    /// will close the connection.
12273    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12274        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12275            (packet,),
12276            0x8d9b8b413ceba9d,
12277            fidl::encoding::DynamicFlags::empty(),
12278        )
12279    }
12280
12281    /// Indicates the stream has ended. The precise semantics of this method are
12282    /// determined by the inheriting interface.
12283    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12284        self.client.send::<fidl::encoding::EmptyPayload>(
12285            (),
12286            0x6180fd6f7e793b71,
12287            fidl::encoding::DynamicFlags::empty(),
12288        )
12289    }
12290
12291    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12292    /// and not yet released. The response is sent after all packets have been
12293    /// released.
12294    pub fn r#discard_all_packets(
12295        &self,
12296        ___deadline: zx::MonotonicInstant,
12297    ) -> Result<(), fidl::Error> {
12298        let _response =
12299            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
12300                (),
12301                0x6f4dad7af2917665,
12302                fidl::encoding::DynamicFlags::empty(),
12303                ___deadline,
12304            )?;
12305        Ok(_response)
12306    }
12307
12308    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12309    /// and not yet released.
12310    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12311        self.client.send::<fidl::encoding::EmptyPayload>(
12312            (),
12313            0x50d36d0d23081bc4,
12314            fidl::encoding::DynamicFlags::empty(),
12315        )
12316    }
12317}
12318
12319#[cfg(target_os = "fuchsia")]
12320impl From<SimpleStreamSinkSynchronousProxy> for zx::Handle {
12321    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12322        value.into_channel().into()
12323    }
12324}
12325
12326#[cfg(target_os = "fuchsia")]
12327impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12328    fn from(value: fidl::Channel) -> Self {
12329        Self::new(value)
12330    }
12331}
12332
12333#[cfg(target_os = "fuchsia")]
12334impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12335    type Protocol = SimpleStreamSinkMarker;
12336
12337    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12338        Self::new(value.into_channel())
12339    }
12340}
12341
12342#[derive(Debug, Clone)]
12343pub struct SimpleStreamSinkProxy {
12344    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12345}
12346
12347impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12348    type Protocol = SimpleStreamSinkMarker;
12349
12350    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12351        Self::new(inner)
12352    }
12353
12354    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12355        self.client.into_channel().map_err(|client| Self { client })
12356    }
12357
12358    fn as_channel(&self) -> &::fidl::AsyncChannel {
12359        self.client.as_channel()
12360    }
12361}
12362
12363impl SimpleStreamSinkProxy {
12364    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12365    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12366        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12367        Self { client: fidl::client::Client::new(channel, protocol_name) }
12368    }
12369
12370    /// Get a Stream of events from the remote end of the protocol.
12371    ///
12372    /// # Panics
12373    ///
12374    /// Panics if the event stream was already taken.
12375    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12376        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12377    }
12378
12379    /// Adds a payload buffer to the current buffer set associated with the
12380    /// connection. A `StreamPacket` struct reference a payload buffer in the
12381    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12382    ///
12383    /// A buffer with ID `id` must not be in the current set when this method is
12384    /// invoked, otherwise the service will close the connection.
12385    pub fn r#add_payload_buffer(
12386        &self,
12387        mut id: u32,
12388        mut payload_buffer: fidl::Vmo,
12389    ) -> Result<(), fidl::Error> {
12390        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12391    }
12392
12393    /// Removes a payload buffer from the current buffer set associated with the
12394    /// connection.
12395    ///
12396    /// A buffer with ID `id` must exist in the current set when this method is
12397    /// invoked, otherwise the service will will close the connection.
12398    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12399        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12400    }
12401
12402    /// Sends a packet to the service. The response is sent when the service is
12403    /// done with the associated payload memory.
12404    ///
12405    /// `packet` must be valid for the current buffer set, otherwise the service
12406    /// will close the connection.
12407    pub fn r#send_packet(
12408        &self,
12409        mut packet: &StreamPacket,
12410    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12411        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12412    }
12413
12414    /// Sends a packet to the service. This interface doesn't define how the
12415    /// client knows when the sink is done with the associated payload memory.
12416    /// The inheriting interface must define that.
12417    ///
12418    /// `packet` must be valid for the current buffer set, otherwise the service
12419    /// will close the connection.
12420    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12421        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12422    }
12423
12424    /// Indicates the stream has ended. The precise semantics of this method are
12425    /// determined by the inheriting interface.
12426    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12427        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12428    }
12429
12430    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12431    /// and not yet released. The response is sent after all packets have been
12432    /// released.
12433    pub fn r#discard_all_packets(
12434        &self,
12435    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12436        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12437    }
12438
12439    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12440    /// and not yet released.
12441    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12442        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12443    }
12444}
12445
12446impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12447    fn r#add_payload_buffer(
12448        &self,
12449        mut id: u32,
12450        mut payload_buffer: fidl::Vmo,
12451    ) -> Result<(), fidl::Error> {
12452        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12453            (id, payload_buffer),
12454            0x3b3a37fc34fe5b56,
12455            fidl::encoding::DynamicFlags::empty(),
12456        )
12457    }
12458
12459    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12460        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12461            (id,),
12462            0x5d1e4f74c3658262,
12463            fidl::encoding::DynamicFlags::empty(),
12464        )
12465    }
12466
12467    type SendPacketResponseFut =
12468        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12469    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12470        fn _decode(
12471            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12472        ) -> Result<(), fidl::Error> {
12473            let _response = fidl::client::decode_transaction_body::<
12474                fidl::encoding::EmptyPayload,
12475                fidl::encoding::DefaultFuchsiaResourceDialect,
12476                0x67cddd607442775f,
12477            >(_buf?)?;
12478            Ok(_response)
12479        }
12480        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12481            (packet,),
12482            0x67cddd607442775f,
12483            fidl::encoding::DynamicFlags::empty(),
12484            _decode,
12485        )
12486    }
12487
12488    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12489        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12490            (packet,),
12491            0x8d9b8b413ceba9d,
12492            fidl::encoding::DynamicFlags::empty(),
12493        )
12494    }
12495
12496    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12497        self.client.send::<fidl::encoding::EmptyPayload>(
12498            (),
12499            0x6180fd6f7e793b71,
12500            fidl::encoding::DynamicFlags::empty(),
12501        )
12502    }
12503
12504    type DiscardAllPacketsResponseFut =
12505        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12506    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12507        fn _decode(
12508            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12509        ) -> Result<(), fidl::Error> {
12510            let _response = fidl::client::decode_transaction_body::<
12511                fidl::encoding::EmptyPayload,
12512                fidl::encoding::DefaultFuchsiaResourceDialect,
12513                0x6f4dad7af2917665,
12514            >(_buf?)?;
12515            Ok(_response)
12516        }
12517        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12518            (),
12519            0x6f4dad7af2917665,
12520            fidl::encoding::DynamicFlags::empty(),
12521            _decode,
12522        )
12523    }
12524
12525    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12526        self.client.send::<fidl::encoding::EmptyPayload>(
12527            (),
12528            0x50d36d0d23081bc4,
12529            fidl::encoding::DynamicFlags::empty(),
12530        )
12531    }
12532}
12533
12534pub struct SimpleStreamSinkEventStream {
12535    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12536}
12537
12538impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12539
12540impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12541    fn is_terminated(&self) -> bool {
12542        self.event_receiver.is_terminated()
12543    }
12544}
12545
12546impl futures::Stream for SimpleStreamSinkEventStream {
12547    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12548
12549    fn poll_next(
12550        mut self: std::pin::Pin<&mut Self>,
12551        cx: &mut std::task::Context<'_>,
12552    ) -> std::task::Poll<Option<Self::Item>> {
12553        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12554            &mut self.event_receiver,
12555            cx
12556        )?) {
12557            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12558            None => std::task::Poll::Ready(None),
12559        }
12560    }
12561}
12562
12563#[derive(Debug)]
12564pub enum SimpleStreamSinkEvent {}
12565
12566impl SimpleStreamSinkEvent {
12567    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12568    fn decode(
12569        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12570    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12571        let (bytes, _handles) = buf.split_mut();
12572        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12573        debug_assert_eq!(tx_header.tx_id, 0);
12574        match tx_header.ordinal {
12575            _ => Err(fidl::Error::UnknownOrdinal {
12576                ordinal: tx_header.ordinal,
12577                protocol_name:
12578                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12579            }),
12580        }
12581    }
12582}
12583
12584/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12585pub struct SimpleStreamSinkRequestStream {
12586    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12587    is_terminated: bool,
12588}
12589
12590impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12591
12592impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12593    fn is_terminated(&self) -> bool {
12594        self.is_terminated
12595    }
12596}
12597
12598impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12599    type Protocol = SimpleStreamSinkMarker;
12600    type ControlHandle = SimpleStreamSinkControlHandle;
12601
12602    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12603        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12604    }
12605
12606    fn control_handle(&self) -> Self::ControlHandle {
12607        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12608    }
12609
12610    fn into_inner(
12611        self,
12612    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12613    {
12614        (self.inner, self.is_terminated)
12615    }
12616
12617    fn from_inner(
12618        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12619        is_terminated: bool,
12620    ) -> Self {
12621        Self { inner, is_terminated }
12622    }
12623}
12624
12625impl futures::Stream for SimpleStreamSinkRequestStream {
12626    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
12627
12628    fn poll_next(
12629        mut self: std::pin::Pin<&mut Self>,
12630        cx: &mut std::task::Context<'_>,
12631    ) -> std::task::Poll<Option<Self::Item>> {
12632        let this = &mut *self;
12633        if this.inner.check_shutdown(cx) {
12634            this.is_terminated = true;
12635            return std::task::Poll::Ready(None);
12636        }
12637        if this.is_terminated {
12638            panic!("polled SimpleStreamSinkRequestStream after completion");
12639        }
12640        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12641            |bytes, handles| {
12642                match this.inner.channel().read_etc(cx, bytes, handles) {
12643                    std::task::Poll::Ready(Ok(())) => {}
12644                    std::task::Poll::Pending => return std::task::Poll::Pending,
12645                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12646                        this.is_terminated = true;
12647                        return std::task::Poll::Ready(None);
12648                    }
12649                    std::task::Poll::Ready(Err(e)) => {
12650                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12651                            e.into(),
12652                        ))));
12653                    }
12654                }
12655
12656                // A message has been received from the channel
12657                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12658
12659                std::task::Poll::Ready(Some(match header.ordinal {
12660                    0x3b3a37fc34fe5b56 => {
12661                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12662                        let mut req = fidl::new_empty!(
12663                            StreamBufferSetAddPayloadBufferRequest,
12664                            fidl::encoding::DefaultFuchsiaResourceDialect
12665                        );
12666                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12667                        let control_handle =
12668                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12669                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
12670                            id: req.id,
12671                            payload_buffer: req.payload_buffer,
12672
12673                            control_handle,
12674                        })
12675                    }
12676                    0x5d1e4f74c3658262 => {
12677                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12678                        let mut req = fidl::new_empty!(
12679                            StreamBufferSetRemovePayloadBufferRequest,
12680                            fidl::encoding::DefaultFuchsiaResourceDialect
12681                        );
12682                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12683                        let control_handle =
12684                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12685                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
12686                            id: req.id,
12687
12688                            control_handle,
12689                        })
12690                    }
12691                    0x67cddd607442775f => {
12692                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12693                        let mut req = fidl::new_empty!(
12694                            StreamSinkSendPacketRequest,
12695                            fidl::encoding::DefaultFuchsiaResourceDialect
12696                        );
12697                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12698                        let control_handle =
12699                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12700                        Ok(SimpleStreamSinkRequest::SendPacket {
12701                            packet: req.packet,
12702
12703                            responder: SimpleStreamSinkSendPacketResponder {
12704                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12705                                tx_id: header.tx_id,
12706                            },
12707                        })
12708                    }
12709                    0x8d9b8b413ceba9d => {
12710                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12711                        let mut req = fidl::new_empty!(
12712                            StreamSinkSendPacketNoReplyRequest,
12713                            fidl::encoding::DefaultFuchsiaResourceDialect
12714                        );
12715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
12716                        let control_handle =
12717                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12718                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
12719                            packet: req.packet,
12720
12721                            control_handle,
12722                        })
12723                    }
12724                    0x6180fd6f7e793b71 => {
12725                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12726                        let mut req = fidl::new_empty!(
12727                            fidl::encoding::EmptyPayload,
12728                            fidl::encoding::DefaultFuchsiaResourceDialect
12729                        );
12730                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12731                        let control_handle =
12732                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12733                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
12734                    }
12735                    0x6f4dad7af2917665 => {
12736                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12737                        let mut req = fidl::new_empty!(
12738                            fidl::encoding::EmptyPayload,
12739                            fidl::encoding::DefaultFuchsiaResourceDialect
12740                        );
12741                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12742                        let control_handle =
12743                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12744                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
12745                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
12746                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12747                                tx_id: header.tx_id,
12748                            },
12749                        })
12750                    }
12751                    0x50d36d0d23081bc4 => {
12752                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12753                        let mut req = fidl::new_empty!(
12754                            fidl::encoding::EmptyPayload,
12755                            fidl::encoding::DefaultFuchsiaResourceDialect
12756                        );
12757                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12758                        let control_handle =
12759                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12760                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
12761                    }
12762                    _ => Err(fidl::Error::UnknownOrdinal {
12763                        ordinal: header.ordinal,
12764                        protocol_name:
12765                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12766                    }),
12767                }))
12768            },
12769        )
12770    }
12771}
12772
12773/// A StreamSink that uses StreamBufferSet for buffer management.
12774#[derive(Debug)]
12775pub enum SimpleStreamSinkRequest {
12776    /// Adds a payload buffer to the current buffer set associated with the
12777    /// connection. A `StreamPacket` struct reference a payload buffer in the
12778    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12779    ///
12780    /// A buffer with ID `id` must not be in the current set when this method is
12781    /// invoked, otherwise the service will close the connection.
12782    AddPayloadBuffer {
12783        id: u32,
12784        payload_buffer: fidl::Vmo,
12785        control_handle: SimpleStreamSinkControlHandle,
12786    },
12787    /// Removes a payload buffer from the current buffer set associated with the
12788    /// connection.
12789    ///
12790    /// A buffer with ID `id` must exist in the current set when this method is
12791    /// invoked, otherwise the service will will close the connection.
12792    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
12793    /// Sends a packet to the service. The response is sent when the service is
12794    /// done with the associated payload memory.
12795    ///
12796    /// `packet` must be valid for the current buffer set, otherwise the service
12797    /// will close the connection.
12798    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
12799    /// Sends a packet to the service. This interface doesn't define how the
12800    /// client knows when the sink is done with the associated payload memory.
12801    /// The inheriting interface must define that.
12802    ///
12803    /// `packet` must be valid for the current buffer set, otherwise the service
12804    /// will close the connection.
12805    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
12806    /// Indicates the stream has ended. The precise semantics of this method are
12807    /// determined by the inheriting interface.
12808    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
12809    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12810    /// and not yet released. The response is sent after all packets have been
12811    /// released.
12812    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
12813    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12814    /// and not yet released.
12815    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
12816}
12817
12818impl SimpleStreamSinkRequest {
12819    #[allow(irrefutable_let_patterns)]
12820    pub fn into_add_payload_buffer(
12821        self,
12822    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
12823        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
12824            self
12825        {
12826            Some((id, payload_buffer, control_handle))
12827        } else {
12828            None
12829        }
12830    }
12831
12832    #[allow(irrefutable_let_patterns)]
12833    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
12834        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
12835            Some((id, control_handle))
12836        } else {
12837            None
12838        }
12839    }
12840
12841    #[allow(irrefutable_let_patterns)]
12842    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
12843        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
12844            Some((packet, responder))
12845        } else {
12846            None
12847        }
12848    }
12849
12850    #[allow(irrefutable_let_patterns)]
12851    pub fn into_send_packet_no_reply(
12852        self,
12853    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
12854        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
12855            Some((packet, control_handle))
12856        } else {
12857            None
12858        }
12859    }
12860
12861    #[allow(irrefutable_let_patterns)]
12862    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
12863        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
12864            Some((control_handle))
12865        } else {
12866            None
12867        }
12868    }
12869
12870    #[allow(irrefutable_let_patterns)]
12871    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
12872        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
12873            Some((responder))
12874        } else {
12875            None
12876        }
12877    }
12878
12879    #[allow(irrefutable_let_patterns)]
12880    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
12881        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
12882            Some((control_handle))
12883        } else {
12884            None
12885        }
12886    }
12887
12888    /// Name of the method defined in FIDL
12889    pub fn method_name(&self) -> &'static str {
12890        match *self {
12891            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
12892            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
12893            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
12894            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
12895            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
12896            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
12897            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
12898                "discard_all_packets_no_reply"
12899            }
12900        }
12901    }
12902}
12903
12904#[derive(Debug, Clone)]
12905pub struct SimpleStreamSinkControlHandle {
12906    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12907}
12908
12909impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
12910    fn shutdown(&self) {
12911        self.inner.shutdown()
12912    }
12913    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12914        self.inner.shutdown_with_epitaph(status)
12915    }
12916
12917    fn is_closed(&self) -> bool {
12918        self.inner.channel().is_closed()
12919    }
12920    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12921        self.inner.channel().on_closed()
12922    }
12923
12924    #[cfg(target_os = "fuchsia")]
12925    fn signal_peer(
12926        &self,
12927        clear_mask: zx::Signals,
12928        set_mask: zx::Signals,
12929    ) -> Result<(), zx_status::Status> {
12930        use fidl::Peered;
12931        self.inner.channel().signal_peer(clear_mask, set_mask)
12932    }
12933}
12934
12935impl SimpleStreamSinkControlHandle {}
12936
12937#[must_use = "FIDL methods require a response to be sent"]
12938#[derive(Debug)]
12939pub struct SimpleStreamSinkSendPacketResponder {
12940    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
12941    tx_id: u32,
12942}
12943
12944/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
12945/// if the responder is dropped without sending a response, so that the client
12946/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12947impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
12948    fn drop(&mut self) {
12949        self.control_handle.shutdown();
12950        // Safety: drops once, never accessed again
12951        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12952    }
12953}
12954
12955impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
12956    type ControlHandle = SimpleStreamSinkControlHandle;
12957
12958    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
12959        &self.control_handle
12960    }
12961
12962    fn drop_without_shutdown(mut self) {
12963        // Safety: drops once, never accessed again due to mem::forget
12964        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12965        // Prevent Drop from running (which would shut down the channel)
12966        std::mem::forget(self);
12967    }
12968}
12969
12970impl SimpleStreamSinkSendPacketResponder {
12971    /// Sends a response to the FIDL transaction.
12972    ///
12973    /// Sets the channel to shutdown if an error occurs.
12974    pub fn send(self) -> Result<(), fidl::Error> {
12975        let _result = self.send_raw();
12976        if _result.is_err() {
12977            self.control_handle.shutdown();
12978        }
12979        self.drop_without_shutdown();
12980        _result
12981    }
12982
12983    /// Similar to "send" but does not shutdown the channel if an error occurs.
12984    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12985        let _result = self.send_raw();
12986        self.drop_without_shutdown();
12987        _result
12988    }
12989
12990    fn send_raw(&self) -> Result<(), fidl::Error> {
12991        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12992            (),
12993            self.tx_id,
12994            0x67cddd607442775f,
12995            fidl::encoding::DynamicFlags::empty(),
12996        )
12997    }
12998}
12999
13000#[must_use = "FIDL methods require a response to be sent"]
13001#[derive(Debug)]
13002pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13003    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13004    tx_id: u32,
13005}
13006
13007/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13008/// if the responder is dropped without sending a response, so that the client
13009/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13010impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13011    fn drop(&mut self) {
13012        self.control_handle.shutdown();
13013        // Safety: drops once, never accessed again
13014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13015    }
13016}
13017
13018impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13019    type ControlHandle = SimpleStreamSinkControlHandle;
13020
13021    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13022        &self.control_handle
13023    }
13024
13025    fn drop_without_shutdown(mut self) {
13026        // Safety: drops once, never accessed again due to mem::forget
13027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13028        // Prevent Drop from running (which would shut down the channel)
13029        std::mem::forget(self);
13030    }
13031}
13032
13033impl SimpleStreamSinkDiscardAllPacketsResponder {
13034    /// Sends a response to the FIDL transaction.
13035    ///
13036    /// Sets the channel to shutdown if an error occurs.
13037    pub fn send(self) -> Result<(), fidl::Error> {
13038        let _result = self.send_raw();
13039        if _result.is_err() {
13040            self.control_handle.shutdown();
13041        }
13042        self.drop_without_shutdown();
13043        _result
13044    }
13045
13046    /// Similar to "send" but does not shutdown the channel if an error occurs.
13047    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13048        let _result = self.send_raw();
13049        self.drop_without_shutdown();
13050        _result
13051    }
13052
13053    fn send_raw(&self) -> Result<(), fidl::Error> {
13054        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13055            (),
13056            self.tx_id,
13057            0x6f4dad7af2917665,
13058            fidl::encoding::DynamicFlags::empty(),
13059        )
13060    }
13061}
13062
13063#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13064pub struct StreamBufferSetMarker;
13065
13066impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13067    type Proxy = StreamBufferSetProxy;
13068    type RequestStream = StreamBufferSetRequestStream;
13069    #[cfg(target_os = "fuchsia")]
13070    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13071
13072    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13073}
13074
13075pub trait StreamBufferSetProxyInterface: Send + Sync {
13076    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13077    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13078}
13079#[derive(Debug)]
13080#[cfg(target_os = "fuchsia")]
13081pub struct StreamBufferSetSynchronousProxy {
13082    client: fidl::client::sync::Client,
13083}
13084
13085#[cfg(target_os = "fuchsia")]
13086impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13087    type Proxy = StreamBufferSetProxy;
13088    type Protocol = StreamBufferSetMarker;
13089
13090    fn from_channel(inner: fidl::Channel) -> Self {
13091        Self::new(inner)
13092    }
13093
13094    fn into_channel(self) -> fidl::Channel {
13095        self.client.into_channel()
13096    }
13097
13098    fn as_channel(&self) -> &fidl::Channel {
13099        self.client.as_channel()
13100    }
13101}
13102
13103#[cfg(target_os = "fuchsia")]
13104impl StreamBufferSetSynchronousProxy {
13105    pub fn new(channel: fidl::Channel) -> Self {
13106        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13107        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13108    }
13109
13110    pub fn into_channel(self) -> fidl::Channel {
13111        self.client.into_channel()
13112    }
13113
13114    /// Waits until an event arrives and returns it. It is safe for other
13115    /// threads to make concurrent requests while waiting for an event.
13116    pub fn wait_for_event(
13117        &self,
13118        deadline: zx::MonotonicInstant,
13119    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13120        StreamBufferSetEvent::decode(self.client.wait_for_event(deadline)?)
13121    }
13122
13123    /// Adds a payload buffer to the current buffer set associated with the
13124    /// connection. A `StreamPacket` struct reference a payload buffer in the
13125    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13126    ///
13127    /// A buffer with ID `id` must not be in the current set when this method is
13128    /// invoked, otherwise the service will close the connection.
13129    pub fn r#add_payload_buffer(
13130        &self,
13131        mut id: u32,
13132        mut payload_buffer: fidl::Vmo,
13133    ) -> Result<(), fidl::Error> {
13134        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13135            (id, payload_buffer),
13136            0x3b3a37fc34fe5b56,
13137            fidl::encoding::DynamicFlags::empty(),
13138        )
13139    }
13140
13141    /// Removes a payload buffer from the current buffer set associated with the
13142    /// connection.
13143    ///
13144    /// A buffer with ID `id` must exist in the current set when this method is
13145    /// invoked, otherwise the service will will close the connection.
13146    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13147        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13148            (id,),
13149            0x5d1e4f74c3658262,
13150            fidl::encoding::DynamicFlags::empty(),
13151        )
13152    }
13153}
13154
13155#[cfg(target_os = "fuchsia")]
13156impl From<StreamBufferSetSynchronousProxy> for zx::Handle {
13157    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13158        value.into_channel().into()
13159    }
13160}
13161
13162#[cfg(target_os = "fuchsia")]
13163impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13164    fn from(value: fidl::Channel) -> Self {
13165        Self::new(value)
13166    }
13167}
13168
13169#[cfg(target_os = "fuchsia")]
13170impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13171    type Protocol = StreamBufferSetMarker;
13172
13173    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13174        Self::new(value.into_channel())
13175    }
13176}
13177
13178#[derive(Debug, Clone)]
13179pub struct StreamBufferSetProxy {
13180    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13181}
13182
13183impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13184    type Protocol = StreamBufferSetMarker;
13185
13186    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13187        Self::new(inner)
13188    }
13189
13190    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13191        self.client.into_channel().map_err(|client| Self { client })
13192    }
13193
13194    fn as_channel(&self) -> &::fidl::AsyncChannel {
13195        self.client.as_channel()
13196    }
13197}
13198
13199impl StreamBufferSetProxy {
13200    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13201    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13202        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13203        Self { client: fidl::client::Client::new(channel, protocol_name) }
13204    }
13205
13206    /// Get a Stream of events from the remote end of the protocol.
13207    ///
13208    /// # Panics
13209    ///
13210    /// Panics if the event stream was already taken.
13211    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13212        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13213    }
13214
13215    /// Adds a payload buffer to the current buffer set associated with the
13216    /// connection. A `StreamPacket` struct reference a payload buffer in the
13217    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13218    ///
13219    /// A buffer with ID `id` must not be in the current set when this method is
13220    /// invoked, otherwise the service will close the connection.
13221    pub fn r#add_payload_buffer(
13222        &self,
13223        mut id: u32,
13224        mut payload_buffer: fidl::Vmo,
13225    ) -> Result<(), fidl::Error> {
13226        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13227    }
13228
13229    /// Removes a payload buffer from the current buffer set associated with the
13230    /// connection.
13231    ///
13232    /// A buffer with ID `id` must exist in the current set when this method is
13233    /// invoked, otherwise the service will will close the connection.
13234    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13235        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13236    }
13237}
13238
13239impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13240    fn r#add_payload_buffer(
13241        &self,
13242        mut id: u32,
13243        mut payload_buffer: fidl::Vmo,
13244    ) -> Result<(), fidl::Error> {
13245        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13246            (id, payload_buffer),
13247            0x3b3a37fc34fe5b56,
13248            fidl::encoding::DynamicFlags::empty(),
13249        )
13250    }
13251
13252    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13253        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13254            (id,),
13255            0x5d1e4f74c3658262,
13256            fidl::encoding::DynamicFlags::empty(),
13257        )
13258    }
13259}
13260
13261pub struct StreamBufferSetEventStream {
13262    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13263}
13264
13265impl std::marker::Unpin for StreamBufferSetEventStream {}
13266
13267impl futures::stream::FusedStream for StreamBufferSetEventStream {
13268    fn is_terminated(&self) -> bool {
13269        self.event_receiver.is_terminated()
13270    }
13271}
13272
13273impl futures::Stream for StreamBufferSetEventStream {
13274    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13275
13276    fn poll_next(
13277        mut self: std::pin::Pin<&mut Self>,
13278        cx: &mut std::task::Context<'_>,
13279    ) -> std::task::Poll<Option<Self::Item>> {
13280        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13281            &mut self.event_receiver,
13282            cx
13283        )?) {
13284            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13285            None => std::task::Poll::Ready(None),
13286        }
13287    }
13288}
13289
13290#[derive(Debug)]
13291pub enum StreamBufferSetEvent {}
13292
13293impl StreamBufferSetEvent {
13294    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13295    fn decode(
13296        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13297    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13298        let (bytes, _handles) = buf.split_mut();
13299        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13300        debug_assert_eq!(tx_header.tx_id, 0);
13301        match tx_header.ordinal {
13302            _ => Err(fidl::Error::UnknownOrdinal {
13303                ordinal: tx_header.ordinal,
13304                protocol_name:
13305                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13306            }),
13307        }
13308    }
13309}
13310
13311/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13312pub struct StreamBufferSetRequestStream {
13313    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13314    is_terminated: bool,
13315}
13316
13317impl std::marker::Unpin for StreamBufferSetRequestStream {}
13318
13319impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13320    fn is_terminated(&self) -> bool {
13321        self.is_terminated
13322    }
13323}
13324
13325impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13326    type Protocol = StreamBufferSetMarker;
13327    type ControlHandle = StreamBufferSetControlHandle;
13328
13329    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13330        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13331    }
13332
13333    fn control_handle(&self) -> Self::ControlHandle {
13334        StreamBufferSetControlHandle { inner: self.inner.clone() }
13335    }
13336
13337    fn into_inner(
13338        self,
13339    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13340    {
13341        (self.inner, self.is_terminated)
13342    }
13343
13344    fn from_inner(
13345        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13346        is_terminated: bool,
13347    ) -> Self {
13348        Self { inner, is_terminated }
13349    }
13350}
13351
13352impl futures::Stream for StreamBufferSetRequestStream {
13353    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13354
13355    fn poll_next(
13356        mut self: std::pin::Pin<&mut Self>,
13357        cx: &mut std::task::Context<'_>,
13358    ) -> std::task::Poll<Option<Self::Item>> {
13359        let this = &mut *self;
13360        if this.inner.check_shutdown(cx) {
13361            this.is_terminated = true;
13362            return std::task::Poll::Ready(None);
13363        }
13364        if this.is_terminated {
13365            panic!("polled StreamBufferSetRequestStream after completion");
13366        }
13367        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13368            |bytes, handles| {
13369                match this.inner.channel().read_etc(cx, bytes, handles) {
13370                    std::task::Poll::Ready(Ok(())) => {}
13371                    std::task::Poll::Pending => return std::task::Poll::Pending,
13372                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13373                        this.is_terminated = true;
13374                        return std::task::Poll::Ready(None);
13375                    }
13376                    std::task::Poll::Ready(Err(e)) => {
13377                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13378                            e.into(),
13379                        ))));
13380                    }
13381                }
13382
13383                // A message has been received from the channel
13384                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13385
13386                std::task::Poll::Ready(Some(match header.ordinal {
13387                    0x3b3a37fc34fe5b56 => {
13388                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13389                        let mut req = fidl::new_empty!(
13390                            StreamBufferSetAddPayloadBufferRequest,
13391                            fidl::encoding::DefaultFuchsiaResourceDialect
13392                        );
13393                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13394                        let control_handle =
13395                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13396                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13397                            id: req.id,
13398                            payload_buffer: req.payload_buffer,
13399
13400                            control_handle,
13401                        })
13402                    }
13403                    0x5d1e4f74c3658262 => {
13404                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13405                        let mut req = fidl::new_empty!(
13406                            StreamBufferSetRemovePayloadBufferRequest,
13407                            fidl::encoding::DefaultFuchsiaResourceDialect
13408                        );
13409                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13410                        let control_handle =
13411                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13412                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13413                            id: req.id,
13414
13415                            control_handle,
13416                        })
13417                    }
13418                    _ => Err(fidl::Error::UnknownOrdinal {
13419                        ordinal: header.ordinal,
13420                        protocol_name:
13421                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13422                    }),
13423                }))
13424            },
13425        )
13426    }
13427}
13428
13429/// Manages a set of payload buffers for a stream. This interface is typically
13430/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13431/// of elementary streams between clients and services.
13432#[derive(Debug)]
13433pub enum StreamBufferSetRequest {
13434    /// Adds a payload buffer to the current buffer set associated with the
13435    /// connection. A `StreamPacket` struct reference a payload buffer in the
13436    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13437    ///
13438    /// A buffer with ID `id` must not be in the current set when this method is
13439    /// invoked, otherwise the service will close the connection.
13440    AddPayloadBuffer {
13441        id: u32,
13442        payload_buffer: fidl::Vmo,
13443        control_handle: StreamBufferSetControlHandle,
13444    },
13445    /// Removes a payload buffer from the current buffer set associated with the
13446    /// connection.
13447    ///
13448    /// A buffer with ID `id` must exist in the current set when this method is
13449    /// invoked, otherwise the service will will close the connection.
13450    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13451}
13452
13453impl StreamBufferSetRequest {
13454    #[allow(irrefutable_let_patterns)]
13455    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13456        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13457            self
13458        {
13459            Some((id, payload_buffer, control_handle))
13460        } else {
13461            None
13462        }
13463    }
13464
13465    #[allow(irrefutable_let_patterns)]
13466    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13467        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13468            Some((id, control_handle))
13469        } else {
13470            None
13471        }
13472    }
13473
13474    /// Name of the method defined in FIDL
13475    pub fn method_name(&self) -> &'static str {
13476        match *self {
13477            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13478            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13479        }
13480    }
13481}
13482
13483#[derive(Debug, Clone)]
13484pub struct StreamBufferSetControlHandle {
13485    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13486}
13487
13488impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13489    fn shutdown(&self) {
13490        self.inner.shutdown()
13491    }
13492    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13493        self.inner.shutdown_with_epitaph(status)
13494    }
13495
13496    fn is_closed(&self) -> bool {
13497        self.inner.channel().is_closed()
13498    }
13499    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13500        self.inner.channel().on_closed()
13501    }
13502
13503    #[cfg(target_os = "fuchsia")]
13504    fn signal_peer(
13505        &self,
13506        clear_mask: zx::Signals,
13507        set_mask: zx::Signals,
13508    ) -> Result<(), zx_status::Status> {
13509        use fidl::Peered;
13510        self.inner.channel().signal_peer(clear_mask, set_mask)
13511    }
13512}
13513
13514impl StreamBufferSetControlHandle {}
13515
13516#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13517pub struct StreamProcessorMarker;
13518
13519impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13520    type Proxy = StreamProcessorProxy;
13521    type RequestStream = StreamProcessorRequestStream;
13522    #[cfg(target_os = "fuchsia")]
13523    type SynchronousProxy = StreamProcessorSynchronousProxy;
13524
13525    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13526}
13527
13528pub trait StreamProcessorProxyInterface: Send + Sync {
13529    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13530    fn r#set_input_buffer_partial_settings(
13531        &self,
13532        input_settings: StreamBufferPartialSettings,
13533    ) -> Result<(), fidl::Error>;
13534    fn r#set_output_buffer_partial_settings(
13535        &self,
13536        output_settings: StreamBufferPartialSettings,
13537    ) -> Result<(), fidl::Error>;
13538    fn r#complete_output_buffer_partial_settings(
13539        &self,
13540        buffer_lifetime_ordinal: u64,
13541    ) -> Result<(), fidl::Error>;
13542    fn r#flush_end_of_stream_and_close_stream(
13543        &self,
13544        stream_lifetime_ordinal: u64,
13545    ) -> Result<(), fidl::Error>;
13546    fn r#close_current_stream(
13547        &self,
13548        stream_lifetime_ordinal: u64,
13549        release_input_buffers: bool,
13550        release_output_buffers: bool,
13551    ) -> Result<(), fidl::Error>;
13552    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13553    fn r#sync(&self) -> Self::SyncResponseFut;
13554    fn r#recycle_output_packet(
13555        &self,
13556        available_output_packet: &PacketHeader,
13557    ) -> Result<(), fidl::Error>;
13558    fn r#queue_input_format_details(
13559        &self,
13560        stream_lifetime_ordinal: u64,
13561        format_details: &FormatDetails,
13562    ) -> Result<(), fidl::Error>;
13563    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13564    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13565}
13566#[derive(Debug)]
13567#[cfg(target_os = "fuchsia")]
13568pub struct StreamProcessorSynchronousProxy {
13569    client: fidl::client::sync::Client,
13570}
13571
13572#[cfg(target_os = "fuchsia")]
13573impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13574    type Proxy = StreamProcessorProxy;
13575    type Protocol = StreamProcessorMarker;
13576
13577    fn from_channel(inner: fidl::Channel) -> Self {
13578        Self::new(inner)
13579    }
13580
13581    fn into_channel(self) -> fidl::Channel {
13582        self.client.into_channel()
13583    }
13584
13585    fn as_channel(&self) -> &fidl::Channel {
13586        self.client.as_channel()
13587    }
13588}
13589
13590#[cfg(target_os = "fuchsia")]
13591impl StreamProcessorSynchronousProxy {
13592    pub fn new(channel: fidl::Channel) -> Self {
13593        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13594        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13595    }
13596
13597    pub fn into_channel(self) -> fidl::Channel {
13598        self.client.into_channel()
13599    }
13600
13601    /// Waits until an event arrives and returns it. It is safe for other
13602    /// threads to make concurrent requests while waiting for an event.
13603    pub fn wait_for_event(
13604        &self,
13605        deadline: zx::MonotonicInstant,
13606    ) -> Result<StreamProcessorEvent, fidl::Error> {
13607        StreamProcessorEvent::decode(self.client.wait_for_event(deadline)?)
13608    }
13609
13610    /// Permit the server to use OnStreamFailed() instead of the server just
13611    /// closing the whole StreamProcessor channel on stream failure.
13612    ///
13613    /// If the server hasn't seen this message by the time a stream fails, the
13614    /// server will close the StreamProcessor channel instead of sending
13615    /// OnStreamFailed().
13616    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
13617        self.client.send::<fidl::encoding::EmptyPayload>(
13618            (),
13619            0x3940929617dbf02b,
13620            fidl::encoding::DynamicFlags::empty(),
13621        )
13622    }
13623
13624    /// This is the replacement for SetInputBufferSettings().
13625    ///
13626    /// When the client is using sysmem to allocate buffers, this message is
13627    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
13628    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
13629    /// the client-specified input settings and a BufferCollectionToken which
13630    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
13631    /// client and the StreamProcessor will be informed of the allocated buffers
13632    /// directly by sysmem via their BufferCollection channel (not via the
13633    /// StreamProcessor channel).
13634    ///
13635    /// The client must not QueueInput...() until after sysmem informs the client
13636    /// that buffer allocation has completed and was successful.
13637    ///
13638    /// The server should be prepared to see QueueInput...() before the server
13639    /// has necessarily heard from sysmem that the buffers are allocated - the
13640    /// server must tolerate either ordering, as the QueueInput...() and
13641    /// notification of sysmem allocation completion arrive on different
13642    /// channels, so the client having heard that allocation is complete doesn't
13643    /// mean the server knows that allocation is complete yet.  However, the
13644    /// server can expect that allocation is in fact complete and can expect to
13645    /// get the allocation information from sysmem immediately upon requesting
13646    /// the information from sysmem.
13647    pub fn r#set_input_buffer_partial_settings(
13648        &self,
13649        mut input_settings: StreamBufferPartialSettings,
13650    ) -> Result<(), fidl::Error> {
13651        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
13652            (&mut input_settings,),
13653            0xb02e0663a40e4c4,
13654            fidl::encoding::DynamicFlags::empty(),
13655        )
13656    }
13657
13658    /// This is the replacement for SetOutputBufferSettings().
13659    ///
13660    /// When the client is using sysmem to allocate buffers, this message is
13661    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13662    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13663    /// with the client-specified output settings and a BufferCollectionToken
13664    /// which the StreamProcessor will use to convey constraints to sysmem.
13665    /// Both the client and the StreamProcessor will be informed of the
13666    /// allocated buffers directly by sysmem via their BufferCollection channel
13667    /// (not via the StreamProcessor channel).
13668    ///
13669    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13670    /// received by the client with buffer_constraints_action_required true and
13671    /// stream_lifetime_ordinal equal to the client's current
13672    /// stream_lifetime_ordinal (even if there is an active stream), and is
13673    /// _permitted_ any time there is no current stream.
13674    ///
13675    /// Closing the current stream occurs on the StreamControl ordering domain,
13676    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13677    /// subsequent Sync() completion must be received by the client before the
13678    /// client knows that there's no longer a current stream.
13679    ///
13680    /// See also CompleteOutputBufferPartialSettings().
13681    pub fn r#set_output_buffer_partial_settings(
13682        &self,
13683        mut output_settings: StreamBufferPartialSettings,
13684    ) -> Result<(), fidl::Error> {
13685        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
13686            (&mut output_settings,),
13687            0x118bb8c819a7bbbb,
13688            fidl::encoding::DynamicFlags::empty(),
13689        )
13690    }
13691
13692    /// After SetOutputBufferPartialSettings(), the server won't send
13693    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13694    /// OnOutputEndOfStream() until after the client sends
13695    /// CompleteOutputBufferPartialSettings().
13696    ///
13697    /// Some clients may be able to send
13698    /// CompleteOutputBufferPartialSettings() immediately after
13699    /// SetOutputBufferPartialSettings() - in that case the client needs to be
13700    /// prepared to receive output without knowing the buffer count or packet
13701    /// count yet - such clients may internally delay processing the received
13702    /// output until the client has heard from sysmem (which is when the client
13703    /// will learn the buffer count and packet count).
13704    ///
13705    /// Other clients may first wait for sysmem to allocate, prepare to receive
13706    /// output, and then send CompleteOutputBufferPartialSettings().
13707    pub fn r#complete_output_buffer_partial_settings(
13708        &self,
13709        mut buffer_lifetime_ordinal: u64,
13710    ) -> Result<(), fidl::Error> {
13711        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
13712            (buffer_lifetime_ordinal,),
13713            0x50529e5c680ae3ab,
13714            fidl::encoding::DynamicFlags::empty(),
13715        )
13716    }
13717
13718    /// This message is optional.
13719    ///
13720    /// This message is only valid after QueueInputEndOfStream() for this stream.
13721    /// The stream_lifetime_ordinal input parameter must match the
13722    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13723    /// will close the channel.
13724    ///
13725    /// A client can use this message to flush through (not discard) the last
13726    /// input data of a stream so that the stream processor server generates
13727    /// corresponding output data for all the input data before the server moves
13728    /// on to the next stream, without forcing the client to wait for
13729    /// OnOutputEndOfStream() before queueing data of another stream.
13730    ///
13731    /// The difference between QueueInputEndOfStream() and
13732    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13733    /// from the client that there will not be any more input data for the
13734    /// stream (and this info is needed by some stream processors for the stream
13735    /// processor to ever emit the very last output data).  The
13736    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13737    /// later completely discarding the rest of the current stream by closing
13738    /// the current stream (with or without a stream switch).  In contrast,
13739    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13740    /// the previously-queued input data be processed including the logical
13741    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13742    /// before moving on to any newer stream - this essentially changes the
13743    /// close-stream handling from discard to flush-through for this stream
13744    /// only.
13745    ///
13746    /// A client using this message can start providing input data for a new
13747    /// stream without that causing discard of old stream data.  That's the
13748    /// purpose of this message - to allow a client to flush through (not
13749    /// discard) the old stream's last data (instead of the default when closing
13750    /// or switching streams which is discard).
13751    ///
13752    /// Because the old stream is not done processing yet and the old stream's
13753    /// data is not being discarded, the client must be prepared to continue to
13754    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13755    /// is done. The client will know the stream_lifetime_ordinal is done when
13756    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13757    /// closes.
13758    pub fn r#flush_end_of_stream_and_close_stream(
13759        &self,
13760        mut stream_lifetime_ordinal: u64,
13761    ) -> Result<(), fidl::Error> {
13762        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
13763            (stream_lifetime_ordinal,),
13764            0x2b62c3e26d0667e6,
13765            fidl::encoding::DynamicFlags::empty(),
13766        )
13767    }
13768
13769    /// This "closes" the current stream, leaving no current stream.  In
13770    /// addition, this message can optionally release input buffers or output
13771    /// buffers.
13772    ///
13773    /// If there has never been any active stream, the stream_lifetime_ordinal
13774    /// must be zero or the server will close the channel.  If there has been an
13775    /// active stream, the stream_lifetime_ordinal must be the most recent
13776    /// active stream whether that stream is still active or not.  Else the
13777    /// server will close the channel.
13778    ///
13779    /// Multiple of this message without any new active stream in between is not
13780    /// to be considered an error, which allows a client to use this message to
13781    /// close the current stream to stop wasting processing power on a stream the
13782    /// user no longer cares about, then later decide that buffers should be
13783    /// released and send this message again with release_input_buffers and/or
13784    /// release_output_buffers true to get the buffers released, if the client is
13785    /// interested in trying to avoid overlap in resource usage between old
13786    /// buffers and new buffers (not all clients are).
13787    ///
13788    /// See also Sync().
13789    pub fn r#close_current_stream(
13790        &self,
13791        mut stream_lifetime_ordinal: u64,
13792        mut release_input_buffers: bool,
13793        mut release_output_buffers: bool,
13794    ) -> Result<(), fidl::Error> {
13795        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
13796            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
13797            0x1d8a67522170ca07,
13798            fidl::encoding::DynamicFlags::empty(),
13799        )
13800    }
13801
13802    /// On completion, all previous StreamProcessor calls have done what they're
13803    /// going to do server-side, _except_ for processing of data queued using
13804    /// QueueInputPacket().
13805    ///
13806    /// The main purpose of this call is to enable the client to wait until
13807    /// CloseCurrentStream() with release_input_buffers and/or
13808    /// release_output_buffers set to true to take effect, before the client
13809    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13810    /// de-overlapping of resource usage can be worthwhile for media buffers
13811    /// which can consume resource types whose overall pools aren't necessarily
13812    /// vast in comparison to resources consumed.  Especially if a client is
13813    /// reconfiguring buffers multiple times.
13814    ///
13815    /// Note that Sync() prior to allocating new media buffers is not alone
13816    /// sufficient to achieve non-overlap of media buffer resource usage system
13817    /// wide, but it can be a useful part of achieving that.
13818    ///
13819    /// The Sync() transits the Output ordering domain and the StreamControl
13820    /// ordering domain, but not the InputData ordering domain.
13821    ///
13822    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13823    /// presently 10.  A client that stays <= 8 in-flight streams will
13824    /// comfortably stay under the limit of 10.  While the protocol permits
13825    /// repeated SetInputBufferSettings() and the like, a client that spams the
13826    /// channel can expect that the channel will just close if the server or the
13827    /// channel itself gets too far behind.
13828    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
13829        let _response =
13830            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
13831                (),
13832                0x4b3e44300b0ec6aa,
13833                fidl::encoding::DynamicFlags::empty(),
13834                ___deadline,
13835            )?;
13836        Ok(_response)
13837    }
13838
13839    /// After the client is done with an output packet, the client needs to tell
13840    /// the stream processor that the output packet can be re-used for more
13841    /// output, via this method.
13842    ///
13843    /// It's not permitted to recycle an output packet that's already free with
13844    /// the stream processor server.  It's permitted but discouraged for a
13845    /// client to recycle an output packet that has been deallocated by an
13846    /// explicit or implicit output buffer de-configuration().  See
13847    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
13848    /// stale RecycleOutputPacket() calls.
13849    pub fn r#recycle_output_packet(
13850        &self,
13851        mut available_output_packet: &PacketHeader,
13852    ) -> Result<(), fidl::Error> {
13853        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
13854            (available_output_packet,),
13855            0x32763632b94e0bd5,
13856            fidl::encoding::DynamicFlags::empty(),
13857        )
13858    }
13859
13860    /// If the input format details are still the same as specified during
13861    /// StreamProcessor creation, this message is unnecessary and does not need
13862    /// to be sent.
13863    ///
13864    /// If the stream doesn't exist yet, this message creates the stream.
13865    ///
13866    /// The server won't send OnOutputConstraints() until after the client has
13867    /// sent at least one QueueInput* message.
13868    ///
13869    /// All servers must permit QueueInputFormatDetails() at the start of a
13870    /// stream without failing, as long as the new format is supported by the
13871    /// StreamProcessor instance.  Technically this allows for a server to only
13872    /// support the exact input format set during StreamProcessor creation, and
13873    /// that is by design.  A client that tries to switch formats and gets a
13874    /// StreamProcessor channel failure should try again one more time with a
13875    /// fresh StreamProcessor instance created with CodecFactory using the new
13876    /// input format during creation, before giving up.
13877    ///
13878    /// These format details override the format details specified during stream
13879    /// processor creation for this stream only.  The next stream will default
13880    /// back to the format details set during stream processor creation.
13881    ///
13882    /// This message is permitted at the start of the first stream (just like at
13883    /// the start of any stream).  The format specified need not match what was
13884    /// specified during stream processor creation, but if it doesn't match, the
13885    /// StreamProcessor channel might close as described above.
13886    pub fn r#queue_input_format_details(
13887        &self,
13888        mut stream_lifetime_ordinal: u64,
13889        mut format_details: &FormatDetails,
13890    ) -> Result<(), fidl::Error> {
13891        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
13892            (stream_lifetime_ordinal, format_details),
13893            0x170dc0979d52231,
13894            fidl::encoding::DynamicFlags::empty(),
13895        )
13896    }
13897
13898    /// This message queues input data to the stream processor for processing.
13899    ///
13900    /// If the stream doesn't exist yet, this message creates the new stream.
13901    ///
13902    /// The server won't send OnOutputConstraints() until after the client has
13903    /// sent at least one QueueInput* message.
13904    ///
13905    /// The client must continue to deliver input data via this message even if
13906    /// the stream processor has not yet generated the first OnOutputConstraints(),
13907    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
13908    /// previously-queued input packets.  The input data must continue as long
13909    /// as there are free packets to be assured that the server will ever
13910    /// generate the first OnOutputConstraints().
13911    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
13912        self.client.send::<StreamProcessorQueueInputPacketRequest>(
13913            (packet,),
13914            0x47173d2652d9df3b,
13915            fidl::encoding::DynamicFlags::empty(),
13916        )
13917    }
13918
13919    /// Inform the server that all QueueInputPacket() messages for this stream
13920    /// have been sent.
13921    ///
13922    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
13923    /// or StreamProcessor channel closing), there will later be a corresponding
13924    /// OnOutputEndOfStream().
13925    ///
13926    /// The corresponding OnOutputEndOfStream() message will be generated only if
13927    /// the server finishes processing the stream before the server sees the
13928    /// client close the stream (such as by starting a new stream).  A way to
13929    /// force the server to finish the stream before closing is to use
13930    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
13931    /// new stream.  Another way to force the server to finish the stream before
13932    /// closing is to wait for the OnOutputEndOfStream() before taking any action
13933    /// that closes the stream.
13934    ///
13935    /// In addition to serving as an "EndOfStream" marker to make it obvious
13936    /// client-side when all input data has been processed, if a client never
13937    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
13938    /// result in all input data getting processed through to the output.  Some
13939    /// stream processors have some internally-delayed data which only gets
13940    /// pushed through by additional input data _or_ by this EndOfStream marker.
13941    /// In that sense, this message can be viewed as a flush-through at
13942    /// InputData domain level, but the flush-through only takes effect if the
13943    /// stream processor even gets that far before the stream is just closed at
13944    /// StreamControl domain level.  This message is not alone sufficient to act
13945    /// as an overall flush-through at StreamControl level. For that, send this
13946    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
13947    /// point it becomes possible to queue input data for a new stream without
13948    /// causing discard of this older stream's data), or wait for the
13949    /// OnOutputEndOfStream() before closing the current stream.
13950    ///
13951    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
13952    /// QueueInputEndOfStream() for this stream after the first
13953    /// QueueInputEndOfStream() for this stream, a server should close the
13954    /// StreamProcessor channel.
13955    pub fn r#queue_input_end_of_stream(
13956        &self,
13957        mut stream_lifetime_ordinal: u64,
13958    ) -> Result<(), fidl::Error> {
13959        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
13960            (stream_lifetime_ordinal,),
13961            0x2051b6ad00f20b37,
13962            fidl::encoding::DynamicFlags::empty(),
13963        )
13964    }
13965}
13966
13967#[cfg(target_os = "fuchsia")]
13968impl From<StreamProcessorSynchronousProxy> for zx::Handle {
13969    fn from(value: StreamProcessorSynchronousProxy) -> Self {
13970        value.into_channel().into()
13971    }
13972}
13973
13974#[cfg(target_os = "fuchsia")]
13975impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
13976    fn from(value: fidl::Channel) -> Self {
13977        Self::new(value)
13978    }
13979}
13980
13981#[cfg(target_os = "fuchsia")]
13982impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
13983    type Protocol = StreamProcessorMarker;
13984
13985    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
13986        Self::new(value.into_channel())
13987    }
13988}
13989
13990#[derive(Debug, Clone)]
13991pub struct StreamProcessorProxy {
13992    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13993}
13994
13995impl fidl::endpoints::Proxy for StreamProcessorProxy {
13996    type Protocol = StreamProcessorMarker;
13997
13998    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13999        Self::new(inner)
14000    }
14001
14002    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14003        self.client.into_channel().map_err(|client| Self { client })
14004    }
14005
14006    fn as_channel(&self) -> &::fidl::AsyncChannel {
14007        self.client.as_channel()
14008    }
14009}
14010
14011impl StreamProcessorProxy {
14012    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14013    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14014        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14015        Self { client: fidl::client::Client::new(channel, protocol_name) }
14016    }
14017
14018    /// Get a Stream of events from the remote end of the protocol.
14019    ///
14020    /// # Panics
14021    ///
14022    /// Panics if the event stream was already taken.
14023    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14024        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14025    }
14026
14027    /// Permit the server to use OnStreamFailed() instead of the server just
14028    /// closing the whole StreamProcessor channel on stream failure.
14029    ///
14030    /// If the server hasn't seen this message by the time a stream fails, the
14031    /// server will close the StreamProcessor channel instead of sending
14032    /// OnStreamFailed().
14033    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14034        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14035    }
14036
14037    /// This is the replacement for SetInputBufferSettings().
14038    ///
14039    /// When the client is using sysmem to allocate buffers, this message is
14040    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
14041    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
14042    /// the client-specified input settings and a BufferCollectionToken which
14043    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
14044    /// client and the StreamProcessor will be informed of the allocated buffers
14045    /// directly by sysmem via their BufferCollection channel (not via the
14046    /// StreamProcessor channel).
14047    ///
14048    /// The client must not QueueInput...() until after sysmem informs the client
14049    /// that buffer allocation has completed and was successful.
14050    ///
14051    /// The server should be prepared to see QueueInput...() before the server
14052    /// has necessarily heard from sysmem that the buffers are allocated - the
14053    /// server must tolerate either ordering, as the QueueInput...() and
14054    /// notification of sysmem allocation completion arrive on different
14055    /// channels, so the client having heard that allocation is complete doesn't
14056    /// mean the server knows that allocation is complete yet.  However, the
14057    /// server can expect that allocation is in fact complete and can expect to
14058    /// get the allocation information from sysmem immediately upon requesting
14059    /// the information from sysmem.
14060    pub fn r#set_input_buffer_partial_settings(
14061        &self,
14062        mut input_settings: StreamBufferPartialSettings,
14063    ) -> Result<(), fidl::Error> {
14064        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14065    }
14066
14067    /// This is the replacement for SetOutputBufferSettings().
14068    ///
14069    /// When the client is using sysmem to allocate buffers, this message is
14070    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14071    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14072    /// with the client-specified output settings and a BufferCollectionToken
14073    /// which the StreamProcessor will use to convey constraints to sysmem.
14074    /// Both the client and the StreamProcessor will be informed of the
14075    /// allocated buffers directly by sysmem via their BufferCollection channel
14076    /// (not via the StreamProcessor channel).
14077    ///
14078    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14079    /// received by the client with buffer_constraints_action_required true and
14080    /// stream_lifetime_ordinal equal to the client's current
14081    /// stream_lifetime_ordinal (even if there is an active stream), and is
14082    /// _permitted_ any time there is no current stream.
14083    ///
14084    /// Closing the current stream occurs on the StreamControl ordering domain,
14085    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14086    /// subsequent Sync() completion must be received by the client before the
14087    /// client knows that there's no longer a current stream.
14088    ///
14089    /// See also CompleteOutputBufferPartialSettings().
14090    pub fn r#set_output_buffer_partial_settings(
14091        &self,
14092        mut output_settings: StreamBufferPartialSettings,
14093    ) -> Result<(), fidl::Error> {
14094        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
14095    }
14096
14097    /// After SetOutputBufferPartialSettings(), the server won't send
14098    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14099    /// OnOutputEndOfStream() until after the client sends
14100    /// CompleteOutputBufferPartialSettings().
14101    ///
14102    /// Some clients may be able to send
14103    /// CompleteOutputBufferPartialSettings() immediately after
14104    /// SetOutputBufferPartialSettings() - in that case the client needs to be
14105    /// prepared to receive output without knowing the buffer count or packet
14106    /// count yet - such clients may internally delay processing the received
14107    /// output until the client has heard from sysmem (which is when the client
14108    /// will learn the buffer count and packet count).
14109    ///
14110    /// Other clients may first wait for sysmem to allocate, prepare to receive
14111    /// output, and then send CompleteOutputBufferPartialSettings().
14112    pub fn r#complete_output_buffer_partial_settings(
14113        &self,
14114        mut buffer_lifetime_ordinal: u64,
14115    ) -> Result<(), fidl::Error> {
14116        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
14117            self,
14118            buffer_lifetime_ordinal,
14119        )
14120    }
14121
14122    /// This message is optional.
14123    ///
14124    /// This message is only valid after QueueInputEndOfStream() for this stream.
14125    /// The stream_lifetime_ordinal input parameter must match the
14126    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14127    /// will close the channel.
14128    ///
14129    /// A client can use this message to flush through (not discard) the last
14130    /// input data of a stream so that the stream processor server generates
14131    /// corresponding output data for all the input data before the server moves
14132    /// on to the next stream, without forcing the client to wait for
14133    /// OnOutputEndOfStream() before queueing data of another stream.
14134    ///
14135    /// The difference between QueueInputEndOfStream() and
14136    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14137    /// from the client that there will not be any more input data for the
14138    /// stream (and this info is needed by some stream processors for the stream
14139    /// processor to ever emit the very last output data).  The
14140    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14141    /// later completely discarding the rest of the current stream by closing
14142    /// the current stream (with or without a stream switch).  In contrast,
14143    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14144    /// the previously-queued input data be processed including the logical
14145    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14146    /// before moving on to any newer stream - this essentially changes the
14147    /// close-stream handling from discard to flush-through for this stream
14148    /// only.
14149    ///
14150    /// A client using this message can start providing input data for a new
14151    /// stream without that causing discard of old stream data.  That's the
14152    /// purpose of this message - to allow a client to flush through (not
14153    /// discard) the old stream's last data (instead of the default when closing
14154    /// or switching streams which is discard).
14155    ///
14156    /// Because the old stream is not done processing yet and the old stream's
14157    /// data is not being discarded, the client must be prepared to continue to
14158    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14159    /// is done. The client will know the stream_lifetime_ordinal is done when
14160    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14161    /// closes.
14162    pub fn r#flush_end_of_stream_and_close_stream(
14163        &self,
14164        mut stream_lifetime_ordinal: u64,
14165    ) -> Result<(), fidl::Error> {
14166        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
14167            self,
14168            stream_lifetime_ordinal,
14169        )
14170    }
14171
14172    /// This "closes" the current stream, leaving no current stream.  In
14173    /// addition, this message can optionally release input buffers or output
14174    /// buffers.
14175    ///
14176    /// If there has never been any active stream, the stream_lifetime_ordinal
14177    /// must be zero or the server will close the channel.  If there has been an
14178    /// active stream, the stream_lifetime_ordinal must be the most recent
14179    /// active stream whether that stream is still active or not.  Else the
14180    /// server will close the channel.
14181    ///
14182    /// Multiple of this message without any new active stream in between is not
14183    /// to be considered an error, which allows a client to use this message to
14184    /// close the current stream to stop wasting processing power on a stream the
14185    /// user no longer cares about, then later decide that buffers should be
14186    /// released and send this message again with release_input_buffers and/or
14187    /// release_output_buffers true to get the buffers released, if the client is
14188    /// interested in trying to avoid overlap in resource usage between old
14189    /// buffers and new buffers (not all clients are).
14190    ///
14191    /// See also Sync().
14192    pub fn r#close_current_stream(
14193        &self,
14194        mut stream_lifetime_ordinal: u64,
14195        mut release_input_buffers: bool,
14196        mut release_output_buffers: bool,
14197    ) -> Result<(), fidl::Error> {
14198        StreamProcessorProxyInterface::r#close_current_stream(
14199            self,
14200            stream_lifetime_ordinal,
14201            release_input_buffers,
14202            release_output_buffers,
14203        )
14204    }
14205
14206    /// On completion, all previous StreamProcessor calls have done what they're
14207    /// going to do server-side, _except_ for processing of data queued using
14208    /// QueueInputPacket().
14209    ///
14210    /// The main purpose of this call is to enable the client to wait until
14211    /// CloseCurrentStream() with release_input_buffers and/or
14212    /// release_output_buffers set to true to take effect, before the client
14213    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14214    /// de-overlapping of resource usage can be worthwhile for media buffers
14215    /// which can consume resource types whose overall pools aren't necessarily
14216    /// vast in comparison to resources consumed.  Especially if a client is
14217    /// reconfiguring buffers multiple times.
14218    ///
14219    /// Note that Sync() prior to allocating new media buffers is not alone
14220    /// sufficient to achieve non-overlap of media buffer resource usage system
14221    /// wide, but it can be a useful part of achieving that.
14222    ///
14223    /// The Sync() transits the Output ordering domain and the StreamControl
14224    /// ordering domain, but not the InputData ordering domain.
14225    ///
14226    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14227    /// presently 10.  A client that stays <= 8 in-flight streams will
14228    /// comfortably stay under the limit of 10.  While the protocol permits
14229    /// repeated SetInputBufferSettings() and the like, a client that spams the
14230    /// channel can expect that the channel will just close if the server or the
14231    /// channel itself gets too far behind.
14232    pub fn r#sync(
14233        &self,
14234    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
14235        StreamProcessorProxyInterface::r#sync(self)
14236    }
14237
14238    /// After the client is done with an output packet, the client needs to tell
14239    /// the stream processor that the output packet can be re-used for more
14240    /// output, via this method.
14241    ///
14242    /// It's not permitted to recycle an output packet that's already free with
14243    /// the stream processor server.  It's permitted but discouraged for a
14244    /// client to recycle an output packet that has been deallocated by an
14245    /// explicit or implicit output buffer de-configuration().  See
14246    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
14247    /// stale RecycleOutputPacket() calls.
14248    pub fn r#recycle_output_packet(
14249        &self,
14250        mut available_output_packet: &PacketHeader,
14251    ) -> Result<(), fidl::Error> {
14252        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
14253    }
14254
14255    /// If the input format details are still the same as specified during
14256    /// StreamProcessor creation, this message is unnecessary and does not need
14257    /// to be sent.
14258    ///
14259    /// If the stream doesn't exist yet, this message creates the stream.
14260    ///
14261    /// The server won't send OnOutputConstraints() until after the client has
14262    /// sent at least one QueueInput* message.
14263    ///
14264    /// All servers must permit QueueInputFormatDetails() at the start of a
14265    /// stream without failing, as long as the new format is supported by the
14266    /// StreamProcessor instance.  Technically this allows for a server to only
14267    /// support the exact input format set during StreamProcessor creation, and
14268    /// that is by design.  A client that tries to switch formats and gets a
14269    /// StreamProcessor channel failure should try again one more time with a
14270    /// fresh StreamProcessor instance created with CodecFactory using the new
14271    /// input format during creation, before giving up.
14272    ///
14273    /// These format details override the format details specified during stream
14274    /// processor creation for this stream only.  The next stream will default
14275    /// back to the format details set during stream processor creation.
14276    ///
14277    /// This message is permitted at the start of the first stream (just like at
14278    /// the start of any stream).  The format specified need not match what was
14279    /// specified during stream processor creation, but if it doesn't match, the
14280    /// StreamProcessor channel might close as described above.
14281    pub fn r#queue_input_format_details(
14282        &self,
14283        mut stream_lifetime_ordinal: u64,
14284        mut format_details: &FormatDetails,
14285    ) -> Result<(), fidl::Error> {
14286        StreamProcessorProxyInterface::r#queue_input_format_details(
14287            self,
14288            stream_lifetime_ordinal,
14289            format_details,
14290        )
14291    }
14292
14293    /// This message queues input data to the stream processor for processing.
14294    ///
14295    /// If the stream doesn't exist yet, this message creates the new stream.
14296    ///
14297    /// The server won't send OnOutputConstraints() until after the client has
14298    /// sent at least one QueueInput* message.
14299    ///
14300    /// The client must continue to deliver input data via this message even if
14301    /// the stream processor has not yet generated the first OnOutputConstraints(),
14302    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
14303    /// previously-queued input packets.  The input data must continue as long
14304    /// as there are free packets to be assured that the server will ever
14305    /// generate the first OnOutputConstraints().
14306    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14307        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
14308    }
14309
14310    /// Inform the server that all QueueInputPacket() messages for this stream
14311    /// have been sent.
14312    ///
14313    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14314    /// or StreamProcessor channel closing), there will later be a corresponding
14315    /// OnOutputEndOfStream().
14316    ///
14317    /// The corresponding OnOutputEndOfStream() message will be generated only if
14318    /// the server finishes processing the stream before the server sees the
14319    /// client close the stream (such as by starting a new stream).  A way to
14320    /// force the server to finish the stream before closing is to use
14321    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
14322    /// new stream.  Another way to force the server to finish the stream before
14323    /// closing is to wait for the OnOutputEndOfStream() before taking any action
14324    /// that closes the stream.
14325    ///
14326    /// In addition to serving as an "EndOfStream" marker to make it obvious
14327    /// client-side when all input data has been processed, if a client never
14328    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
14329    /// result in all input data getting processed through to the output.  Some
14330    /// stream processors have some internally-delayed data which only gets
14331    /// pushed through by additional input data _or_ by this EndOfStream marker.
14332    /// In that sense, this message can be viewed as a flush-through at
14333    /// InputData domain level, but the flush-through only takes effect if the
14334    /// stream processor even gets that far before the stream is just closed at
14335    /// StreamControl domain level.  This message is not alone sufficient to act
14336    /// as an overall flush-through at StreamControl level. For that, send this
14337    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14338    /// point it becomes possible to queue input data for a new stream without
14339    /// causing discard of this older stream's data), or wait for the
14340    /// OnOutputEndOfStream() before closing the current stream.
14341    ///
14342    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14343    /// QueueInputEndOfStream() for this stream after the first
14344    /// QueueInputEndOfStream() for this stream, a server should close the
14345    /// StreamProcessor channel.
14346    pub fn r#queue_input_end_of_stream(
14347        &self,
14348        mut stream_lifetime_ordinal: u64,
14349    ) -> Result<(), fidl::Error> {
14350        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
14351    }
14352}
14353
14354impl StreamProcessorProxyInterface for StreamProcessorProxy {
14355    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14356        self.client.send::<fidl::encoding::EmptyPayload>(
14357            (),
14358            0x3940929617dbf02b,
14359            fidl::encoding::DynamicFlags::empty(),
14360        )
14361    }
14362
14363    fn r#set_input_buffer_partial_settings(
14364        &self,
14365        mut input_settings: StreamBufferPartialSettings,
14366    ) -> Result<(), fidl::Error> {
14367        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14368            (&mut input_settings,),
14369            0xb02e0663a40e4c4,
14370            fidl::encoding::DynamicFlags::empty(),
14371        )
14372    }
14373
14374    fn r#set_output_buffer_partial_settings(
14375        &self,
14376        mut output_settings: StreamBufferPartialSettings,
14377    ) -> Result<(), fidl::Error> {
14378        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14379            (&mut output_settings,),
14380            0x118bb8c819a7bbbb,
14381            fidl::encoding::DynamicFlags::empty(),
14382        )
14383    }
14384
14385    fn r#complete_output_buffer_partial_settings(
14386        &self,
14387        mut buffer_lifetime_ordinal: u64,
14388    ) -> Result<(), fidl::Error> {
14389        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14390            (buffer_lifetime_ordinal,),
14391            0x50529e5c680ae3ab,
14392            fidl::encoding::DynamicFlags::empty(),
14393        )
14394    }
14395
14396    fn r#flush_end_of_stream_and_close_stream(
14397        &self,
14398        mut stream_lifetime_ordinal: u64,
14399    ) -> Result<(), fidl::Error> {
14400        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14401            (stream_lifetime_ordinal,),
14402            0x2b62c3e26d0667e6,
14403            fidl::encoding::DynamicFlags::empty(),
14404        )
14405    }
14406
14407    fn r#close_current_stream(
14408        &self,
14409        mut stream_lifetime_ordinal: u64,
14410        mut release_input_buffers: bool,
14411        mut release_output_buffers: bool,
14412    ) -> Result<(), fidl::Error> {
14413        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14414            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14415            0x1d8a67522170ca07,
14416            fidl::encoding::DynamicFlags::empty(),
14417        )
14418    }
14419
14420    type SyncResponseFut =
14421        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
14422    fn r#sync(&self) -> Self::SyncResponseFut {
14423        fn _decode(
14424            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14425        ) -> Result<(), fidl::Error> {
14426            let _response = fidl::client::decode_transaction_body::<
14427                fidl::encoding::EmptyPayload,
14428                fidl::encoding::DefaultFuchsiaResourceDialect,
14429                0x4b3e44300b0ec6aa,
14430            >(_buf?)?;
14431            Ok(_response)
14432        }
14433        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14434            (),
14435            0x4b3e44300b0ec6aa,
14436            fidl::encoding::DynamicFlags::empty(),
14437            _decode,
14438        )
14439    }
14440
14441    fn r#recycle_output_packet(
14442        &self,
14443        mut available_output_packet: &PacketHeader,
14444    ) -> Result<(), fidl::Error> {
14445        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14446            (available_output_packet,),
14447            0x32763632b94e0bd5,
14448            fidl::encoding::DynamicFlags::empty(),
14449        )
14450    }
14451
14452    fn r#queue_input_format_details(
14453        &self,
14454        mut stream_lifetime_ordinal: u64,
14455        mut format_details: &FormatDetails,
14456    ) -> Result<(), fidl::Error> {
14457        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14458            (stream_lifetime_ordinal, format_details),
14459            0x170dc0979d52231,
14460            fidl::encoding::DynamicFlags::empty(),
14461        )
14462    }
14463
14464    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14465        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14466            (packet,),
14467            0x47173d2652d9df3b,
14468            fidl::encoding::DynamicFlags::empty(),
14469        )
14470    }
14471
14472    fn r#queue_input_end_of_stream(
14473        &self,
14474        mut stream_lifetime_ordinal: u64,
14475    ) -> Result<(), fidl::Error> {
14476        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14477            (stream_lifetime_ordinal,),
14478            0x2051b6ad00f20b37,
14479            fidl::encoding::DynamicFlags::empty(),
14480        )
14481    }
14482}
14483
14484pub struct StreamProcessorEventStream {
14485    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
14486}
14487
14488impl std::marker::Unpin for StreamProcessorEventStream {}
14489
14490impl futures::stream::FusedStream for StreamProcessorEventStream {
14491    fn is_terminated(&self) -> bool {
14492        self.event_receiver.is_terminated()
14493    }
14494}
14495
14496impl futures::Stream for StreamProcessorEventStream {
14497    type Item = Result<StreamProcessorEvent, fidl::Error>;
14498
14499    fn poll_next(
14500        mut self: std::pin::Pin<&mut Self>,
14501        cx: &mut std::task::Context<'_>,
14502    ) -> std::task::Poll<Option<Self::Item>> {
14503        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14504            &mut self.event_receiver,
14505            cx
14506        )?) {
14507            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
14508            None => std::task::Poll::Ready(None),
14509        }
14510    }
14511}
14512
14513#[derive(Debug)]
14514pub enum StreamProcessorEvent {
14515    OnStreamFailed {
14516        stream_lifetime_ordinal: u64,
14517        error: StreamError,
14518    },
14519    OnInputConstraints {
14520        input_constraints: StreamBufferConstraints,
14521    },
14522    OnOutputConstraints {
14523        output_config: StreamOutputConstraints,
14524    },
14525    OnOutputFormat {
14526        output_format: StreamOutputFormat,
14527    },
14528    OnOutputPacket {
14529        output_packet: Packet,
14530        error_detected_before: bool,
14531        error_detected_during: bool,
14532    },
14533    OnOutputEndOfStream {
14534        stream_lifetime_ordinal: u64,
14535        error_detected_before: bool,
14536    },
14537    OnFreeInputPacket {
14538        free_input_packet: PacketHeader,
14539    },
14540}
14541
14542impl StreamProcessorEvent {
14543    #[allow(irrefutable_let_patterns)]
14544    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
14545        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
14546            Some((stream_lifetime_ordinal, error))
14547        } else {
14548            None
14549        }
14550    }
14551    #[allow(irrefutable_let_patterns)]
14552    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
14553        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
14554            Some((input_constraints))
14555        } else {
14556            None
14557        }
14558    }
14559    #[allow(irrefutable_let_patterns)]
14560    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
14561        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
14562            Some((output_config))
14563        } else {
14564            None
14565        }
14566    }
14567    #[allow(irrefutable_let_patterns)]
14568    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
14569        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
14570            Some((output_format))
14571        } else {
14572            None
14573        }
14574    }
14575    #[allow(irrefutable_let_patterns)]
14576    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
14577        if let StreamProcessorEvent::OnOutputPacket {
14578            output_packet,
14579            error_detected_before,
14580            error_detected_during,
14581        } = self
14582        {
14583            Some((output_packet, error_detected_before, error_detected_during))
14584        } else {
14585            None
14586        }
14587    }
14588    #[allow(irrefutable_let_patterns)]
14589    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
14590        if let StreamProcessorEvent::OnOutputEndOfStream {
14591            stream_lifetime_ordinal,
14592            error_detected_before,
14593        } = self
14594        {
14595            Some((stream_lifetime_ordinal, error_detected_before))
14596        } else {
14597            None
14598        }
14599    }
14600    #[allow(irrefutable_let_patterns)]
14601    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
14602        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
14603            Some((free_input_packet))
14604        } else {
14605            None
14606        }
14607    }
14608
14609    /// Decodes a message buffer as a [`StreamProcessorEvent`].
14610    fn decode(
14611        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14612    ) -> Result<StreamProcessorEvent, fidl::Error> {
14613        let (bytes, _handles) = buf.split_mut();
14614        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14615        debug_assert_eq!(tx_header.tx_id, 0);
14616        match tx_header.ordinal {
14617            0x77ccf70bb061cf8e => {
14618                let mut out = fidl::new_empty!(
14619                    StreamProcessorOnStreamFailedRequest,
14620                    fidl::encoding::DefaultFuchsiaResourceDialect
14621                );
14622                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14623                Ok((StreamProcessorEvent::OnStreamFailed {
14624                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14625                    error: out.error,
14626                }))
14627            }
14628            0x211da9966a8ca0 => {
14629                let mut out = fidl::new_empty!(
14630                    StreamProcessorOnInputConstraintsRequest,
14631                    fidl::encoding::DefaultFuchsiaResourceDialect
14632                );
14633                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14634                Ok((StreamProcessorEvent::OnInputConstraints {
14635                    input_constraints: out.input_constraints,
14636                }))
14637            }
14638            0x40d8234504c170f3 => {
14639                let mut out = fidl::new_empty!(
14640                    StreamProcessorOnOutputConstraintsRequest,
14641                    fidl::encoding::DefaultFuchsiaResourceDialect
14642                );
14643                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14644                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
14645            }
14646            0x131b77ae120360bc => {
14647                let mut out = fidl::new_empty!(
14648                    StreamProcessorOnOutputFormatRequest,
14649                    fidl::encoding::DefaultFuchsiaResourceDialect
14650                );
14651                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14652                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
14653            }
14654            0x5c2029be1090ce93 => {
14655                let mut out = fidl::new_empty!(
14656                    StreamProcessorOnOutputPacketRequest,
14657                    fidl::encoding::DefaultFuchsiaResourceDialect
14658                );
14659                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14660                Ok((StreamProcessorEvent::OnOutputPacket {
14661                    output_packet: out.output_packet,
14662                    error_detected_before: out.error_detected_before,
14663                    error_detected_during: out.error_detected_during,
14664                }))
14665            }
14666            0x3bb65d237cfa50e6 => {
14667                let mut out = fidl::new_empty!(
14668                    StreamProcessorOnOutputEndOfStreamRequest,
14669                    fidl::encoding::DefaultFuchsiaResourceDialect
14670                );
14671                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14672                Ok((StreamProcessorEvent::OnOutputEndOfStream {
14673                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14674                    error_detected_before: out.error_detected_before,
14675                }))
14676            }
14677            0xeef799b28708bbd => {
14678                let mut out = fidl::new_empty!(
14679                    StreamProcessorOnFreeInputPacketRequest,
14680                    fidl::encoding::DefaultFuchsiaResourceDialect
14681                );
14682                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14683                Ok((StreamProcessorEvent::OnFreeInputPacket {
14684                    free_input_packet: out.free_input_packet,
14685                }))
14686            }
14687            _ => Err(fidl::Error::UnknownOrdinal {
14688                ordinal: tx_header.ordinal,
14689                protocol_name:
14690                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14691            }),
14692        }
14693    }
14694}
14695
14696/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
14697pub struct StreamProcessorRequestStream {
14698    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14699    is_terminated: bool,
14700}
14701
14702impl std::marker::Unpin for StreamProcessorRequestStream {}
14703
14704impl futures::stream::FusedStream for StreamProcessorRequestStream {
14705    fn is_terminated(&self) -> bool {
14706        self.is_terminated
14707    }
14708}
14709
14710impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
14711    type Protocol = StreamProcessorMarker;
14712    type ControlHandle = StreamProcessorControlHandle;
14713
14714    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
14715        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14716    }
14717
14718    fn control_handle(&self) -> Self::ControlHandle {
14719        StreamProcessorControlHandle { inner: self.inner.clone() }
14720    }
14721
14722    fn into_inner(
14723        self,
14724    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
14725    {
14726        (self.inner, self.is_terminated)
14727    }
14728
14729    fn from_inner(
14730        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14731        is_terminated: bool,
14732    ) -> Self {
14733        Self { inner, is_terminated }
14734    }
14735}
14736
14737impl futures::Stream for StreamProcessorRequestStream {
14738    type Item = Result<StreamProcessorRequest, fidl::Error>;
14739
14740    fn poll_next(
14741        mut self: std::pin::Pin<&mut Self>,
14742        cx: &mut std::task::Context<'_>,
14743    ) -> std::task::Poll<Option<Self::Item>> {
14744        let this = &mut *self;
14745        if this.inner.check_shutdown(cx) {
14746            this.is_terminated = true;
14747            return std::task::Poll::Ready(None);
14748        }
14749        if this.is_terminated {
14750            panic!("polled StreamProcessorRequestStream after completion");
14751        }
14752        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
14753            |bytes, handles| {
14754                match this.inner.channel().read_etc(cx, bytes, handles) {
14755                    std::task::Poll::Ready(Ok(())) => {}
14756                    std::task::Poll::Pending => return std::task::Poll::Pending,
14757                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
14758                        this.is_terminated = true;
14759                        return std::task::Poll::Ready(None);
14760                    }
14761                    std::task::Poll::Ready(Err(e)) => {
14762                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14763                            e.into(),
14764                        ))));
14765                    }
14766                }
14767
14768                // A message has been received from the channel
14769                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14770
14771                std::task::Poll::Ready(Some(match header.ordinal {
14772                    0x3940929617dbf02b => {
14773                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14774                        let mut req = fidl::new_empty!(
14775                            fidl::encoding::EmptyPayload,
14776                            fidl::encoding::DefaultFuchsiaResourceDialect
14777                        );
14778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14779                        let control_handle =
14780                            StreamProcessorControlHandle { inner: this.inner.clone() };
14781                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
14782                    }
14783                    0xb02e0663a40e4c4 => {
14784                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14785                        let mut req = fidl::new_empty!(
14786                            StreamProcessorSetInputBufferPartialSettingsRequest,
14787                            fidl::encoding::DefaultFuchsiaResourceDialect
14788                        );
14789                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14790                        let control_handle =
14791                            StreamProcessorControlHandle { inner: this.inner.clone() };
14792                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
14793                            input_settings: req.input_settings,
14794
14795                            control_handle,
14796                        })
14797                    }
14798                    0x118bb8c819a7bbbb => {
14799                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14800                        let mut req = fidl::new_empty!(
14801                            StreamProcessorSetOutputBufferPartialSettingsRequest,
14802                            fidl::encoding::DefaultFuchsiaResourceDialect
14803                        );
14804                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14805                        let control_handle =
14806                            StreamProcessorControlHandle { inner: this.inner.clone() };
14807                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
14808                            output_settings: req.output_settings,
14809
14810                            control_handle,
14811                        })
14812                    }
14813                    0x50529e5c680ae3ab => {
14814                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14815                        let mut req = fidl::new_empty!(
14816                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
14817                            fidl::encoding::DefaultFuchsiaResourceDialect
14818                        );
14819                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14820                        let control_handle =
14821                            StreamProcessorControlHandle { inner: this.inner.clone() };
14822                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
14823                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
14824
14825                            control_handle,
14826                        })
14827                    }
14828                    0x2b62c3e26d0667e6 => {
14829                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14830                        let mut req = fidl::new_empty!(
14831                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
14832                            fidl::encoding::DefaultFuchsiaResourceDialect
14833                        );
14834                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14835                        let control_handle =
14836                            StreamProcessorControlHandle { inner: this.inner.clone() };
14837                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
14838                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14839
14840                            control_handle,
14841                        })
14842                    }
14843                    0x1d8a67522170ca07 => {
14844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14845                        let mut req = fidl::new_empty!(
14846                            StreamProcessorCloseCurrentStreamRequest,
14847                            fidl::encoding::DefaultFuchsiaResourceDialect
14848                        );
14849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14850                        let control_handle =
14851                            StreamProcessorControlHandle { inner: this.inner.clone() };
14852                        Ok(StreamProcessorRequest::CloseCurrentStream {
14853                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14854                            release_input_buffers: req.release_input_buffers,
14855                            release_output_buffers: req.release_output_buffers,
14856
14857                            control_handle,
14858                        })
14859                    }
14860                    0x4b3e44300b0ec6aa => {
14861                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14862                        let mut req = fidl::new_empty!(
14863                            fidl::encoding::EmptyPayload,
14864                            fidl::encoding::DefaultFuchsiaResourceDialect
14865                        );
14866                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14867                        let control_handle =
14868                            StreamProcessorControlHandle { inner: this.inner.clone() };
14869                        Ok(StreamProcessorRequest::Sync {
14870                            responder: StreamProcessorSyncResponder {
14871                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14872                                tx_id: header.tx_id,
14873                            },
14874                        })
14875                    }
14876                    0x32763632b94e0bd5 => {
14877                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14878                        let mut req = fidl::new_empty!(
14879                            StreamProcessorRecycleOutputPacketRequest,
14880                            fidl::encoding::DefaultFuchsiaResourceDialect
14881                        );
14882                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14883                        let control_handle =
14884                            StreamProcessorControlHandle { inner: this.inner.clone() };
14885                        Ok(StreamProcessorRequest::RecycleOutputPacket {
14886                            available_output_packet: req.available_output_packet,
14887
14888                            control_handle,
14889                        })
14890                    }
14891                    0x170dc0979d52231 => {
14892                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14893                        let mut req = fidl::new_empty!(
14894                            StreamProcessorQueueInputFormatDetailsRequest,
14895                            fidl::encoding::DefaultFuchsiaResourceDialect
14896                        );
14897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
14898                        let control_handle =
14899                            StreamProcessorControlHandle { inner: this.inner.clone() };
14900                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
14901                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14902                            format_details: req.format_details,
14903
14904                            control_handle,
14905                        })
14906                    }
14907                    0x47173d2652d9df3b => {
14908                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14909                        let mut req = fidl::new_empty!(
14910                            StreamProcessorQueueInputPacketRequest,
14911                            fidl::encoding::DefaultFuchsiaResourceDialect
14912                        );
14913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14914                        let control_handle =
14915                            StreamProcessorControlHandle { inner: this.inner.clone() };
14916                        Ok(StreamProcessorRequest::QueueInputPacket {
14917                            packet: req.packet,
14918
14919                            control_handle,
14920                        })
14921                    }
14922                    0x2051b6ad00f20b37 => {
14923                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14924                        let mut req = fidl::new_empty!(
14925                            StreamProcessorQueueInputEndOfStreamRequest,
14926                            fidl::encoding::DefaultFuchsiaResourceDialect
14927                        );
14928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14929                        let control_handle =
14930                            StreamProcessorControlHandle { inner: this.inner.clone() };
14931                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
14932                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14933
14934                            control_handle,
14935                        })
14936                    }
14937                    _ => Err(fidl::Error::UnknownOrdinal {
14938                        ordinal: header.ordinal,
14939                        protocol_name:
14940                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14941                    }),
14942                }))
14943            },
14944        )
14945    }
14946}
14947
14948/// Overview of operation:
14949///
14950/// 1. Create
14951///   * create via CodecFactory - see CodecFactory
14952///   * create via LicenseSession - see LicenseSession
14953/// 2. Get input constraints
14954///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
14955///     stream processor creation.
14956/// 3. Provide input buffers
14957///   * SetInputBufferPartialSettings()
14958/// 4. Deliver input data
14959///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
14960///     possibly working through all input packets repeatedly before...
14961/// 5. Get output constraints and format
14962///   * OnOutputConstraints()
14963///   * This is not sent until after at least one QueueInput* message is sent by
14964///     the client, even if the underlying processor behind the StreamProcessor
14965///     doesn't fundamentally need any input data to determine its output
14966///     constraints.  This server behavior prevents clients taking an incorrect
14967///     dependency on the output constraints showing up before input is
14968///     delivered.
14969///   * A client must tolerate this arriving as late as after substantial input
14970///     data has been delivered, including lots of input packet recycling via
14971///     OnFreeInputPacket().
14972///   * This message can arrive more than once before the first output data.
14973/// 6. Provide output buffers
14974///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
14975/// 7. Data flows, with optional EndOfStream
14976///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
14977///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
14978///
14979/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
14980/// very few capabilities) just in case the decoding SW has a vulnerability
14981/// which could be used to take over the StreamProcessor server.  Clients of the
14982/// stream processor interface using decoders and processing streams of separate
14983/// security contexts, to a greater extent than some other interfaces, need to
14984/// protect themselves against invalid server behavior, such as double-free of a
14985/// packet_index and any other invalid server behavior.  Having fed in
14986/// compressed data of one security context, don't place too much trust in a
14987/// single StreamProcessor instance to not mix data among any buffers that
14988/// StreamProcessor server has ever been told about.  Instead, create separate
14989/// StreamProcessor instances for use by security-separate client-side contexts.
14990/// While the picture for HW-based decoders looks somewhat different and is out
14991/// of scope of this paragraph, the client should always use separate
14992/// StreamProcessor instances for security-separate client-side contexts.
14993///
14994/// Descriptions of actions taken by methods of this protocol and the states of
14995/// things are given as if the methods are synchronously executed by the stream
14996/// processor server, but in reality, as is typical of FIDL interfaces, the
14997/// message processing is async.  The states described are to be read as the
14998/// state from the client's point of view unless otherwise stated.  Events
14999/// coming back from the server are of course delivered async, and a client that
15000/// processes more than one stream per StreamProcessor instance needs to care
15001/// whether a given event is from the current stream vs. some older
15002/// soon-to-be-gone stream.
15003///
15004/// The Sync() method's main purpose is to enable the client to robustly prevent
15005/// having both old and new buffers allocated in the system at the same time,
15006/// since media buffers can be significantly large, depending. The Sync() method
15007/// achieves this by only delivering it's response when all previous calls to
15008/// the StreamProcessor protocol have actually taken effect in the
15009/// StreamControl ordering domain. Sync() can also be used to wait for the
15010/// stream processor server to catch up if there's a possibility that a client
15011/// might otherwise get too far ahead of the StreamProcessor server, by for
15012/// example requesting creation of a large number of streams in a row.  It can
15013/// also be used during debugging to ensure that a stream processor server
15014/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
15015/// for correctness - only potentially required to de-overlap resource usage.
15016///
15017/// It's possible to re-use a StreamProcessor instance for another stream, and
15018/// doing so can sometimes skip over re-allocation of buffers. This can be a
15019/// useful thing to do for cases like seeking to a new location - at the
15020/// StreamProcessor interface that can look like switching to a new stream.
15021#[derive(Debug)]
15022pub enum StreamProcessorRequest {
15023    /// Permit the server to use OnStreamFailed() instead of the server just
15024    /// closing the whole StreamProcessor channel on stream failure.
15025    ///
15026    /// If the server hasn't seen this message by the time a stream fails, the
15027    /// server will close the StreamProcessor channel instead of sending
15028    /// OnStreamFailed().
15029    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
15030    /// This is the replacement for SetInputBufferSettings().
15031    ///
15032    /// When the client is using sysmem to allocate buffers, this message is
15033    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
15034    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
15035    /// the client-specified input settings and a BufferCollectionToken which
15036    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
15037    /// client and the StreamProcessor will be informed of the allocated buffers
15038    /// directly by sysmem via their BufferCollection channel (not via the
15039    /// StreamProcessor channel).
15040    ///
15041    /// The client must not QueueInput...() until after sysmem informs the client
15042    /// that buffer allocation has completed and was successful.
15043    ///
15044    /// The server should be prepared to see QueueInput...() before the server
15045    /// has necessarily heard from sysmem that the buffers are allocated - the
15046    /// server must tolerate either ordering, as the QueueInput...() and
15047    /// notification of sysmem allocation completion arrive on different
15048    /// channels, so the client having heard that allocation is complete doesn't
15049    /// mean the server knows that allocation is complete yet.  However, the
15050    /// server can expect that allocation is in fact complete and can expect to
15051    /// get the allocation information from sysmem immediately upon requesting
15052    /// the information from sysmem.
15053    SetInputBufferPartialSettings {
15054        input_settings: StreamBufferPartialSettings,
15055        control_handle: StreamProcessorControlHandle,
15056    },
15057    /// This is the replacement for SetOutputBufferSettings().
15058    ///
15059    /// When the client is using sysmem to allocate buffers, this message is
15060    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
15061    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
15062    /// with the client-specified output settings and a BufferCollectionToken
15063    /// which the StreamProcessor will use to convey constraints to sysmem.
15064    /// Both the client and the StreamProcessor will be informed of the
15065    /// allocated buffers directly by sysmem via their BufferCollection channel
15066    /// (not via the StreamProcessor channel).
15067    ///
15068    /// Configuring output buffers is _required_ after OnOutputConstraints() is
15069    /// received by the client with buffer_constraints_action_required true and
15070    /// stream_lifetime_ordinal equal to the client's current
15071    /// stream_lifetime_ordinal (even if there is an active stream), and is
15072    /// _permitted_ any time there is no current stream.
15073    ///
15074    /// Closing the current stream occurs on the StreamControl ordering domain,
15075    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15076    /// subsequent Sync() completion must be received by the client before the
15077    /// client knows that there's no longer a current stream.
15078    ///
15079    /// See also CompleteOutputBufferPartialSettings().
15080    SetOutputBufferPartialSettings {
15081        output_settings: StreamBufferPartialSettings,
15082        control_handle: StreamProcessorControlHandle,
15083    },
15084    /// After SetOutputBufferPartialSettings(), the server won't send
15085    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15086    /// OnOutputEndOfStream() until after the client sends
15087    /// CompleteOutputBufferPartialSettings().
15088    ///
15089    /// Some clients may be able to send
15090    /// CompleteOutputBufferPartialSettings() immediately after
15091    /// SetOutputBufferPartialSettings() - in that case the client needs to be
15092    /// prepared to receive output without knowing the buffer count or packet
15093    /// count yet - such clients may internally delay processing the received
15094    /// output until the client has heard from sysmem (which is when the client
15095    /// will learn the buffer count and packet count).
15096    ///
15097    /// Other clients may first wait for sysmem to allocate, prepare to receive
15098    /// output, and then send CompleteOutputBufferPartialSettings().
15099    CompleteOutputBufferPartialSettings {
15100        buffer_lifetime_ordinal: u64,
15101        control_handle: StreamProcessorControlHandle,
15102    },
15103    /// This message is optional.
15104    ///
15105    /// This message is only valid after QueueInputEndOfStream() for this stream.
15106    /// The stream_lifetime_ordinal input parameter must match the
15107    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15108    /// will close the channel.
15109    ///
15110    /// A client can use this message to flush through (not discard) the last
15111    /// input data of a stream so that the stream processor server generates
15112    /// corresponding output data for all the input data before the server moves
15113    /// on to the next stream, without forcing the client to wait for
15114    /// OnOutputEndOfStream() before queueing data of another stream.
15115    ///
15116    /// The difference between QueueInputEndOfStream() and
15117    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15118    /// from the client that there will not be any more input data for the
15119    /// stream (and this info is needed by some stream processors for the stream
15120    /// processor to ever emit the very last output data).  The
15121    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15122    /// later completely discarding the rest of the current stream by closing
15123    /// the current stream (with or without a stream switch).  In contrast,
15124    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15125    /// the previously-queued input data be processed including the logical
15126    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15127    /// before moving on to any newer stream - this essentially changes the
15128    /// close-stream handling from discard to flush-through for this stream
15129    /// only.
15130    ///
15131    /// A client using this message can start providing input data for a new
15132    /// stream without that causing discard of old stream data.  That's the
15133    /// purpose of this message - to allow a client to flush through (not
15134    /// discard) the old stream's last data (instead of the default when closing
15135    /// or switching streams which is discard).
15136    ///
15137    /// Because the old stream is not done processing yet and the old stream's
15138    /// data is not being discarded, the client must be prepared to continue to
15139    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15140    /// is done. The client will know the stream_lifetime_ordinal is done when
15141    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15142    /// closes.
15143    FlushEndOfStreamAndCloseStream {
15144        stream_lifetime_ordinal: u64,
15145        control_handle: StreamProcessorControlHandle,
15146    },
15147    /// This "closes" the current stream, leaving no current stream.  In
15148    /// addition, this message can optionally release input buffers or output
15149    /// buffers.
15150    ///
15151    /// If there has never been any active stream, the stream_lifetime_ordinal
15152    /// must be zero or the server will close the channel.  If there has been an
15153    /// active stream, the stream_lifetime_ordinal must be the most recent
15154    /// active stream whether that stream is still active or not.  Else the
15155    /// server will close the channel.
15156    ///
15157    /// Multiple of this message without any new active stream in between is not
15158    /// to be considered an error, which allows a client to use this message to
15159    /// close the current stream to stop wasting processing power on a stream the
15160    /// user no longer cares about, then later decide that buffers should be
15161    /// released and send this message again with release_input_buffers and/or
15162    /// release_output_buffers true to get the buffers released, if the client is
15163    /// interested in trying to avoid overlap in resource usage between old
15164    /// buffers and new buffers (not all clients are).
15165    ///
15166    /// See also Sync().
15167    CloseCurrentStream {
15168        stream_lifetime_ordinal: u64,
15169        release_input_buffers: bool,
15170        release_output_buffers: bool,
15171        control_handle: StreamProcessorControlHandle,
15172    },
15173    /// On completion, all previous StreamProcessor calls have done what they're
15174    /// going to do server-side, _except_ for processing of data queued using
15175    /// QueueInputPacket().
15176    ///
15177    /// The main purpose of this call is to enable the client to wait until
15178    /// CloseCurrentStream() with release_input_buffers and/or
15179    /// release_output_buffers set to true to take effect, before the client
15180    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15181    /// de-overlapping of resource usage can be worthwhile for media buffers
15182    /// which can consume resource types whose overall pools aren't necessarily
15183    /// vast in comparison to resources consumed.  Especially if a client is
15184    /// reconfiguring buffers multiple times.
15185    ///
15186    /// Note that Sync() prior to allocating new media buffers is not alone
15187    /// sufficient to achieve non-overlap of media buffer resource usage system
15188    /// wide, but it can be a useful part of achieving that.
15189    ///
15190    /// The Sync() transits the Output ordering domain and the StreamControl
15191    /// ordering domain, but not the InputData ordering domain.
15192    ///
15193    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15194    /// presently 10.  A client that stays <= 8 in-flight streams will
15195    /// comfortably stay under the limit of 10.  While the protocol permits
15196    /// repeated SetInputBufferSettings() and the like, a client that spams the
15197    /// channel can expect that the channel will just close if the server or the
15198    /// channel itself gets too far behind.
15199    Sync { responder: StreamProcessorSyncResponder },
15200    /// After the client is done with an output packet, the client needs to tell
15201    /// the stream processor that the output packet can be re-used for more
15202    /// output, via this method.
15203    ///
15204    /// It's not permitted to recycle an output packet that's already free with
15205    /// the stream processor server.  It's permitted but discouraged for a
15206    /// client to recycle an output packet that has been deallocated by an
15207    /// explicit or implicit output buffer de-configuration().  See
15208    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
15209    /// stale RecycleOutputPacket() calls.
15210    RecycleOutputPacket {
15211        available_output_packet: PacketHeader,
15212        control_handle: StreamProcessorControlHandle,
15213    },
15214    /// If the input format details are still the same as specified during
15215    /// StreamProcessor creation, this message is unnecessary and does not need
15216    /// to be sent.
15217    ///
15218    /// If the stream doesn't exist yet, this message creates the stream.
15219    ///
15220    /// The server won't send OnOutputConstraints() until after the client has
15221    /// sent at least one QueueInput* message.
15222    ///
15223    /// All servers must permit QueueInputFormatDetails() at the start of a
15224    /// stream without failing, as long as the new format is supported by the
15225    /// StreamProcessor instance.  Technically this allows for a server to only
15226    /// support the exact input format set during StreamProcessor creation, and
15227    /// that is by design.  A client that tries to switch formats and gets a
15228    /// StreamProcessor channel failure should try again one more time with a
15229    /// fresh StreamProcessor instance created with CodecFactory using the new
15230    /// input format during creation, before giving up.
15231    ///
15232    /// These format details override the format details specified during stream
15233    /// processor creation for this stream only.  The next stream will default
15234    /// back to the format details set during stream processor creation.
15235    ///
15236    /// This message is permitted at the start of the first stream (just like at
15237    /// the start of any stream).  The format specified need not match what was
15238    /// specified during stream processor creation, but if it doesn't match, the
15239    /// StreamProcessor channel might close as described above.
15240    QueueInputFormatDetails {
15241        stream_lifetime_ordinal: u64,
15242        format_details: FormatDetails,
15243        control_handle: StreamProcessorControlHandle,
15244    },
15245    /// This message queues input data to the stream processor for processing.
15246    ///
15247    /// If the stream doesn't exist yet, this message creates the new stream.
15248    ///
15249    /// The server won't send OnOutputConstraints() until after the client has
15250    /// sent at least one QueueInput* message.
15251    ///
15252    /// The client must continue to deliver input data via this message even if
15253    /// the stream processor has not yet generated the first OnOutputConstraints(),
15254    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
15255    /// previously-queued input packets.  The input data must continue as long
15256    /// as there are free packets to be assured that the server will ever
15257    /// generate the first OnOutputConstraints().
15258    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
15259    /// Inform the server that all QueueInputPacket() messages for this stream
15260    /// have been sent.
15261    ///
15262    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15263    /// or StreamProcessor channel closing), there will later be a corresponding
15264    /// OnOutputEndOfStream().
15265    ///
15266    /// The corresponding OnOutputEndOfStream() message will be generated only if
15267    /// the server finishes processing the stream before the server sees the
15268    /// client close the stream (such as by starting a new stream).  A way to
15269    /// force the server to finish the stream before closing is to use
15270    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
15271    /// new stream.  Another way to force the server to finish the stream before
15272    /// closing is to wait for the OnOutputEndOfStream() before taking any action
15273    /// that closes the stream.
15274    ///
15275    /// In addition to serving as an "EndOfStream" marker to make it obvious
15276    /// client-side when all input data has been processed, if a client never
15277    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
15278    /// result in all input data getting processed through to the output.  Some
15279    /// stream processors have some internally-delayed data which only gets
15280    /// pushed through by additional input data _or_ by this EndOfStream marker.
15281    /// In that sense, this message can be viewed as a flush-through at
15282    /// InputData domain level, but the flush-through only takes effect if the
15283    /// stream processor even gets that far before the stream is just closed at
15284    /// StreamControl domain level.  This message is not alone sufficient to act
15285    /// as an overall flush-through at StreamControl level. For that, send this
15286    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
15287    /// point it becomes possible to queue input data for a new stream without
15288    /// causing discard of this older stream's data), or wait for the
15289    /// OnOutputEndOfStream() before closing the current stream.
15290    ///
15291    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
15292    /// QueueInputEndOfStream() for this stream after the first
15293    /// QueueInputEndOfStream() for this stream, a server should close the
15294    /// StreamProcessor channel.
15295    QueueInputEndOfStream {
15296        stream_lifetime_ordinal: u64,
15297        control_handle: StreamProcessorControlHandle,
15298    },
15299}
15300
15301impl StreamProcessorRequest {
15302    #[allow(irrefutable_let_patterns)]
15303    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
15304        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
15305            Some((control_handle))
15306        } else {
15307            None
15308        }
15309    }
15310
15311    #[allow(irrefutable_let_patterns)]
15312    pub fn into_set_input_buffer_partial_settings(
15313        self,
15314    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15315        if let StreamProcessorRequest::SetInputBufferPartialSettings {
15316            input_settings,
15317            control_handle,
15318        } = self
15319        {
15320            Some((input_settings, control_handle))
15321        } else {
15322            None
15323        }
15324    }
15325
15326    #[allow(irrefutable_let_patterns)]
15327    pub fn into_set_output_buffer_partial_settings(
15328        self,
15329    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15330        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
15331            output_settings,
15332            control_handle,
15333        } = self
15334        {
15335            Some((output_settings, control_handle))
15336        } else {
15337            None
15338        }
15339    }
15340
15341    #[allow(irrefutable_let_patterns)]
15342    pub fn into_complete_output_buffer_partial_settings(
15343        self,
15344    ) -> Option<(u64, StreamProcessorControlHandle)> {
15345        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
15346            buffer_lifetime_ordinal,
15347            control_handle,
15348        } = self
15349        {
15350            Some((buffer_lifetime_ordinal, control_handle))
15351        } else {
15352            None
15353        }
15354    }
15355
15356    #[allow(irrefutable_let_patterns)]
15357    pub fn into_flush_end_of_stream_and_close_stream(
15358        self,
15359    ) -> Option<(u64, StreamProcessorControlHandle)> {
15360        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
15361            stream_lifetime_ordinal,
15362            control_handle,
15363        } = self
15364        {
15365            Some((stream_lifetime_ordinal, control_handle))
15366        } else {
15367            None
15368        }
15369    }
15370
15371    #[allow(irrefutable_let_patterns)]
15372    pub fn into_close_current_stream(
15373        self,
15374    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
15375        if let StreamProcessorRequest::CloseCurrentStream {
15376            stream_lifetime_ordinal,
15377            release_input_buffers,
15378            release_output_buffers,
15379            control_handle,
15380        } = self
15381        {
15382            Some((
15383                stream_lifetime_ordinal,
15384                release_input_buffers,
15385                release_output_buffers,
15386                control_handle,
15387            ))
15388        } else {
15389            None
15390        }
15391    }
15392
15393    #[allow(irrefutable_let_patterns)]
15394    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
15395        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
15396    }
15397
15398    #[allow(irrefutable_let_patterns)]
15399    pub fn into_recycle_output_packet(
15400        self,
15401    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
15402        if let StreamProcessorRequest::RecycleOutputPacket {
15403            available_output_packet,
15404            control_handle,
15405        } = self
15406        {
15407            Some((available_output_packet, control_handle))
15408        } else {
15409            None
15410        }
15411    }
15412
15413    #[allow(irrefutable_let_patterns)]
15414    pub fn into_queue_input_format_details(
15415        self,
15416    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
15417        if let StreamProcessorRequest::QueueInputFormatDetails {
15418            stream_lifetime_ordinal,
15419            format_details,
15420            control_handle,
15421        } = self
15422        {
15423            Some((stream_lifetime_ordinal, format_details, control_handle))
15424        } else {
15425            None
15426        }
15427    }
15428
15429    #[allow(irrefutable_let_patterns)]
15430    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
15431        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
15432            Some((packet, control_handle))
15433        } else {
15434            None
15435        }
15436    }
15437
15438    #[allow(irrefutable_let_patterns)]
15439    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
15440        if let StreamProcessorRequest::QueueInputEndOfStream {
15441            stream_lifetime_ordinal,
15442            control_handle,
15443        } = self
15444        {
15445            Some((stream_lifetime_ordinal, control_handle))
15446        } else {
15447            None
15448        }
15449    }
15450
15451    /// Name of the method defined in FIDL
15452    pub fn method_name(&self) -> &'static str {
15453        match *self {
15454            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
15455            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
15456                "set_input_buffer_partial_settings"
15457            }
15458            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
15459                "set_output_buffer_partial_settings"
15460            }
15461            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
15462                "complete_output_buffer_partial_settings"
15463            }
15464            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
15465                "flush_end_of_stream_and_close_stream"
15466            }
15467            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
15468            StreamProcessorRequest::Sync { .. } => "sync",
15469            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
15470            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
15471            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
15472            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
15473        }
15474    }
15475}
15476
15477#[derive(Debug, Clone)]
15478pub struct StreamProcessorControlHandle {
15479    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
15480}
15481
15482impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
15483    fn shutdown(&self) {
15484        self.inner.shutdown()
15485    }
15486    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15487        self.inner.shutdown_with_epitaph(status)
15488    }
15489
15490    fn is_closed(&self) -> bool {
15491        self.inner.channel().is_closed()
15492    }
15493    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
15494        self.inner.channel().on_closed()
15495    }
15496
15497    #[cfg(target_os = "fuchsia")]
15498    fn signal_peer(
15499        &self,
15500        clear_mask: zx::Signals,
15501        set_mask: zx::Signals,
15502    ) -> Result<(), zx_status::Status> {
15503        use fidl::Peered;
15504        self.inner.channel().signal_peer(clear_mask, set_mask)
15505    }
15506}
15507
15508impl StreamProcessorControlHandle {
15509    pub fn send_on_stream_failed(
15510        &self,
15511        mut stream_lifetime_ordinal: u64,
15512        mut error: StreamError,
15513    ) -> Result<(), fidl::Error> {
15514        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
15515            (stream_lifetime_ordinal, error),
15516            0,
15517            0x77ccf70bb061cf8e,
15518            fidl::encoding::DynamicFlags::empty(),
15519        )
15520    }
15521
15522    pub fn send_on_input_constraints(
15523        &self,
15524        mut input_constraints: &StreamBufferConstraints,
15525    ) -> Result<(), fidl::Error> {
15526        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
15527            (input_constraints,),
15528            0,
15529            0x211da9966a8ca0,
15530            fidl::encoding::DynamicFlags::empty(),
15531        )
15532    }
15533
15534    pub fn send_on_output_constraints(
15535        &self,
15536        mut output_config: &StreamOutputConstraints,
15537    ) -> Result<(), fidl::Error> {
15538        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
15539            (output_config,),
15540            0,
15541            0x40d8234504c170f3,
15542            fidl::encoding::DynamicFlags::empty(),
15543        )
15544    }
15545
15546    pub fn send_on_output_format(
15547        &self,
15548        mut output_format: &StreamOutputFormat,
15549    ) -> Result<(), fidl::Error> {
15550        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
15551            (output_format,),
15552            0,
15553            0x131b77ae120360bc,
15554            fidl::encoding::DynamicFlags::empty(),
15555        )
15556    }
15557
15558    pub fn send_on_output_packet(
15559        &self,
15560        mut output_packet: &Packet,
15561        mut error_detected_before: bool,
15562        mut error_detected_during: bool,
15563    ) -> Result<(), fidl::Error> {
15564        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
15565            (output_packet, error_detected_before, error_detected_during),
15566            0,
15567            0x5c2029be1090ce93,
15568            fidl::encoding::DynamicFlags::empty(),
15569        )
15570    }
15571
15572    pub fn send_on_output_end_of_stream(
15573        &self,
15574        mut stream_lifetime_ordinal: u64,
15575        mut error_detected_before: bool,
15576    ) -> Result<(), fidl::Error> {
15577        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
15578            (stream_lifetime_ordinal, error_detected_before),
15579            0,
15580            0x3bb65d237cfa50e6,
15581            fidl::encoding::DynamicFlags::empty(),
15582        )
15583    }
15584
15585    pub fn send_on_free_input_packet(
15586        &self,
15587        mut free_input_packet: &PacketHeader,
15588    ) -> Result<(), fidl::Error> {
15589        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
15590            (free_input_packet,),
15591            0,
15592            0xeef799b28708bbd,
15593            fidl::encoding::DynamicFlags::empty(),
15594        )
15595    }
15596}
15597
15598#[must_use = "FIDL methods require a response to be sent"]
15599#[derive(Debug)]
15600pub struct StreamProcessorSyncResponder {
15601    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
15602    tx_id: u32,
15603}
15604
15605/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
15606/// if the responder is dropped without sending a response, so that the client
15607/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15608impl std::ops::Drop for StreamProcessorSyncResponder {
15609    fn drop(&mut self) {
15610        self.control_handle.shutdown();
15611        // Safety: drops once, never accessed again
15612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15613    }
15614}
15615
15616impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
15617    type ControlHandle = StreamProcessorControlHandle;
15618
15619    fn control_handle(&self) -> &StreamProcessorControlHandle {
15620        &self.control_handle
15621    }
15622
15623    fn drop_without_shutdown(mut self) {
15624        // Safety: drops once, never accessed again due to mem::forget
15625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15626        // Prevent Drop from running (which would shut down the channel)
15627        std::mem::forget(self);
15628    }
15629}
15630
15631impl StreamProcessorSyncResponder {
15632    /// Sends a response to the FIDL transaction.
15633    ///
15634    /// Sets the channel to shutdown if an error occurs.
15635    pub fn send(self) -> Result<(), fidl::Error> {
15636        let _result = self.send_raw();
15637        if _result.is_err() {
15638            self.control_handle.shutdown();
15639        }
15640        self.drop_without_shutdown();
15641        _result
15642    }
15643
15644    /// Similar to "send" but does not shutdown the channel if an error occurs.
15645    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15646        let _result = self.send_raw();
15647        self.drop_without_shutdown();
15648        _result
15649    }
15650
15651    fn send_raw(&self) -> Result<(), fidl::Error> {
15652        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15653            (),
15654            self.tx_id,
15655            0x4b3e44300b0ec6aa,
15656            fidl::encoding::DynamicFlags::empty(),
15657        )
15658    }
15659}
15660
15661#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15662pub struct StreamSinkMarker;
15663
15664impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
15665    type Proxy = StreamSinkProxy;
15666    type RequestStream = StreamSinkRequestStream;
15667    #[cfg(target_os = "fuchsia")]
15668    type SynchronousProxy = StreamSinkSynchronousProxy;
15669
15670    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
15671}
15672
15673pub trait StreamSinkProxyInterface: Send + Sync {
15674    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15675    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
15676    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
15677    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
15678    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15679    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
15680    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
15681}
15682#[derive(Debug)]
15683#[cfg(target_os = "fuchsia")]
15684pub struct StreamSinkSynchronousProxy {
15685    client: fidl::client::sync::Client,
15686}
15687
15688#[cfg(target_os = "fuchsia")]
15689impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
15690    type Proxy = StreamSinkProxy;
15691    type Protocol = StreamSinkMarker;
15692
15693    fn from_channel(inner: fidl::Channel) -> Self {
15694        Self::new(inner)
15695    }
15696
15697    fn into_channel(self) -> fidl::Channel {
15698        self.client.into_channel()
15699    }
15700
15701    fn as_channel(&self) -> &fidl::Channel {
15702        self.client.as_channel()
15703    }
15704}
15705
15706#[cfg(target_os = "fuchsia")]
15707impl StreamSinkSynchronousProxy {
15708    pub fn new(channel: fidl::Channel) -> Self {
15709        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15710        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
15711    }
15712
15713    pub fn into_channel(self) -> fidl::Channel {
15714        self.client.into_channel()
15715    }
15716
15717    /// Waits until an event arrives and returns it. It is safe for other
15718    /// threads to make concurrent requests while waiting for an event.
15719    pub fn wait_for_event(
15720        &self,
15721        deadline: zx::MonotonicInstant,
15722    ) -> Result<StreamSinkEvent, fidl::Error> {
15723        StreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
15724    }
15725
15726    /// Sends a packet to the service. The response is sent when the service is
15727    /// done with the associated payload memory.
15728    ///
15729    /// `packet` must be valid for the current buffer set, otherwise the service
15730    /// will close the connection.
15731    pub fn r#send_packet(
15732        &self,
15733        mut packet: &StreamPacket,
15734        ___deadline: zx::MonotonicInstant,
15735    ) -> Result<(), fidl::Error> {
15736        let _response =
15737            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
15738                (packet,),
15739                0x67cddd607442775f,
15740                fidl::encoding::DynamicFlags::empty(),
15741                ___deadline,
15742            )?;
15743        Ok(_response)
15744    }
15745
15746    /// Sends a packet to the service. This interface doesn't define how the
15747    /// client knows when the sink is done with the associated payload memory.
15748    /// The inheriting interface must define that.
15749    ///
15750    /// `packet` must be valid for the current buffer set, otherwise the service
15751    /// will close the connection.
15752    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15753        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15754            (packet,),
15755            0x8d9b8b413ceba9d,
15756            fidl::encoding::DynamicFlags::empty(),
15757        )
15758    }
15759
15760    /// Indicates the stream has ended. The precise semantics of this method are
15761    /// determined by the inheriting interface.
15762    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15763        self.client.send::<fidl::encoding::EmptyPayload>(
15764            (),
15765            0x6180fd6f7e793b71,
15766            fidl::encoding::DynamicFlags::empty(),
15767        )
15768    }
15769
15770    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15771    /// and not yet released. The response is sent after all packets have been
15772    /// released.
15773    pub fn r#discard_all_packets(
15774        &self,
15775        ___deadline: zx::MonotonicInstant,
15776    ) -> Result<(), fidl::Error> {
15777        let _response =
15778            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
15779                (),
15780                0x6f4dad7af2917665,
15781                fidl::encoding::DynamicFlags::empty(),
15782                ___deadline,
15783            )?;
15784        Ok(_response)
15785    }
15786
15787    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15788    /// and not yet released.
15789    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15790        self.client.send::<fidl::encoding::EmptyPayload>(
15791            (),
15792            0x50d36d0d23081bc4,
15793            fidl::encoding::DynamicFlags::empty(),
15794        )
15795    }
15796}
15797
15798#[cfg(target_os = "fuchsia")]
15799impl From<StreamSinkSynchronousProxy> for zx::Handle {
15800    fn from(value: StreamSinkSynchronousProxy) -> Self {
15801        value.into_channel().into()
15802    }
15803}
15804
15805#[cfg(target_os = "fuchsia")]
15806impl From<fidl::Channel> for StreamSinkSynchronousProxy {
15807    fn from(value: fidl::Channel) -> Self {
15808        Self::new(value)
15809    }
15810}
15811
15812#[cfg(target_os = "fuchsia")]
15813impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
15814    type Protocol = StreamSinkMarker;
15815
15816    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
15817        Self::new(value.into_channel())
15818    }
15819}
15820
15821#[derive(Debug, Clone)]
15822pub struct StreamSinkProxy {
15823    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
15824}
15825
15826impl fidl::endpoints::Proxy for StreamSinkProxy {
15827    type Protocol = StreamSinkMarker;
15828
15829    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
15830        Self::new(inner)
15831    }
15832
15833    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
15834        self.client.into_channel().map_err(|client| Self { client })
15835    }
15836
15837    fn as_channel(&self) -> &::fidl::AsyncChannel {
15838        self.client.as_channel()
15839    }
15840}
15841
15842impl StreamSinkProxy {
15843    /// Create a new Proxy for fuchsia.media/StreamSink.
15844    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
15845        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15846        Self { client: fidl::client::Client::new(channel, protocol_name) }
15847    }
15848
15849    /// Get a Stream of events from the remote end of the protocol.
15850    ///
15851    /// # Panics
15852    ///
15853    /// Panics if the event stream was already taken.
15854    pub fn take_event_stream(&self) -> StreamSinkEventStream {
15855        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
15856    }
15857
15858    /// Sends a packet to the service. The response is sent when the service is
15859    /// done with the associated payload memory.
15860    ///
15861    /// `packet` must be valid for the current buffer set, otherwise the service
15862    /// will close the connection.
15863    pub fn r#send_packet(
15864        &self,
15865        mut packet: &StreamPacket,
15866    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15867        StreamSinkProxyInterface::r#send_packet(self, packet)
15868    }
15869
15870    /// Sends a packet to the service. This interface doesn't define how the
15871    /// client knows when the sink is done with the associated payload memory.
15872    /// The inheriting interface must define that.
15873    ///
15874    /// `packet` must be valid for the current buffer set, otherwise the service
15875    /// will close the connection.
15876    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15877        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
15878    }
15879
15880    /// Indicates the stream has ended. The precise semantics of this method are
15881    /// determined by the inheriting interface.
15882    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15883        StreamSinkProxyInterface::r#end_of_stream(self)
15884    }
15885
15886    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15887    /// and not yet released. The response is sent after all packets have been
15888    /// released.
15889    pub fn r#discard_all_packets(
15890        &self,
15891    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15892        StreamSinkProxyInterface::r#discard_all_packets(self)
15893    }
15894
15895    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15896    /// and not yet released.
15897    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15898        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
15899    }
15900}
15901
15902impl StreamSinkProxyInterface for StreamSinkProxy {
15903    type SendPacketResponseFut =
15904        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15905    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
15906        fn _decode(
15907            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15908        ) -> Result<(), fidl::Error> {
15909            let _response = fidl::client::decode_transaction_body::<
15910                fidl::encoding::EmptyPayload,
15911                fidl::encoding::DefaultFuchsiaResourceDialect,
15912                0x67cddd607442775f,
15913            >(_buf?)?;
15914            Ok(_response)
15915        }
15916        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
15917            (packet,),
15918            0x67cddd607442775f,
15919            fidl::encoding::DynamicFlags::empty(),
15920            _decode,
15921        )
15922    }
15923
15924    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15925        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15926            (packet,),
15927            0x8d9b8b413ceba9d,
15928            fidl::encoding::DynamicFlags::empty(),
15929        )
15930    }
15931
15932    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15933        self.client.send::<fidl::encoding::EmptyPayload>(
15934            (),
15935            0x6180fd6f7e793b71,
15936            fidl::encoding::DynamicFlags::empty(),
15937        )
15938    }
15939
15940    type DiscardAllPacketsResponseFut =
15941        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15942    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
15943        fn _decode(
15944            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15945        ) -> Result<(), fidl::Error> {
15946            let _response = fidl::client::decode_transaction_body::<
15947                fidl::encoding::EmptyPayload,
15948                fidl::encoding::DefaultFuchsiaResourceDialect,
15949                0x6f4dad7af2917665,
15950            >(_buf?)?;
15951            Ok(_response)
15952        }
15953        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
15954            (),
15955            0x6f4dad7af2917665,
15956            fidl::encoding::DynamicFlags::empty(),
15957            _decode,
15958        )
15959    }
15960
15961    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15962        self.client.send::<fidl::encoding::EmptyPayload>(
15963            (),
15964            0x50d36d0d23081bc4,
15965            fidl::encoding::DynamicFlags::empty(),
15966        )
15967    }
15968}
15969
15970pub struct StreamSinkEventStream {
15971    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
15972}
15973
15974impl std::marker::Unpin for StreamSinkEventStream {}
15975
15976impl futures::stream::FusedStream for StreamSinkEventStream {
15977    fn is_terminated(&self) -> bool {
15978        self.event_receiver.is_terminated()
15979    }
15980}
15981
15982impl futures::Stream for StreamSinkEventStream {
15983    type Item = Result<StreamSinkEvent, fidl::Error>;
15984
15985    fn poll_next(
15986        mut self: std::pin::Pin<&mut Self>,
15987        cx: &mut std::task::Context<'_>,
15988    ) -> std::task::Poll<Option<Self::Item>> {
15989        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15990            &mut self.event_receiver,
15991            cx
15992        )?) {
15993            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
15994            None => std::task::Poll::Ready(None),
15995        }
15996    }
15997}
15998
15999#[derive(Debug)]
16000pub enum StreamSinkEvent {}
16001
16002impl StreamSinkEvent {
16003    /// Decodes a message buffer as a [`StreamSinkEvent`].
16004    fn decode(
16005        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16006    ) -> Result<StreamSinkEvent, fidl::Error> {
16007        let (bytes, _handles) = buf.split_mut();
16008        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16009        debug_assert_eq!(tx_header.tx_id, 0);
16010        match tx_header.ordinal {
16011            _ => Err(fidl::Error::UnknownOrdinal {
16012                ordinal: tx_header.ordinal,
16013                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16014            }),
16015        }
16016    }
16017}
16018
16019/// A Stream of incoming requests for fuchsia.media/StreamSink.
16020pub struct StreamSinkRequestStream {
16021    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16022    is_terminated: bool,
16023}
16024
16025impl std::marker::Unpin for StreamSinkRequestStream {}
16026
16027impl futures::stream::FusedStream for StreamSinkRequestStream {
16028    fn is_terminated(&self) -> bool {
16029        self.is_terminated
16030    }
16031}
16032
16033impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
16034    type Protocol = StreamSinkMarker;
16035    type ControlHandle = StreamSinkControlHandle;
16036
16037    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16038        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16039    }
16040
16041    fn control_handle(&self) -> Self::ControlHandle {
16042        StreamSinkControlHandle { inner: self.inner.clone() }
16043    }
16044
16045    fn into_inner(
16046        self,
16047    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16048    {
16049        (self.inner, self.is_terminated)
16050    }
16051
16052    fn from_inner(
16053        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16054        is_terminated: bool,
16055    ) -> Self {
16056        Self { inner, is_terminated }
16057    }
16058}
16059
16060impl futures::Stream for StreamSinkRequestStream {
16061    type Item = Result<StreamSinkRequest, fidl::Error>;
16062
16063    fn poll_next(
16064        mut self: std::pin::Pin<&mut Self>,
16065        cx: &mut std::task::Context<'_>,
16066    ) -> std::task::Poll<Option<Self::Item>> {
16067        let this = &mut *self;
16068        if this.inner.check_shutdown(cx) {
16069            this.is_terminated = true;
16070            return std::task::Poll::Ready(None);
16071        }
16072        if this.is_terminated {
16073            panic!("polled StreamSinkRequestStream after completion");
16074        }
16075        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16076            |bytes, handles| {
16077                match this.inner.channel().read_etc(cx, bytes, handles) {
16078                    std::task::Poll::Ready(Ok(())) => {}
16079                    std::task::Poll::Pending => return std::task::Poll::Pending,
16080                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16081                        this.is_terminated = true;
16082                        return std::task::Poll::Ready(None);
16083                    }
16084                    std::task::Poll::Ready(Err(e)) => {
16085                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16086                            e.into(),
16087                        ))));
16088                    }
16089                }
16090
16091                // A message has been received from the channel
16092                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16093
16094                std::task::Poll::Ready(Some(match header.ordinal {
16095                    0x67cddd607442775f => {
16096                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16097                        let mut req = fidl::new_empty!(
16098                            StreamSinkSendPacketRequest,
16099                            fidl::encoding::DefaultFuchsiaResourceDialect
16100                        );
16101                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16102                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16103                        Ok(StreamSinkRequest::SendPacket {
16104                            packet: req.packet,
16105
16106                            responder: StreamSinkSendPacketResponder {
16107                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16108                                tx_id: header.tx_id,
16109                            },
16110                        })
16111                    }
16112                    0x8d9b8b413ceba9d => {
16113                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16114                        let mut req = fidl::new_empty!(
16115                            StreamSinkSendPacketNoReplyRequest,
16116                            fidl::encoding::DefaultFuchsiaResourceDialect
16117                        );
16118                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
16119                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16120                        Ok(StreamSinkRequest::SendPacketNoReply {
16121                            packet: req.packet,
16122
16123                            control_handle,
16124                        })
16125                    }
16126                    0x6180fd6f7e793b71 => {
16127                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16128                        let mut req = fidl::new_empty!(
16129                            fidl::encoding::EmptyPayload,
16130                            fidl::encoding::DefaultFuchsiaResourceDialect
16131                        );
16132                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16133                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16134                        Ok(StreamSinkRequest::EndOfStream { control_handle })
16135                    }
16136                    0x6f4dad7af2917665 => {
16137                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16138                        let mut req = fidl::new_empty!(
16139                            fidl::encoding::EmptyPayload,
16140                            fidl::encoding::DefaultFuchsiaResourceDialect
16141                        );
16142                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16143                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16144                        Ok(StreamSinkRequest::DiscardAllPackets {
16145                            responder: StreamSinkDiscardAllPacketsResponder {
16146                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16147                                tx_id: header.tx_id,
16148                            },
16149                        })
16150                    }
16151                    0x50d36d0d23081bc4 => {
16152                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16153                        let mut req = fidl::new_empty!(
16154                            fidl::encoding::EmptyPayload,
16155                            fidl::encoding::DefaultFuchsiaResourceDialect
16156                        );
16157                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16158                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16159                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
16160                    }
16161                    _ => Err(fidl::Error::UnknownOrdinal {
16162                        ordinal: header.ordinal,
16163                        protocol_name:
16164                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16165                    }),
16166                }))
16167            },
16168        )
16169    }
16170}
16171
16172/// Consumes a stream of packets. This interface is typically inherited along
16173/// with `StreamBufferSet` to enable the transport of elementary streams from
16174/// clients to services.
16175#[derive(Debug)]
16176pub enum StreamSinkRequest {
16177    /// Sends a packet to the service. The response is sent when the service is
16178    /// done with the associated payload memory.
16179    ///
16180    /// `packet` must be valid for the current buffer set, otherwise the service
16181    /// will close the connection.
16182    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
16183    /// Sends a packet to the service. This interface doesn't define how the
16184    /// client knows when the sink is done with the associated payload memory.
16185    /// The inheriting interface must define that.
16186    ///
16187    /// `packet` must be valid for the current buffer set, otherwise the service
16188    /// will close the connection.
16189    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
16190    /// Indicates the stream has ended. The precise semantics of this method are
16191    /// determined by the inheriting interface.
16192    EndOfStream { control_handle: StreamSinkControlHandle },
16193    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16194    /// and not yet released. The response is sent after all packets have been
16195    /// released.
16196    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
16197    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16198    /// and not yet released.
16199    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
16200}
16201
16202impl StreamSinkRequest {
16203    #[allow(irrefutable_let_patterns)]
16204    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
16205        if let StreamSinkRequest::SendPacket { packet, responder } = self {
16206            Some((packet, responder))
16207        } else {
16208            None
16209        }
16210    }
16211
16212    #[allow(irrefutable_let_patterns)]
16213    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
16214        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
16215            Some((packet, control_handle))
16216        } else {
16217            None
16218        }
16219    }
16220
16221    #[allow(irrefutable_let_patterns)]
16222    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
16223        if let StreamSinkRequest::EndOfStream { control_handle } = self {
16224            Some((control_handle))
16225        } else {
16226            None
16227        }
16228    }
16229
16230    #[allow(irrefutable_let_patterns)]
16231    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
16232        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
16233            Some((responder))
16234        } else {
16235            None
16236        }
16237    }
16238
16239    #[allow(irrefutable_let_patterns)]
16240    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
16241        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
16242            Some((control_handle))
16243        } else {
16244            None
16245        }
16246    }
16247
16248    /// Name of the method defined in FIDL
16249    pub fn method_name(&self) -> &'static str {
16250        match *self {
16251            StreamSinkRequest::SendPacket { .. } => "send_packet",
16252            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
16253            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
16254            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
16255            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16256        }
16257    }
16258}
16259
16260#[derive(Debug, Clone)]
16261pub struct StreamSinkControlHandle {
16262    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16263}
16264
16265impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
16266    fn shutdown(&self) {
16267        self.inner.shutdown()
16268    }
16269    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16270        self.inner.shutdown_with_epitaph(status)
16271    }
16272
16273    fn is_closed(&self) -> bool {
16274        self.inner.channel().is_closed()
16275    }
16276    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16277        self.inner.channel().on_closed()
16278    }
16279
16280    #[cfg(target_os = "fuchsia")]
16281    fn signal_peer(
16282        &self,
16283        clear_mask: zx::Signals,
16284        set_mask: zx::Signals,
16285    ) -> Result<(), zx_status::Status> {
16286        use fidl::Peered;
16287        self.inner.channel().signal_peer(clear_mask, set_mask)
16288    }
16289}
16290
16291impl StreamSinkControlHandle {}
16292
16293#[must_use = "FIDL methods require a response to be sent"]
16294#[derive(Debug)]
16295pub struct StreamSinkSendPacketResponder {
16296    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16297    tx_id: u32,
16298}
16299
16300/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16301/// if the responder is dropped without sending a response, so that the client
16302/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16303impl std::ops::Drop for StreamSinkSendPacketResponder {
16304    fn drop(&mut self) {
16305        self.control_handle.shutdown();
16306        // Safety: drops once, never accessed again
16307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16308    }
16309}
16310
16311impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
16312    type ControlHandle = StreamSinkControlHandle;
16313
16314    fn control_handle(&self) -> &StreamSinkControlHandle {
16315        &self.control_handle
16316    }
16317
16318    fn drop_without_shutdown(mut self) {
16319        // Safety: drops once, never accessed again due to mem::forget
16320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16321        // Prevent Drop from running (which would shut down the channel)
16322        std::mem::forget(self);
16323    }
16324}
16325
16326impl StreamSinkSendPacketResponder {
16327    /// Sends a response to the FIDL transaction.
16328    ///
16329    /// Sets the channel to shutdown if an error occurs.
16330    pub fn send(self) -> Result<(), fidl::Error> {
16331        let _result = self.send_raw();
16332        if _result.is_err() {
16333            self.control_handle.shutdown();
16334        }
16335        self.drop_without_shutdown();
16336        _result
16337    }
16338
16339    /// Similar to "send" but does not shutdown the channel if an error occurs.
16340    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16341        let _result = self.send_raw();
16342        self.drop_without_shutdown();
16343        _result
16344    }
16345
16346    fn send_raw(&self) -> Result<(), fidl::Error> {
16347        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16348            (),
16349            self.tx_id,
16350            0x67cddd607442775f,
16351            fidl::encoding::DynamicFlags::empty(),
16352        )
16353    }
16354}
16355
16356#[must_use = "FIDL methods require a response to be sent"]
16357#[derive(Debug)]
16358pub struct StreamSinkDiscardAllPacketsResponder {
16359    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16360    tx_id: u32,
16361}
16362
16363/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16364/// if the responder is dropped without sending a response, so that the client
16365/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16366impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
16367    fn drop(&mut self) {
16368        self.control_handle.shutdown();
16369        // Safety: drops once, never accessed again
16370        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16371    }
16372}
16373
16374impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
16375    type ControlHandle = StreamSinkControlHandle;
16376
16377    fn control_handle(&self) -> &StreamSinkControlHandle {
16378        &self.control_handle
16379    }
16380
16381    fn drop_without_shutdown(mut self) {
16382        // Safety: drops once, never accessed again due to mem::forget
16383        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16384        // Prevent Drop from running (which would shut down the channel)
16385        std::mem::forget(self);
16386    }
16387}
16388
16389impl StreamSinkDiscardAllPacketsResponder {
16390    /// Sends a response to the FIDL transaction.
16391    ///
16392    /// Sets the channel to shutdown if an error occurs.
16393    pub fn send(self) -> Result<(), fidl::Error> {
16394        let _result = self.send_raw();
16395        if _result.is_err() {
16396            self.control_handle.shutdown();
16397        }
16398        self.drop_without_shutdown();
16399        _result
16400    }
16401
16402    /// Similar to "send" but does not shutdown the channel if an error occurs.
16403    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16404        let _result = self.send_raw();
16405        self.drop_without_shutdown();
16406        _result
16407    }
16408
16409    fn send_raw(&self) -> Result<(), fidl::Error> {
16410        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16411            (),
16412            self.tx_id,
16413            0x6f4dad7af2917665,
16414            fidl::encoding::DynamicFlags::empty(),
16415        )
16416    }
16417}
16418
16419#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16420pub struct StreamSourceMarker;
16421
16422impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
16423    type Proxy = StreamSourceProxy;
16424    type RequestStream = StreamSourceRequestStream;
16425    #[cfg(target_os = "fuchsia")]
16426    type SynchronousProxy = StreamSourceSynchronousProxy;
16427
16428    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
16429}
16430
16431pub trait StreamSourceProxyInterface: Send + Sync {
16432    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
16433    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16434    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
16435    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
16436}
16437#[derive(Debug)]
16438#[cfg(target_os = "fuchsia")]
16439pub struct StreamSourceSynchronousProxy {
16440    client: fidl::client::sync::Client,
16441}
16442
16443#[cfg(target_os = "fuchsia")]
16444impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
16445    type Proxy = StreamSourceProxy;
16446    type Protocol = StreamSourceMarker;
16447
16448    fn from_channel(inner: fidl::Channel) -> Self {
16449        Self::new(inner)
16450    }
16451
16452    fn into_channel(self) -> fidl::Channel {
16453        self.client.into_channel()
16454    }
16455
16456    fn as_channel(&self) -> &fidl::Channel {
16457        self.client.as_channel()
16458    }
16459}
16460
16461#[cfg(target_os = "fuchsia")]
16462impl StreamSourceSynchronousProxy {
16463    pub fn new(channel: fidl::Channel) -> Self {
16464        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16465        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
16466    }
16467
16468    pub fn into_channel(self) -> fidl::Channel {
16469        self.client.into_channel()
16470    }
16471
16472    /// Waits until an event arrives and returns it. It is safe for other
16473    /// threads to make concurrent requests while waiting for an event.
16474    pub fn wait_for_event(
16475        &self,
16476        deadline: zx::MonotonicInstant,
16477    ) -> Result<StreamSourceEvent, fidl::Error> {
16478        StreamSourceEvent::decode(self.client.wait_for_event(deadline)?)
16479    }
16480
16481    /// Releases payload memory associated with a packet previously delivered
16482    /// via `OnPacketProduced`.
16483    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16484        self.client.send::<StreamSourceReleasePacketRequest>(
16485            (packet,),
16486            0x7a7b57f0f7d9e4bb,
16487            fidl::encoding::DynamicFlags::empty(),
16488        )
16489    }
16490
16491    pub fn r#discard_all_packets(
16492        &self,
16493        ___deadline: zx::MonotonicInstant,
16494    ) -> Result<(), fidl::Error> {
16495        let _response =
16496            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
16497                (),
16498                0x27afd605e97b09d2,
16499                fidl::encoding::DynamicFlags::empty(),
16500                ___deadline,
16501            )?;
16502        Ok(_response)
16503    }
16504
16505    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16506        self.client.send::<fidl::encoding::EmptyPayload>(
16507            (),
16508            0x35f9d721e905b831,
16509            fidl::encoding::DynamicFlags::empty(),
16510        )
16511    }
16512}
16513
16514#[cfg(target_os = "fuchsia")]
16515impl From<StreamSourceSynchronousProxy> for zx::Handle {
16516    fn from(value: StreamSourceSynchronousProxy) -> Self {
16517        value.into_channel().into()
16518    }
16519}
16520
16521#[cfg(target_os = "fuchsia")]
16522impl From<fidl::Channel> for StreamSourceSynchronousProxy {
16523    fn from(value: fidl::Channel) -> Self {
16524        Self::new(value)
16525    }
16526}
16527
16528#[cfg(target_os = "fuchsia")]
16529impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
16530    type Protocol = StreamSourceMarker;
16531
16532    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
16533        Self::new(value.into_channel())
16534    }
16535}
16536
16537#[derive(Debug, Clone)]
16538pub struct StreamSourceProxy {
16539    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
16540}
16541
16542impl fidl::endpoints::Proxy for StreamSourceProxy {
16543    type Protocol = StreamSourceMarker;
16544
16545    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
16546        Self::new(inner)
16547    }
16548
16549    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
16550        self.client.into_channel().map_err(|client| Self { client })
16551    }
16552
16553    fn as_channel(&self) -> &::fidl::AsyncChannel {
16554        self.client.as_channel()
16555    }
16556}
16557
16558impl StreamSourceProxy {
16559    /// Create a new Proxy for fuchsia.media/StreamSource.
16560    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
16561        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16562        Self { client: fidl::client::Client::new(channel, protocol_name) }
16563    }
16564
16565    /// Get a Stream of events from the remote end of the protocol.
16566    ///
16567    /// # Panics
16568    ///
16569    /// Panics if the event stream was already taken.
16570    pub fn take_event_stream(&self) -> StreamSourceEventStream {
16571        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
16572    }
16573
16574    /// Releases payload memory associated with a packet previously delivered
16575    /// via `OnPacketProduced`.
16576    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16577        StreamSourceProxyInterface::r#release_packet(self, packet)
16578    }
16579
16580    pub fn r#discard_all_packets(
16581        &self,
16582    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16583        StreamSourceProxyInterface::r#discard_all_packets(self)
16584    }
16585
16586    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16587        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
16588    }
16589}
16590
16591impl StreamSourceProxyInterface for StreamSourceProxy {
16592    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16593        self.client.send::<StreamSourceReleasePacketRequest>(
16594            (packet,),
16595            0x7a7b57f0f7d9e4bb,
16596            fidl::encoding::DynamicFlags::empty(),
16597        )
16598    }
16599
16600    type DiscardAllPacketsResponseFut =
16601        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16602    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16603        fn _decode(
16604            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16605        ) -> Result<(), fidl::Error> {
16606            let _response = fidl::client::decode_transaction_body::<
16607                fidl::encoding::EmptyPayload,
16608                fidl::encoding::DefaultFuchsiaResourceDialect,
16609                0x27afd605e97b09d2,
16610            >(_buf?)?;
16611            Ok(_response)
16612        }
16613        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16614            (),
16615            0x27afd605e97b09d2,
16616            fidl::encoding::DynamicFlags::empty(),
16617            _decode,
16618        )
16619    }
16620
16621    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16622        self.client.send::<fidl::encoding::EmptyPayload>(
16623            (),
16624            0x35f9d721e905b831,
16625            fidl::encoding::DynamicFlags::empty(),
16626        )
16627    }
16628}
16629
16630pub struct StreamSourceEventStream {
16631    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16632}
16633
16634impl std::marker::Unpin for StreamSourceEventStream {}
16635
16636impl futures::stream::FusedStream for StreamSourceEventStream {
16637    fn is_terminated(&self) -> bool {
16638        self.event_receiver.is_terminated()
16639    }
16640}
16641
16642impl futures::Stream for StreamSourceEventStream {
16643    type Item = Result<StreamSourceEvent, fidl::Error>;
16644
16645    fn poll_next(
16646        mut self: std::pin::Pin<&mut Self>,
16647        cx: &mut std::task::Context<'_>,
16648    ) -> std::task::Poll<Option<Self::Item>> {
16649        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16650            &mut self.event_receiver,
16651            cx
16652        )?) {
16653            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
16654            None => std::task::Poll::Ready(None),
16655        }
16656    }
16657}
16658
16659#[derive(Debug)]
16660pub enum StreamSourceEvent {
16661    OnPacketProduced { packet: StreamPacket },
16662    OnEndOfStream {},
16663}
16664
16665impl StreamSourceEvent {
16666    #[allow(irrefutable_let_patterns)]
16667    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
16668        if let StreamSourceEvent::OnPacketProduced { packet } = self {
16669            Some((packet))
16670        } else {
16671            None
16672        }
16673    }
16674    #[allow(irrefutable_let_patterns)]
16675    pub fn into_on_end_of_stream(self) -> Option<()> {
16676        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
16677    }
16678
16679    /// Decodes a message buffer as a [`StreamSourceEvent`].
16680    fn decode(
16681        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16682    ) -> Result<StreamSourceEvent, fidl::Error> {
16683        let (bytes, _handles) = buf.split_mut();
16684        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16685        debug_assert_eq!(tx_header.tx_id, 0);
16686        match tx_header.ordinal {
16687            0x6bbe69746a3c8bd9 => {
16688                let mut out = fidl::new_empty!(
16689                    StreamSourceOnPacketProducedRequest,
16690                    fidl::encoding::DefaultFuchsiaResourceDialect
16691                );
16692                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16693                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
16694            }
16695            0x550e69b41d03e2c2 => {
16696                let mut out = fidl::new_empty!(
16697                    fidl::encoding::EmptyPayload,
16698                    fidl::encoding::DefaultFuchsiaResourceDialect
16699                );
16700                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
16701                Ok((StreamSourceEvent::OnEndOfStream {}))
16702            }
16703            _ => Err(fidl::Error::UnknownOrdinal {
16704                ordinal: tx_header.ordinal,
16705                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16706            }),
16707        }
16708    }
16709}
16710
16711/// A Stream of incoming requests for fuchsia.media/StreamSource.
16712pub struct StreamSourceRequestStream {
16713    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16714    is_terminated: bool,
16715}
16716
16717impl std::marker::Unpin for StreamSourceRequestStream {}
16718
16719impl futures::stream::FusedStream for StreamSourceRequestStream {
16720    fn is_terminated(&self) -> bool {
16721        self.is_terminated
16722    }
16723}
16724
16725impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
16726    type Protocol = StreamSourceMarker;
16727    type ControlHandle = StreamSourceControlHandle;
16728
16729    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16730        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16731    }
16732
16733    fn control_handle(&self) -> Self::ControlHandle {
16734        StreamSourceControlHandle { inner: self.inner.clone() }
16735    }
16736
16737    fn into_inner(
16738        self,
16739    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16740    {
16741        (self.inner, self.is_terminated)
16742    }
16743
16744    fn from_inner(
16745        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16746        is_terminated: bool,
16747    ) -> Self {
16748        Self { inner, is_terminated }
16749    }
16750}
16751
16752impl futures::Stream for StreamSourceRequestStream {
16753    type Item = Result<StreamSourceRequest, fidl::Error>;
16754
16755    fn poll_next(
16756        mut self: std::pin::Pin<&mut Self>,
16757        cx: &mut std::task::Context<'_>,
16758    ) -> std::task::Poll<Option<Self::Item>> {
16759        let this = &mut *self;
16760        if this.inner.check_shutdown(cx) {
16761            this.is_terminated = true;
16762            return std::task::Poll::Ready(None);
16763        }
16764        if this.is_terminated {
16765            panic!("polled StreamSourceRequestStream after completion");
16766        }
16767        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16768            |bytes, handles| {
16769                match this.inner.channel().read_etc(cx, bytes, handles) {
16770                    std::task::Poll::Ready(Ok(())) => {}
16771                    std::task::Poll::Pending => return std::task::Poll::Pending,
16772                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16773                        this.is_terminated = true;
16774                        return std::task::Poll::Ready(None);
16775                    }
16776                    std::task::Poll::Ready(Err(e)) => {
16777                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16778                            e.into(),
16779                        ))));
16780                    }
16781                }
16782
16783                // A message has been received from the channel
16784                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16785
16786                std::task::Poll::Ready(Some(match header.ordinal {
16787                    0x7a7b57f0f7d9e4bb => {
16788                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16789                        let mut req = fidl::new_empty!(
16790                            StreamSourceReleasePacketRequest,
16791                            fidl::encoding::DefaultFuchsiaResourceDialect
16792                        );
16793                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
16794                        let control_handle =
16795                            StreamSourceControlHandle { inner: this.inner.clone() };
16796                        Ok(StreamSourceRequest::ReleasePacket {
16797                            packet: req.packet,
16798
16799                            control_handle,
16800                        })
16801                    }
16802                    0x27afd605e97b09d2 => {
16803                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16804                        let mut req = fidl::new_empty!(
16805                            fidl::encoding::EmptyPayload,
16806                            fidl::encoding::DefaultFuchsiaResourceDialect
16807                        );
16808                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16809                        let control_handle =
16810                            StreamSourceControlHandle { inner: this.inner.clone() };
16811                        Ok(StreamSourceRequest::DiscardAllPackets {
16812                            responder: StreamSourceDiscardAllPacketsResponder {
16813                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16814                                tx_id: header.tx_id,
16815                            },
16816                        })
16817                    }
16818                    0x35f9d721e905b831 => {
16819                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16820                        let mut req = fidl::new_empty!(
16821                            fidl::encoding::EmptyPayload,
16822                            fidl::encoding::DefaultFuchsiaResourceDialect
16823                        );
16824                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16825                        let control_handle =
16826                            StreamSourceControlHandle { inner: this.inner.clone() };
16827                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
16828                    }
16829                    _ => Err(fidl::Error::UnknownOrdinal {
16830                        ordinal: header.ordinal,
16831                        protocol_name:
16832                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16833                    }),
16834                }))
16835            },
16836        )
16837    }
16838}
16839
16840/// Produces a stream of packets. This interface is typically inherited along
16841/// with `StreamBufferSet` to enable the transport of elementary streams from
16842/// services to clients.
16843#[derive(Debug)]
16844pub enum StreamSourceRequest {
16845    /// Releases payload memory associated with a packet previously delivered
16846    /// via `OnPacketProduced`.
16847    ReleasePacket {
16848        packet: StreamPacket,
16849        control_handle: StreamSourceControlHandle,
16850    },
16851    DiscardAllPackets {
16852        responder: StreamSourceDiscardAllPacketsResponder,
16853    },
16854    DiscardAllPacketsNoReply {
16855        control_handle: StreamSourceControlHandle,
16856    },
16857}
16858
16859impl StreamSourceRequest {
16860    #[allow(irrefutable_let_patterns)]
16861    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
16862        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
16863            Some((packet, control_handle))
16864        } else {
16865            None
16866        }
16867    }
16868
16869    #[allow(irrefutable_let_patterns)]
16870    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
16871        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
16872            Some((responder))
16873        } else {
16874            None
16875        }
16876    }
16877
16878    #[allow(irrefutable_let_patterns)]
16879    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
16880        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
16881            Some((control_handle))
16882        } else {
16883            None
16884        }
16885    }
16886
16887    /// Name of the method defined in FIDL
16888    pub fn method_name(&self) -> &'static str {
16889        match *self {
16890            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
16891            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
16892            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16893        }
16894    }
16895}
16896
16897#[derive(Debug, Clone)]
16898pub struct StreamSourceControlHandle {
16899    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16900}
16901
16902impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
16903    fn shutdown(&self) {
16904        self.inner.shutdown()
16905    }
16906    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16907        self.inner.shutdown_with_epitaph(status)
16908    }
16909
16910    fn is_closed(&self) -> bool {
16911        self.inner.channel().is_closed()
16912    }
16913    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16914        self.inner.channel().on_closed()
16915    }
16916
16917    #[cfg(target_os = "fuchsia")]
16918    fn signal_peer(
16919        &self,
16920        clear_mask: zx::Signals,
16921        set_mask: zx::Signals,
16922    ) -> Result<(), zx_status::Status> {
16923        use fidl::Peered;
16924        self.inner.channel().signal_peer(clear_mask, set_mask)
16925    }
16926}
16927
16928impl StreamSourceControlHandle {
16929    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16930        self.inner.send::<StreamSourceOnPacketProducedRequest>(
16931            (packet,),
16932            0,
16933            0x6bbe69746a3c8bd9,
16934            fidl::encoding::DynamicFlags::empty(),
16935        )
16936    }
16937
16938    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
16939        self.inner.send::<fidl::encoding::EmptyPayload>(
16940            (),
16941            0,
16942            0x550e69b41d03e2c2,
16943            fidl::encoding::DynamicFlags::empty(),
16944        )
16945    }
16946}
16947
16948#[must_use = "FIDL methods require a response to be sent"]
16949#[derive(Debug)]
16950pub struct StreamSourceDiscardAllPacketsResponder {
16951    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
16952    tx_id: u32,
16953}
16954
16955/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
16956/// if the responder is dropped without sending a response, so that the client
16957/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16958impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
16959    fn drop(&mut self) {
16960        self.control_handle.shutdown();
16961        // Safety: drops once, never accessed again
16962        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16963    }
16964}
16965
16966impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
16967    type ControlHandle = StreamSourceControlHandle;
16968
16969    fn control_handle(&self) -> &StreamSourceControlHandle {
16970        &self.control_handle
16971    }
16972
16973    fn drop_without_shutdown(mut self) {
16974        // Safety: drops once, never accessed again due to mem::forget
16975        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16976        // Prevent Drop from running (which would shut down the channel)
16977        std::mem::forget(self);
16978    }
16979}
16980
16981impl StreamSourceDiscardAllPacketsResponder {
16982    /// Sends a response to the FIDL transaction.
16983    ///
16984    /// Sets the channel to shutdown if an error occurs.
16985    pub fn send(self) -> Result<(), fidl::Error> {
16986        let _result = self.send_raw();
16987        if _result.is_err() {
16988            self.control_handle.shutdown();
16989        }
16990        self.drop_without_shutdown();
16991        _result
16992    }
16993
16994    /// Similar to "send" but does not shutdown the channel if an error occurs.
16995    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16996        let _result = self.send_raw();
16997        self.drop_without_shutdown();
16998        _result
16999    }
17000
17001    fn send_raw(&self) -> Result<(), fidl::Error> {
17002        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17003            (),
17004            self.tx_id,
17005            0x27afd605e97b09d2,
17006            fidl::encoding::DynamicFlags::empty(),
17007        )
17008    }
17009}
17010
17011#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17012pub struct Usage2AudioConsumerFactoryMarker;
17013
17014impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
17015    type Proxy = Usage2AudioConsumerFactoryProxy;
17016    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
17017    #[cfg(target_os = "fuchsia")]
17018    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
17019
17020    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
17021}
17022impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
17023
17024pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
17025    fn r#create_audio_consumer(
17026        &self,
17027        usage: AudioRenderUsage2,
17028        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17029    ) -> Result<(), fidl::Error>;
17030}
17031#[derive(Debug)]
17032#[cfg(target_os = "fuchsia")]
17033pub struct Usage2AudioConsumerFactorySynchronousProxy {
17034    client: fidl::client::sync::Client,
17035}
17036
17037#[cfg(target_os = "fuchsia")]
17038impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
17039    type Proxy = Usage2AudioConsumerFactoryProxy;
17040    type Protocol = Usage2AudioConsumerFactoryMarker;
17041
17042    fn from_channel(inner: fidl::Channel) -> Self {
17043        Self::new(inner)
17044    }
17045
17046    fn into_channel(self) -> fidl::Channel {
17047        self.client.into_channel()
17048    }
17049
17050    fn as_channel(&self) -> &fidl::Channel {
17051        self.client.as_channel()
17052    }
17053}
17054
17055#[cfg(target_os = "fuchsia")]
17056impl Usage2AudioConsumerFactorySynchronousProxy {
17057    pub fn new(channel: fidl::Channel) -> Self {
17058        let protocol_name =
17059            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17060        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17061    }
17062
17063    pub fn into_channel(self) -> fidl::Channel {
17064        self.client.into_channel()
17065    }
17066
17067    /// Waits until an event arrives and returns it. It is safe for other
17068    /// threads to make concurrent requests while waiting for an event.
17069    pub fn wait_for_event(
17070        &self,
17071        deadline: zx::MonotonicInstant,
17072    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17073        Usage2AudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17074    }
17075
17076    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17077    /// Audio submitted to such a consumer is always rendered locally.
17078    pub fn r#create_audio_consumer(
17079        &self,
17080        mut usage: AudioRenderUsage2,
17081        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17082    ) -> Result<(), fidl::Error> {
17083        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17084            (usage, audio_consumer_request),
17085            0x767722302a171873,
17086            fidl::encoding::DynamicFlags::FLEXIBLE,
17087        )
17088    }
17089}
17090
17091#[cfg(target_os = "fuchsia")]
17092impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::Handle {
17093    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
17094        value.into_channel().into()
17095    }
17096}
17097
17098#[cfg(target_os = "fuchsia")]
17099impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
17100    fn from(value: fidl::Channel) -> Self {
17101        Self::new(value)
17102    }
17103}
17104
17105#[cfg(target_os = "fuchsia")]
17106impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
17107    type Protocol = Usage2AudioConsumerFactoryMarker;
17108
17109    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
17110        Self::new(value.into_channel())
17111    }
17112}
17113
17114#[derive(Debug, Clone)]
17115pub struct Usage2AudioConsumerFactoryProxy {
17116    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17117}
17118
17119impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
17120    type Protocol = Usage2AudioConsumerFactoryMarker;
17121
17122    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17123        Self::new(inner)
17124    }
17125
17126    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17127        self.client.into_channel().map_err(|client| Self { client })
17128    }
17129
17130    fn as_channel(&self) -> &::fidl::AsyncChannel {
17131        self.client.as_channel()
17132    }
17133}
17134
17135impl Usage2AudioConsumerFactoryProxy {
17136    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
17137    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17138        let protocol_name =
17139            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17140        Self { client: fidl::client::Client::new(channel, protocol_name) }
17141    }
17142
17143    /// Get a Stream of events from the remote end of the protocol.
17144    ///
17145    /// # Panics
17146    ///
17147    /// Panics if the event stream was already taken.
17148    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
17149        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17150    }
17151
17152    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17153    /// Audio submitted to such a consumer is always rendered locally.
17154    pub fn r#create_audio_consumer(
17155        &self,
17156        mut usage: AudioRenderUsage2,
17157        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17158    ) -> Result<(), fidl::Error> {
17159        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17160            self,
17161            usage,
17162            audio_consumer_request,
17163        )
17164    }
17165}
17166
17167impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
17168    fn r#create_audio_consumer(
17169        &self,
17170        mut usage: AudioRenderUsage2,
17171        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17172    ) -> Result<(), fidl::Error> {
17173        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17174            (usage, audio_consumer_request),
17175            0x767722302a171873,
17176            fidl::encoding::DynamicFlags::FLEXIBLE,
17177        )
17178    }
17179}
17180
17181pub struct Usage2AudioConsumerFactoryEventStream {
17182    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17183}
17184
17185impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
17186
17187impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
17188    fn is_terminated(&self) -> bool {
17189        self.event_receiver.is_terminated()
17190    }
17191}
17192
17193impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
17194    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
17195
17196    fn poll_next(
17197        mut self: std::pin::Pin<&mut Self>,
17198        cx: &mut std::task::Context<'_>,
17199    ) -> std::task::Poll<Option<Self::Item>> {
17200        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17201            &mut self.event_receiver,
17202            cx
17203        )?) {
17204            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
17205            None => std::task::Poll::Ready(None),
17206        }
17207    }
17208}
17209
17210#[derive(Debug)]
17211pub enum Usage2AudioConsumerFactoryEvent {
17212    #[non_exhaustive]
17213    _UnknownEvent {
17214        /// Ordinal of the event that was sent.
17215        ordinal: u64,
17216    },
17217}
17218
17219impl Usage2AudioConsumerFactoryEvent {
17220    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
17221    fn decode(
17222        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17223    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17224        let (bytes, _handles) = buf.split_mut();
17225        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17226        debug_assert_eq!(tx_header.tx_id, 0);
17227        match tx_header.ordinal {
17228            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17229                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
17230                    ordinal: tx_header.ordinal,
17231                })
17232            }
17233            _ => Err(fidl::Error::UnknownOrdinal {
17234                ordinal: tx_header.ordinal,
17235                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17236            })
17237        }
17238    }
17239}
17240
17241/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
17242pub struct Usage2AudioConsumerFactoryRequestStream {
17243    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17244    is_terminated: bool,
17245}
17246
17247impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
17248
17249impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
17250    fn is_terminated(&self) -> bool {
17251        self.is_terminated
17252    }
17253}
17254
17255impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
17256    type Protocol = Usage2AudioConsumerFactoryMarker;
17257    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
17258
17259    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17260        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17261    }
17262
17263    fn control_handle(&self) -> Self::ControlHandle {
17264        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17265    }
17266
17267    fn into_inner(
17268        self,
17269    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17270    {
17271        (self.inner, self.is_terminated)
17272    }
17273
17274    fn from_inner(
17275        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17276        is_terminated: bool,
17277    ) -> Self {
17278        Self { inner, is_terminated }
17279    }
17280}
17281
17282impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
17283    type Item = Result<Usage2AudioConsumerFactoryRequest, 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        let this = &mut *self;
17290        if this.inner.check_shutdown(cx) {
17291            this.is_terminated = true;
17292            return std::task::Poll::Ready(None);
17293        }
17294        if this.is_terminated {
17295            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
17296        }
17297        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17298            |bytes, handles| {
17299                match this.inner.channel().read_etc(cx, bytes, handles) {
17300                    std::task::Poll::Ready(Ok(())) => {}
17301                    std::task::Poll::Pending => return std::task::Poll::Pending,
17302                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17303                        this.is_terminated = true;
17304                        return std::task::Poll::Ready(None);
17305                    }
17306                    std::task::Poll::Ready(Err(e)) => {
17307                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17308                            e.into(),
17309                        ))));
17310                    }
17311                }
17312
17313                // A message has been received from the channel
17314                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17315
17316                std::task::Poll::Ready(Some(match header.ordinal {
17317                0x767722302a171873 => {
17318                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17319                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17320                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17321                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
17322                        inner: this.inner.clone(),
17323                    };
17324                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17325audio_consumer_request: req.audio_consumer_request,
17326
17327                        control_handle,
17328                    })
17329                }
17330                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17331                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17332                        ordinal: header.ordinal,
17333                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17334                        method_type: fidl::MethodType::OneWay,
17335                    })
17336                }
17337                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17338                    this.inner.send_framework_err(
17339                        fidl::encoding::FrameworkErr::UnknownMethod,
17340                        header.tx_id,
17341                        header.ordinal,
17342                        header.dynamic_flags(),
17343                        (bytes, handles),
17344                    )?;
17345                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17346                        ordinal: header.ordinal,
17347                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17348                        method_type: fidl::MethodType::TwoWay,
17349                    })
17350                }
17351                _ => Err(fidl::Error::UnknownOrdinal {
17352                    ordinal: header.ordinal,
17353                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17354                }),
17355            }))
17356            },
17357        )
17358    }
17359}
17360
17361/// Interface for creating audio consumers for local rendering.
17362#[derive(Debug)]
17363pub enum Usage2AudioConsumerFactoryRequest {
17364    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17365    /// Audio submitted to such a consumer is always rendered locally.
17366    CreateAudioConsumer {
17367        usage: AudioRenderUsage2,
17368        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17369        control_handle: Usage2AudioConsumerFactoryControlHandle,
17370    },
17371    /// An interaction was received which does not match any known method.
17372    #[non_exhaustive]
17373    _UnknownMethod {
17374        /// Ordinal of the method that was called.
17375        ordinal: u64,
17376        control_handle: Usage2AudioConsumerFactoryControlHandle,
17377        method_type: fidl::MethodType,
17378    },
17379}
17380
17381impl Usage2AudioConsumerFactoryRequest {
17382    #[allow(irrefutable_let_patterns)]
17383    pub fn into_create_audio_consumer(
17384        self,
17385    ) -> Option<(
17386        AudioRenderUsage2,
17387        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17388        Usage2AudioConsumerFactoryControlHandle,
17389    )> {
17390        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
17391            usage,
17392            audio_consumer_request,
17393            control_handle,
17394        } = self
17395        {
17396            Some((usage, audio_consumer_request, control_handle))
17397        } else {
17398            None
17399        }
17400    }
17401
17402    /// Name of the method defined in FIDL
17403    pub fn method_name(&self) -> &'static str {
17404        match *self {
17405            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
17406                "create_audio_consumer"
17407            }
17408            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17409                method_type: fidl::MethodType::OneWay,
17410                ..
17411            } => "unknown one-way method",
17412            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17413                method_type: fidl::MethodType::TwoWay,
17414                ..
17415            } => "unknown two-way method",
17416        }
17417    }
17418}
17419
17420#[derive(Debug, Clone)]
17421pub struct Usage2AudioConsumerFactoryControlHandle {
17422    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17423}
17424
17425impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
17426    fn shutdown(&self) {
17427        self.inner.shutdown()
17428    }
17429    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17430        self.inner.shutdown_with_epitaph(status)
17431    }
17432
17433    fn is_closed(&self) -> bool {
17434        self.inner.channel().is_closed()
17435    }
17436    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17437        self.inner.channel().on_closed()
17438    }
17439
17440    #[cfg(target_os = "fuchsia")]
17441    fn signal_peer(
17442        &self,
17443        clear_mask: zx::Signals,
17444        set_mask: zx::Signals,
17445    ) -> Result<(), zx_status::Status> {
17446        use fidl::Peered;
17447        self.inner.channel().signal_peer(clear_mask, set_mask)
17448    }
17449}
17450
17451impl Usage2AudioConsumerFactoryControlHandle {}
17452
17453#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17454pub struct UsageAudioConsumerFactoryMarker;
17455
17456impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
17457    type Proxy = UsageAudioConsumerFactoryProxy;
17458    type RequestStream = UsageAudioConsumerFactoryRequestStream;
17459    #[cfg(target_os = "fuchsia")]
17460    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
17461
17462    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
17463}
17464impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
17465
17466pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
17467    fn r#create_audio_consumer(
17468        &self,
17469        usage: AudioRenderUsage,
17470        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17471    ) -> Result<(), fidl::Error>;
17472}
17473#[derive(Debug)]
17474#[cfg(target_os = "fuchsia")]
17475pub struct UsageAudioConsumerFactorySynchronousProxy {
17476    client: fidl::client::sync::Client,
17477}
17478
17479#[cfg(target_os = "fuchsia")]
17480impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
17481    type Proxy = UsageAudioConsumerFactoryProxy;
17482    type Protocol = UsageAudioConsumerFactoryMarker;
17483
17484    fn from_channel(inner: fidl::Channel) -> Self {
17485        Self::new(inner)
17486    }
17487
17488    fn into_channel(self) -> fidl::Channel {
17489        self.client.into_channel()
17490    }
17491
17492    fn as_channel(&self) -> &fidl::Channel {
17493        self.client.as_channel()
17494    }
17495}
17496
17497#[cfg(target_os = "fuchsia")]
17498impl UsageAudioConsumerFactorySynchronousProxy {
17499    pub fn new(channel: fidl::Channel) -> Self {
17500        let protocol_name =
17501            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17502        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17503    }
17504
17505    pub fn into_channel(self) -> fidl::Channel {
17506        self.client.into_channel()
17507    }
17508
17509    /// Waits until an event arrives and returns it. It is safe for other
17510    /// threads to make concurrent requests while waiting for an event.
17511    pub fn wait_for_event(
17512        &self,
17513        deadline: zx::MonotonicInstant,
17514    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17515        UsageAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17516    }
17517
17518    pub fn r#create_audio_consumer(
17519        &self,
17520        mut usage: AudioRenderUsage,
17521        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17522    ) -> Result<(), fidl::Error> {
17523        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17524            (usage, audio_consumer_request),
17525            0x4d975ca9b8f625a3,
17526            fidl::encoding::DynamicFlags::empty(),
17527        )
17528    }
17529}
17530
17531#[cfg(target_os = "fuchsia")]
17532impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::Handle {
17533    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
17534        value.into_channel().into()
17535    }
17536}
17537
17538#[cfg(target_os = "fuchsia")]
17539impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
17540    fn from(value: fidl::Channel) -> Self {
17541        Self::new(value)
17542    }
17543}
17544
17545#[cfg(target_os = "fuchsia")]
17546impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
17547    type Protocol = UsageAudioConsumerFactoryMarker;
17548
17549    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
17550        Self::new(value.into_channel())
17551    }
17552}
17553
17554#[derive(Debug, Clone)]
17555pub struct UsageAudioConsumerFactoryProxy {
17556    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17557}
17558
17559impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
17560    type Protocol = UsageAudioConsumerFactoryMarker;
17561
17562    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17563        Self::new(inner)
17564    }
17565
17566    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17567        self.client.into_channel().map_err(|client| Self { client })
17568    }
17569
17570    fn as_channel(&self) -> &::fidl::AsyncChannel {
17571        self.client.as_channel()
17572    }
17573}
17574
17575impl UsageAudioConsumerFactoryProxy {
17576    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
17577    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17578        let protocol_name =
17579            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17580        Self { client: fidl::client::Client::new(channel, protocol_name) }
17581    }
17582
17583    /// Get a Stream of events from the remote end of the protocol.
17584    ///
17585    /// # Panics
17586    ///
17587    /// Panics if the event stream was already taken.
17588    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
17589        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17590    }
17591
17592    pub fn r#create_audio_consumer(
17593        &self,
17594        mut usage: AudioRenderUsage,
17595        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17596    ) -> Result<(), fidl::Error> {
17597        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17598            self,
17599            usage,
17600            audio_consumer_request,
17601        )
17602    }
17603}
17604
17605impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
17606    fn r#create_audio_consumer(
17607        &self,
17608        mut usage: AudioRenderUsage,
17609        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17610    ) -> Result<(), fidl::Error> {
17611        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17612            (usage, audio_consumer_request),
17613            0x4d975ca9b8f625a3,
17614            fidl::encoding::DynamicFlags::empty(),
17615        )
17616    }
17617}
17618
17619pub struct UsageAudioConsumerFactoryEventStream {
17620    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17621}
17622
17623impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
17624
17625impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
17626    fn is_terminated(&self) -> bool {
17627        self.event_receiver.is_terminated()
17628    }
17629}
17630
17631impl futures::Stream for UsageAudioConsumerFactoryEventStream {
17632    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
17633
17634    fn poll_next(
17635        mut self: std::pin::Pin<&mut Self>,
17636        cx: &mut std::task::Context<'_>,
17637    ) -> std::task::Poll<Option<Self::Item>> {
17638        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17639            &mut self.event_receiver,
17640            cx
17641        )?) {
17642            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
17643            None => std::task::Poll::Ready(None),
17644        }
17645    }
17646}
17647
17648#[derive(Debug)]
17649pub enum UsageAudioConsumerFactoryEvent {}
17650
17651impl UsageAudioConsumerFactoryEvent {
17652    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
17653    fn decode(
17654        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17655    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17656        let (bytes, _handles) = buf.split_mut();
17657        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17658        debug_assert_eq!(tx_header.tx_id, 0);
17659        match tx_header.ordinal {
17660            _ => Err(fidl::Error::UnknownOrdinal {
17661                ordinal: tx_header.ordinal,
17662                protocol_name:
17663                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17664            }),
17665        }
17666    }
17667}
17668
17669/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
17670pub struct UsageAudioConsumerFactoryRequestStream {
17671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17672    is_terminated: bool,
17673}
17674
17675impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
17676
17677impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
17678    fn is_terminated(&self) -> bool {
17679        self.is_terminated
17680    }
17681}
17682
17683impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
17684    type Protocol = UsageAudioConsumerFactoryMarker;
17685    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
17686
17687    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17688        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17689    }
17690
17691    fn control_handle(&self) -> Self::ControlHandle {
17692        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17693    }
17694
17695    fn into_inner(
17696        self,
17697    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17698    {
17699        (self.inner, self.is_terminated)
17700    }
17701
17702    fn from_inner(
17703        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17704        is_terminated: bool,
17705    ) -> Self {
17706        Self { inner, is_terminated }
17707    }
17708}
17709
17710impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
17711    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
17712
17713    fn poll_next(
17714        mut self: std::pin::Pin<&mut Self>,
17715        cx: &mut std::task::Context<'_>,
17716    ) -> std::task::Poll<Option<Self::Item>> {
17717        let this = &mut *self;
17718        if this.inner.check_shutdown(cx) {
17719            this.is_terminated = true;
17720            return std::task::Poll::Ready(None);
17721        }
17722        if this.is_terminated {
17723            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
17724        }
17725        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17726            |bytes, handles| {
17727                match this.inner.channel().read_etc(cx, bytes, handles) {
17728                    std::task::Poll::Ready(Ok(())) => {}
17729                    std::task::Poll::Pending => return std::task::Poll::Pending,
17730                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17731                        this.is_terminated = true;
17732                        return std::task::Poll::Ready(None);
17733                    }
17734                    std::task::Poll::Ready(Err(e)) => {
17735                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17736                            e.into(),
17737                        ))));
17738                    }
17739                }
17740
17741                // A message has been received from the channel
17742                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17743
17744                std::task::Poll::Ready(Some(match header.ordinal {
17745                0x4d975ca9b8f625a3 => {
17746                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17747                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17748                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17749                    let control_handle = UsageAudioConsumerFactoryControlHandle {
17750                        inner: this.inner.clone(),
17751                    };
17752                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17753audio_consumer_request: req.audio_consumer_request,
17754
17755                        control_handle,
17756                    })
17757                }
17758                _ => Err(fidl::Error::UnknownOrdinal {
17759                    ordinal: header.ordinal,
17760                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17761                }),
17762            }))
17763            },
17764        )
17765    }
17766}
17767
17768/// Interface for creating audio consumers for local rendering.
17769#[derive(Debug)]
17770pub enum UsageAudioConsumerFactoryRequest {
17771    CreateAudioConsumer {
17772        usage: AudioRenderUsage,
17773        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17774        control_handle: UsageAudioConsumerFactoryControlHandle,
17775    },
17776}
17777
17778impl UsageAudioConsumerFactoryRequest {
17779    #[allow(irrefutable_let_patterns)]
17780    pub fn into_create_audio_consumer(
17781        self,
17782    ) -> Option<(
17783        AudioRenderUsage,
17784        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17785        UsageAudioConsumerFactoryControlHandle,
17786    )> {
17787        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
17788            usage,
17789            audio_consumer_request,
17790            control_handle,
17791        } = self
17792        {
17793            Some((usage, audio_consumer_request, control_handle))
17794        } else {
17795            None
17796        }
17797    }
17798
17799    /// Name of the method defined in FIDL
17800    pub fn method_name(&self) -> &'static str {
17801        match *self {
17802            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
17803        }
17804    }
17805}
17806
17807#[derive(Debug, Clone)]
17808pub struct UsageAudioConsumerFactoryControlHandle {
17809    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17810}
17811
17812impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
17813    fn shutdown(&self) {
17814        self.inner.shutdown()
17815    }
17816    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17817        self.inner.shutdown_with_epitaph(status)
17818    }
17819
17820    fn is_closed(&self) -> bool {
17821        self.inner.channel().is_closed()
17822    }
17823    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17824        self.inner.channel().on_closed()
17825    }
17826
17827    #[cfg(target_os = "fuchsia")]
17828    fn signal_peer(
17829        &self,
17830        clear_mask: zx::Signals,
17831        set_mask: zx::Signals,
17832    ) -> Result<(), zx_status::Status> {
17833        use fidl::Peered;
17834        self.inner.channel().signal_peer(clear_mask, set_mask)
17835    }
17836}
17837
17838impl UsageAudioConsumerFactoryControlHandle {}
17839
17840#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17841pub struct UsageGainListenerMarker;
17842
17843impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
17844    type Proxy = UsageGainListenerProxy;
17845    type RequestStream = UsageGainListenerRequestStream;
17846    #[cfg(target_os = "fuchsia")]
17847    type SynchronousProxy = UsageGainListenerSynchronousProxy;
17848
17849    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
17850}
17851
17852pub trait UsageGainListenerProxyInterface: Send + Sync {
17853    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17854    fn r#on_gain_mute_changed(
17855        &self,
17856        muted: bool,
17857        gain_dbfs: f32,
17858    ) -> Self::OnGainMuteChangedResponseFut;
17859}
17860#[derive(Debug)]
17861#[cfg(target_os = "fuchsia")]
17862pub struct UsageGainListenerSynchronousProxy {
17863    client: fidl::client::sync::Client,
17864}
17865
17866#[cfg(target_os = "fuchsia")]
17867impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
17868    type Proxy = UsageGainListenerProxy;
17869    type Protocol = UsageGainListenerMarker;
17870
17871    fn from_channel(inner: fidl::Channel) -> Self {
17872        Self::new(inner)
17873    }
17874
17875    fn into_channel(self) -> fidl::Channel {
17876        self.client.into_channel()
17877    }
17878
17879    fn as_channel(&self) -> &fidl::Channel {
17880        self.client.as_channel()
17881    }
17882}
17883
17884#[cfg(target_os = "fuchsia")]
17885impl UsageGainListenerSynchronousProxy {
17886    pub fn new(channel: fidl::Channel) -> Self {
17887        let protocol_name =
17888            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17889        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17890    }
17891
17892    pub fn into_channel(self) -> fidl::Channel {
17893        self.client.into_channel()
17894    }
17895
17896    /// Waits until an event arrives and returns it. It is safe for other
17897    /// threads to make concurrent requests while waiting for an event.
17898    pub fn wait_for_event(
17899        &self,
17900        deadline: zx::MonotonicInstant,
17901    ) -> Result<UsageGainListenerEvent, fidl::Error> {
17902        UsageGainListenerEvent::decode(self.client.wait_for_event(deadline)?)
17903    }
17904
17905    /// Called immediately on connection and afterward any time
17906    /// the usage gain setting changes.
17907    ///
17908    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17909    /// events will eventually be disconnected.
17910    ///
17911    /// Note: This API does not have mute reporting implemented; `muted` is always false.
17912    pub fn r#on_gain_mute_changed(
17913        &self,
17914        mut muted: bool,
17915        mut gain_dbfs: f32,
17916        ___deadline: zx::MonotonicInstant,
17917    ) -> Result<(), fidl::Error> {
17918        let _response = self
17919            .client
17920            .send_query::<UsageGainListenerOnGainMuteChangedRequest, fidl::encoding::EmptyPayload>(
17921                (muted, gain_dbfs),
17922                0x681570258eac3a8d,
17923                fidl::encoding::DynamicFlags::empty(),
17924                ___deadline,
17925            )?;
17926        Ok(_response)
17927    }
17928}
17929
17930#[cfg(target_os = "fuchsia")]
17931impl From<UsageGainListenerSynchronousProxy> for zx::Handle {
17932    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
17933        value.into_channel().into()
17934    }
17935}
17936
17937#[cfg(target_os = "fuchsia")]
17938impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
17939    fn from(value: fidl::Channel) -> Self {
17940        Self::new(value)
17941    }
17942}
17943
17944#[cfg(target_os = "fuchsia")]
17945impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
17946    type Protocol = UsageGainListenerMarker;
17947
17948    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
17949        Self::new(value.into_channel())
17950    }
17951}
17952
17953#[derive(Debug, Clone)]
17954pub struct UsageGainListenerProxy {
17955    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17956}
17957
17958impl fidl::endpoints::Proxy for UsageGainListenerProxy {
17959    type Protocol = UsageGainListenerMarker;
17960
17961    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17962        Self::new(inner)
17963    }
17964
17965    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17966        self.client.into_channel().map_err(|client| Self { client })
17967    }
17968
17969    fn as_channel(&self) -> &::fidl::AsyncChannel {
17970        self.client.as_channel()
17971    }
17972}
17973
17974impl UsageGainListenerProxy {
17975    /// Create a new Proxy for fuchsia.media/UsageGainListener.
17976    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17977        let protocol_name =
17978            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17979        Self { client: fidl::client::Client::new(channel, protocol_name) }
17980    }
17981
17982    /// Get a Stream of events from the remote end of the protocol.
17983    ///
17984    /// # Panics
17985    ///
17986    /// Panics if the event stream was already taken.
17987    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
17988        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
17989    }
17990
17991    /// Called immediately on connection and afterward any time
17992    /// the usage gain setting changes.
17993    ///
17994    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17995    /// events will eventually be disconnected.
17996    ///
17997    /// Note: This API does not have mute reporting implemented; `muted` is always false.
17998    pub fn r#on_gain_mute_changed(
17999        &self,
18000        mut muted: bool,
18001        mut gain_dbfs: f32,
18002    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18003        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
18004    }
18005}
18006
18007impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
18008    type OnGainMuteChangedResponseFut =
18009        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18010    fn r#on_gain_mute_changed(
18011        &self,
18012        mut muted: bool,
18013        mut gain_dbfs: f32,
18014    ) -> Self::OnGainMuteChangedResponseFut {
18015        fn _decode(
18016            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18017        ) -> Result<(), fidl::Error> {
18018            let _response = fidl::client::decode_transaction_body::<
18019                fidl::encoding::EmptyPayload,
18020                fidl::encoding::DefaultFuchsiaResourceDialect,
18021                0x681570258eac3a8d,
18022            >(_buf?)?;
18023            Ok(_response)
18024        }
18025        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
18026            (muted, gain_dbfs),
18027            0x681570258eac3a8d,
18028            fidl::encoding::DynamicFlags::empty(),
18029            _decode,
18030        )
18031    }
18032}
18033
18034pub struct UsageGainListenerEventStream {
18035    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18036}
18037
18038impl std::marker::Unpin for UsageGainListenerEventStream {}
18039
18040impl futures::stream::FusedStream for UsageGainListenerEventStream {
18041    fn is_terminated(&self) -> bool {
18042        self.event_receiver.is_terminated()
18043    }
18044}
18045
18046impl futures::Stream for UsageGainListenerEventStream {
18047    type Item = Result<UsageGainListenerEvent, fidl::Error>;
18048
18049    fn poll_next(
18050        mut self: std::pin::Pin<&mut Self>,
18051        cx: &mut std::task::Context<'_>,
18052    ) -> std::task::Poll<Option<Self::Item>> {
18053        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18054            &mut self.event_receiver,
18055            cx
18056        )?) {
18057            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
18058            None => std::task::Poll::Ready(None),
18059        }
18060    }
18061}
18062
18063#[derive(Debug)]
18064pub enum UsageGainListenerEvent {}
18065
18066impl UsageGainListenerEvent {
18067    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
18068    fn decode(
18069        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18070    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18071        let (bytes, _handles) = buf.split_mut();
18072        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18073        debug_assert_eq!(tx_header.tx_id, 0);
18074        match tx_header.ordinal {
18075            _ => Err(fidl::Error::UnknownOrdinal {
18076                ordinal: tx_header.ordinal,
18077                protocol_name:
18078                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18079            }),
18080        }
18081    }
18082}
18083
18084/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
18085pub struct UsageGainListenerRequestStream {
18086    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18087    is_terminated: bool,
18088}
18089
18090impl std::marker::Unpin for UsageGainListenerRequestStream {}
18091
18092impl futures::stream::FusedStream for UsageGainListenerRequestStream {
18093    fn is_terminated(&self) -> bool {
18094        self.is_terminated
18095    }
18096}
18097
18098impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
18099    type Protocol = UsageGainListenerMarker;
18100    type ControlHandle = UsageGainListenerControlHandle;
18101
18102    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18103        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18104    }
18105
18106    fn control_handle(&self) -> Self::ControlHandle {
18107        UsageGainListenerControlHandle { inner: self.inner.clone() }
18108    }
18109
18110    fn into_inner(
18111        self,
18112    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18113    {
18114        (self.inner, self.is_terminated)
18115    }
18116
18117    fn from_inner(
18118        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18119        is_terminated: bool,
18120    ) -> Self {
18121        Self { inner, is_terminated }
18122    }
18123}
18124
18125impl futures::Stream for UsageGainListenerRequestStream {
18126    type Item = Result<UsageGainListenerRequest, fidl::Error>;
18127
18128    fn poll_next(
18129        mut self: std::pin::Pin<&mut Self>,
18130        cx: &mut std::task::Context<'_>,
18131    ) -> std::task::Poll<Option<Self::Item>> {
18132        let this = &mut *self;
18133        if this.inner.check_shutdown(cx) {
18134            this.is_terminated = true;
18135            return std::task::Poll::Ready(None);
18136        }
18137        if this.is_terminated {
18138            panic!("polled UsageGainListenerRequestStream after completion");
18139        }
18140        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18141            |bytes, handles| {
18142                match this.inner.channel().read_etc(cx, bytes, handles) {
18143                    std::task::Poll::Ready(Ok(())) => {}
18144                    std::task::Poll::Pending => return std::task::Poll::Pending,
18145                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18146                        this.is_terminated = true;
18147                        return std::task::Poll::Ready(None);
18148                    }
18149                    std::task::Poll::Ready(Err(e)) => {
18150                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18151                            e.into(),
18152                        ))));
18153                    }
18154                }
18155
18156                // A message has been received from the channel
18157                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18158
18159                std::task::Poll::Ready(Some(match header.ordinal {
18160                    0x681570258eac3a8d => {
18161                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18162                        let mut req = fidl::new_empty!(
18163                            UsageGainListenerOnGainMuteChangedRequest,
18164                            fidl::encoding::DefaultFuchsiaResourceDialect
18165                        );
18166                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
18167                        let control_handle =
18168                            UsageGainListenerControlHandle { inner: this.inner.clone() };
18169                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
18170                            muted: req.muted,
18171                            gain_dbfs: req.gain_dbfs,
18172
18173                            responder: UsageGainListenerOnGainMuteChangedResponder {
18174                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18175                                tx_id: header.tx_id,
18176                            },
18177                        })
18178                    }
18179                    _ => Err(fidl::Error::UnknownOrdinal {
18180                        ordinal: header.ordinal,
18181                        protocol_name:
18182                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18183                    }),
18184                }))
18185            },
18186        )
18187    }
18188}
18189
18190/// A protocol for watching changes to usage gain settings.
18191///
18192/// The channel will close when the device is not present.
18193#[derive(Debug)]
18194pub enum UsageGainListenerRequest {
18195    /// Called immediately on connection and afterward any time
18196    /// the usage gain setting changes.
18197    ///
18198    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18199    /// events will eventually be disconnected.
18200    ///
18201    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18202    OnGainMuteChanged {
18203        muted: bool,
18204        gain_dbfs: f32,
18205        responder: UsageGainListenerOnGainMuteChangedResponder,
18206    },
18207}
18208
18209impl UsageGainListenerRequest {
18210    #[allow(irrefutable_let_patterns)]
18211    pub fn into_on_gain_mute_changed(
18212        self,
18213    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
18214        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
18215            Some((muted, gain_dbfs, responder))
18216        } else {
18217            None
18218        }
18219    }
18220
18221    /// Name of the method defined in FIDL
18222    pub fn method_name(&self) -> &'static str {
18223        match *self {
18224            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
18225        }
18226    }
18227}
18228
18229#[derive(Debug, Clone)]
18230pub struct UsageGainListenerControlHandle {
18231    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18232}
18233
18234impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
18235    fn shutdown(&self) {
18236        self.inner.shutdown()
18237    }
18238    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18239        self.inner.shutdown_with_epitaph(status)
18240    }
18241
18242    fn is_closed(&self) -> bool {
18243        self.inner.channel().is_closed()
18244    }
18245    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18246        self.inner.channel().on_closed()
18247    }
18248
18249    #[cfg(target_os = "fuchsia")]
18250    fn signal_peer(
18251        &self,
18252        clear_mask: zx::Signals,
18253        set_mask: zx::Signals,
18254    ) -> Result<(), zx_status::Status> {
18255        use fidl::Peered;
18256        self.inner.channel().signal_peer(clear_mask, set_mask)
18257    }
18258}
18259
18260impl UsageGainListenerControlHandle {}
18261
18262#[must_use = "FIDL methods require a response to be sent"]
18263#[derive(Debug)]
18264pub struct UsageGainListenerOnGainMuteChangedResponder {
18265    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
18266    tx_id: u32,
18267}
18268
18269/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
18270/// if the responder is dropped without sending a response, so that the client
18271/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18272impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
18273    fn drop(&mut self) {
18274        self.control_handle.shutdown();
18275        // Safety: drops once, never accessed again
18276        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18277    }
18278}
18279
18280impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
18281    type ControlHandle = UsageGainListenerControlHandle;
18282
18283    fn control_handle(&self) -> &UsageGainListenerControlHandle {
18284        &self.control_handle
18285    }
18286
18287    fn drop_without_shutdown(mut self) {
18288        // Safety: drops once, never accessed again due to mem::forget
18289        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18290        // Prevent Drop from running (which would shut down the channel)
18291        std::mem::forget(self);
18292    }
18293}
18294
18295impl UsageGainListenerOnGainMuteChangedResponder {
18296    /// Sends a response to the FIDL transaction.
18297    ///
18298    /// Sets the channel to shutdown if an error occurs.
18299    pub fn send(self) -> Result<(), fidl::Error> {
18300        let _result = self.send_raw();
18301        if _result.is_err() {
18302            self.control_handle.shutdown();
18303        }
18304        self.drop_without_shutdown();
18305        _result
18306    }
18307
18308    /// Similar to "send" but does not shutdown the channel if an error occurs.
18309    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18310        let _result = self.send_raw();
18311        self.drop_without_shutdown();
18312        _result
18313    }
18314
18315    fn send_raw(&self) -> Result<(), fidl::Error> {
18316        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18317            (),
18318            self.tx_id,
18319            0x681570258eac3a8d,
18320            fidl::encoding::DynamicFlags::empty(),
18321        )
18322    }
18323}
18324
18325#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18326pub struct UsageGainReporterMarker;
18327
18328impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
18329    type Proxy = UsageGainReporterProxy;
18330    type RequestStream = UsageGainReporterRequestStream;
18331    #[cfg(target_os = "fuchsia")]
18332    type SynchronousProxy = UsageGainReporterSynchronousProxy;
18333
18334    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
18335}
18336impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
18337
18338pub trait UsageGainReporterProxyInterface: Send + Sync {
18339    fn r#register_listener(
18340        &self,
18341        device_unique_id: &str,
18342        usage: &Usage,
18343        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18344    ) -> Result<(), fidl::Error>;
18345    fn r#register_listener2(
18346        &self,
18347        device_unique_id: &str,
18348        usage: &Usage2,
18349        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18350    ) -> Result<(), fidl::Error>;
18351}
18352#[derive(Debug)]
18353#[cfg(target_os = "fuchsia")]
18354pub struct UsageGainReporterSynchronousProxy {
18355    client: fidl::client::sync::Client,
18356}
18357
18358#[cfg(target_os = "fuchsia")]
18359impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
18360    type Proxy = UsageGainReporterProxy;
18361    type Protocol = UsageGainReporterMarker;
18362
18363    fn from_channel(inner: fidl::Channel) -> Self {
18364        Self::new(inner)
18365    }
18366
18367    fn into_channel(self) -> fidl::Channel {
18368        self.client.into_channel()
18369    }
18370
18371    fn as_channel(&self) -> &fidl::Channel {
18372        self.client.as_channel()
18373    }
18374}
18375
18376#[cfg(target_os = "fuchsia")]
18377impl UsageGainReporterSynchronousProxy {
18378    pub fn new(channel: fidl::Channel) -> Self {
18379        let protocol_name =
18380            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18381        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
18382    }
18383
18384    pub fn into_channel(self) -> fidl::Channel {
18385        self.client.into_channel()
18386    }
18387
18388    /// Waits until an event arrives and returns it. It is safe for other
18389    /// threads to make concurrent requests while waiting for an event.
18390    pub fn wait_for_event(
18391        &self,
18392        deadline: zx::MonotonicInstant,
18393    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18394        UsageGainReporterEvent::decode(self.client.wait_for_event(deadline)?)
18395    }
18396
18397    /// Connects a listener to a stream of usage gain setting changes
18398    /// for `usage` on the device identified by `device_token`. Usage
18399    /// Gain is not set directly by any client; it is a translation of
18400    /// the usage volume setting for each device, summed with active
18401    /// muting/ducking gain adjustments.
18402    ///
18403    /// Devices may map the same volume level to different dbfs, so
18404    /// a `device_unique_id` is needed to identify the device.
18405    ///
18406    /// `AudioDeviceEnumerator` provides programmatic access to devices
18407    /// and their unique ids if it is necessary for a client to select
18408    /// an id at runtime.
18409    pub fn r#register_listener(
18410        &self,
18411        mut device_unique_id: &str,
18412        mut usage: &Usage,
18413        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18414    ) -> Result<(), fidl::Error> {
18415        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18416            (device_unique_id, usage, usage_gain_listener),
18417            0x767107c168c226af,
18418            fidl::encoding::DynamicFlags::empty(),
18419        )
18420    }
18421
18422    /// Connects a listener to a stream of usage gain setting changes
18423    /// for `usage` on the device identified by `device_token`. Usage
18424    /// Gain is not set directly by any client; it is a translation of
18425    /// the usage volume setting for each device, summed with active
18426    /// muting/ducking gain adjustments.
18427    ///
18428    /// Devices may map the same volume level to different dbfs, so
18429    /// a `device_unique_id` is needed to identify the device.
18430    ///
18431    /// `AudioDeviceEnumerator` provides programmatic access to devices
18432    /// and their unique ids if it is necessary for a client to select
18433    /// an id at runtime.
18434    pub fn r#register_listener2(
18435        &self,
18436        mut device_unique_id: &str,
18437        mut usage: &Usage2,
18438        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18439    ) -> Result<(), fidl::Error> {
18440        self.client.send::<UsageGainReporterRegisterListener2Request>(
18441            (device_unique_id, usage, usage_gain_listener),
18442            0x760a8e1c5873629c,
18443            fidl::encoding::DynamicFlags::FLEXIBLE,
18444        )
18445    }
18446}
18447
18448#[cfg(target_os = "fuchsia")]
18449impl From<UsageGainReporterSynchronousProxy> for zx::Handle {
18450    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
18451        value.into_channel().into()
18452    }
18453}
18454
18455#[cfg(target_os = "fuchsia")]
18456impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
18457    fn from(value: fidl::Channel) -> Self {
18458        Self::new(value)
18459    }
18460}
18461
18462#[cfg(target_os = "fuchsia")]
18463impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
18464    type Protocol = UsageGainReporterMarker;
18465
18466    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
18467        Self::new(value.into_channel())
18468    }
18469}
18470
18471#[derive(Debug, Clone)]
18472pub struct UsageGainReporterProxy {
18473    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18474}
18475
18476impl fidl::endpoints::Proxy for UsageGainReporterProxy {
18477    type Protocol = UsageGainReporterMarker;
18478
18479    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18480        Self::new(inner)
18481    }
18482
18483    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18484        self.client.into_channel().map_err(|client| Self { client })
18485    }
18486
18487    fn as_channel(&self) -> &::fidl::AsyncChannel {
18488        self.client.as_channel()
18489    }
18490}
18491
18492impl UsageGainReporterProxy {
18493    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
18494    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18495        let protocol_name =
18496            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18497        Self { client: fidl::client::Client::new(channel, protocol_name) }
18498    }
18499
18500    /// Get a Stream of events from the remote end of the protocol.
18501    ///
18502    /// # Panics
18503    ///
18504    /// Panics if the event stream was already taken.
18505    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
18506        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
18507    }
18508
18509    /// Connects a listener to a stream of usage gain setting changes
18510    /// for `usage` on the device identified by `device_token`. Usage
18511    /// Gain is not set directly by any client; it is a translation of
18512    /// the usage volume setting for each device, summed with active
18513    /// muting/ducking gain adjustments.
18514    ///
18515    /// Devices may map the same volume level to different dbfs, so
18516    /// a `device_unique_id` is needed to identify the device.
18517    ///
18518    /// `AudioDeviceEnumerator` provides programmatic access to devices
18519    /// and their unique ids if it is necessary for a client to select
18520    /// an id at runtime.
18521    pub fn r#register_listener(
18522        &self,
18523        mut device_unique_id: &str,
18524        mut usage: &Usage,
18525        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18526    ) -> Result<(), fidl::Error> {
18527        UsageGainReporterProxyInterface::r#register_listener(
18528            self,
18529            device_unique_id,
18530            usage,
18531            usage_gain_listener,
18532        )
18533    }
18534
18535    /// Connects a listener to a stream of usage gain setting changes
18536    /// for `usage` on the device identified by `device_token`. Usage
18537    /// Gain is not set directly by any client; it is a translation of
18538    /// the usage volume setting for each device, summed with active
18539    /// muting/ducking gain adjustments.
18540    ///
18541    /// Devices may map the same volume level to different dbfs, so
18542    /// a `device_unique_id` is needed to identify the device.
18543    ///
18544    /// `AudioDeviceEnumerator` provides programmatic access to devices
18545    /// and their unique ids if it is necessary for a client to select
18546    /// an id at runtime.
18547    pub fn r#register_listener2(
18548        &self,
18549        mut device_unique_id: &str,
18550        mut usage: &Usage2,
18551        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18552    ) -> Result<(), fidl::Error> {
18553        UsageGainReporterProxyInterface::r#register_listener2(
18554            self,
18555            device_unique_id,
18556            usage,
18557            usage_gain_listener,
18558        )
18559    }
18560}
18561
18562impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
18563    fn r#register_listener(
18564        &self,
18565        mut device_unique_id: &str,
18566        mut usage: &Usage,
18567        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18568    ) -> Result<(), fidl::Error> {
18569        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18570            (device_unique_id, usage, usage_gain_listener),
18571            0x767107c168c226af,
18572            fidl::encoding::DynamicFlags::empty(),
18573        )
18574    }
18575
18576    fn r#register_listener2(
18577        &self,
18578        mut device_unique_id: &str,
18579        mut usage: &Usage2,
18580        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18581    ) -> Result<(), fidl::Error> {
18582        self.client.send::<UsageGainReporterRegisterListener2Request>(
18583            (device_unique_id, usage, usage_gain_listener),
18584            0x760a8e1c5873629c,
18585            fidl::encoding::DynamicFlags::FLEXIBLE,
18586        )
18587    }
18588}
18589
18590pub struct UsageGainReporterEventStream {
18591    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18592}
18593
18594impl std::marker::Unpin for UsageGainReporterEventStream {}
18595
18596impl futures::stream::FusedStream for UsageGainReporterEventStream {
18597    fn is_terminated(&self) -> bool {
18598        self.event_receiver.is_terminated()
18599    }
18600}
18601
18602impl futures::Stream for UsageGainReporterEventStream {
18603    type Item = Result<UsageGainReporterEvent, fidl::Error>;
18604
18605    fn poll_next(
18606        mut self: std::pin::Pin<&mut Self>,
18607        cx: &mut std::task::Context<'_>,
18608    ) -> std::task::Poll<Option<Self::Item>> {
18609        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18610            &mut self.event_receiver,
18611            cx
18612        )?) {
18613            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
18614            None => std::task::Poll::Ready(None),
18615        }
18616    }
18617}
18618
18619#[derive(Debug)]
18620pub enum UsageGainReporterEvent {
18621    #[non_exhaustive]
18622    _UnknownEvent {
18623        /// Ordinal of the event that was sent.
18624        ordinal: u64,
18625    },
18626}
18627
18628impl UsageGainReporterEvent {
18629    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
18630    fn decode(
18631        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18632    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18633        let (bytes, _handles) = buf.split_mut();
18634        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18635        debug_assert_eq!(tx_header.tx_id, 0);
18636        match tx_header.ordinal {
18637            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
18638                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
18639            }
18640            _ => Err(fidl::Error::UnknownOrdinal {
18641                ordinal: tx_header.ordinal,
18642                protocol_name:
18643                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18644            }),
18645        }
18646    }
18647}
18648
18649/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
18650pub struct UsageGainReporterRequestStream {
18651    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18652    is_terminated: bool,
18653}
18654
18655impl std::marker::Unpin for UsageGainReporterRequestStream {}
18656
18657impl futures::stream::FusedStream for UsageGainReporterRequestStream {
18658    fn is_terminated(&self) -> bool {
18659        self.is_terminated
18660    }
18661}
18662
18663impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
18664    type Protocol = UsageGainReporterMarker;
18665    type ControlHandle = UsageGainReporterControlHandle;
18666
18667    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18668        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18669    }
18670
18671    fn control_handle(&self) -> Self::ControlHandle {
18672        UsageGainReporterControlHandle { inner: self.inner.clone() }
18673    }
18674
18675    fn into_inner(
18676        self,
18677    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18678    {
18679        (self.inner, self.is_terminated)
18680    }
18681
18682    fn from_inner(
18683        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18684        is_terminated: bool,
18685    ) -> Self {
18686        Self { inner, is_terminated }
18687    }
18688}
18689
18690impl futures::Stream for UsageGainReporterRequestStream {
18691    type Item = Result<UsageGainReporterRequest, fidl::Error>;
18692
18693    fn poll_next(
18694        mut self: std::pin::Pin<&mut Self>,
18695        cx: &mut std::task::Context<'_>,
18696    ) -> std::task::Poll<Option<Self::Item>> {
18697        let this = &mut *self;
18698        if this.inner.check_shutdown(cx) {
18699            this.is_terminated = true;
18700            return std::task::Poll::Ready(None);
18701        }
18702        if this.is_terminated {
18703            panic!("polled UsageGainReporterRequestStream after completion");
18704        }
18705        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18706            |bytes, handles| {
18707                match this.inner.channel().read_etc(cx, bytes, handles) {
18708                    std::task::Poll::Ready(Ok(())) => {}
18709                    std::task::Poll::Pending => return std::task::Poll::Pending,
18710                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18711                        this.is_terminated = true;
18712                        return std::task::Poll::Ready(None);
18713                    }
18714                    std::task::Poll::Ready(Err(e)) => {
18715                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18716                            e.into(),
18717                        ))));
18718                    }
18719                }
18720
18721                // A message has been received from the channel
18722                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18723
18724                std::task::Poll::Ready(Some(match header.ordinal {
18725                    0x767107c168c226af => {
18726                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18727                        let mut req = fidl::new_empty!(
18728                            UsageGainReporterRegisterListenerRequest,
18729                            fidl::encoding::DefaultFuchsiaResourceDialect
18730                        );
18731                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
18732                        let control_handle =
18733                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18734                        Ok(UsageGainReporterRequest::RegisterListener {
18735                            device_unique_id: req.device_unique_id,
18736                            usage: req.usage,
18737                            usage_gain_listener: req.usage_gain_listener,
18738
18739                            control_handle,
18740                        })
18741                    }
18742                    0x760a8e1c5873629c => {
18743                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18744                        let mut req = fidl::new_empty!(
18745                            UsageGainReporterRegisterListener2Request,
18746                            fidl::encoding::DefaultFuchsiaResourceDialect
18747                        );
18748                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
18749                        let control_handle =
18750                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18751                        Ok(UsageGainReporterRequest::RegisterListener2 {
18752                            device_unique_id: req.device_unique_id,
18753                            usage: req.usage,
18754                            usage_gain_listener: req.usage_gain_listener,
18755
18756                            control_handle,
18757                        })
18758                    }
18759                    _ if header.tx_id == 0
18760                        && header
18761                            .dynamic_flags()
18762                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18763                    {
18764                        Ok(UsageGainReporterRequest::_UnknownMethod {
18765                            ordinal: header.ordinal,
18766                            control_handle: UsageGainReporterControlHandle {
18767                                inner: this.inner.clone(),
18768                            },
18769                            method_type: fidl::MethodType::OneWay,
18770                        })
18771                    }
18772                    _ if header
18773                        .dynamic_flags()
18774                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18775                    {
18776                        this.inner.send_framework_err(
18777                            fidl::encoding::FrameworkErr::UnknownMethod,
18778                            header.tx_id,
18779                            header.ordinal,
18780                            header.dynamic_flags(),
18781                            (bytes, handles),
18782                        )?;
18783                        Ok(UsageGainReporterRequest::_UnknownMethod {
18784                            ordinal: header.ordinal,
18785                            control_handle: UsageGainReporterControlHandle {
18786                                inner: this.inner.clone(),
18787                            },
18788                            method_type: fidl::MethodType::TwoWay,
18789                        })
18790                    }
18791                    _ => Err(fidl::Error::UnknownOrdinal {
18792                        ordinal: header.ordinal,
18793                        protocol_name:
18794                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18795                    }),
18796                }))
18797            },
18798        )
18799    }
18800}
18801
18802/// A protocol for setting up watchers of usage gain.
18803#[derive(Debug)]
18804pub enum UsageGainReporterRequest {
18805    /// Connects a listener to a stream of usage gain setting changes
18806    /// for `usage` on the device identified by `device_token`. Usage
18807    /// Gain is not set directly by any client; it is a translation of
18808    /// the usage volume setting for each device, summed with active
18809    /// muting/ducking gain adjustments.
18810    ///
18811    /// Devices may map the same volume level to different dbfs, so
18812    /// a `device_unique_id` is needed to identify the device.
18813    ///
18814    /// `AudioDeviceEnumerator` provides programmatic access to devices
18815    /// and their unique ids if it is necessary for a client to select
18816    /// an id at runtime.
18817    RegisterListener {
18818        device_unique_id: String,
18819        usage: Usage,
18820        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18821        control_handle: UsageGainReporterControlHandle,
18822    },
18823    /// Connects a listener to a stream of usage gain setting changes
18824    /// for `usage` on the device identified by `device_token`. Usage
18825    /// Gain is not set directly by any client; it is a translation of
18826    /// the usage volume setting for each device, summed with active
18827    /// muting/ducking gain adjustments.
18828    ///
18829    /// Devices may map the same volume level to different dbfs, so
18830    /// a `device_unique_id` is needed to identify the device.
18831    ///
18832    /// `AudioDeviceEnumerator` provides programmatic access to devices
18833    /// and their unique ids if it is necessary for a client to select
18834    /// an id at runtime.
18835    RegisterListener2 {
18836        device_unique_id: String,
18837        usage: Usage2,
18838        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18839        control_handle: UsageGainReporterControlHandle,
18840    },
18841    /// An interaction was received which does not match any known method.
18842    #[non_exhaustive]
18843    _UnknownMethod {
18844        /// Ordinal of the method that was called.
18845        ordinal: u64,
18846        control_handle: UsageGainReporterControlHandle,
18847        method_type: fidl::MethodType,
18848    },
18849}
18850
18851impl UsageGainReporterRequest {
18852    #[allow(irrefutable_let_patterns)]
18853    pub fn into_register_listener(
18854        self,
18855    ) -> Option<(
18856        String,
18857        Usage,
18858        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18859        UsageGainReporterControlHandle,
18860    )> {
18861        if let UsageGainReporterRequest::RegisterListener {
18862            device_unique_id,
18863            usage,
18864            usage_gain_listener,
18865            control_handle,
18866        } = self
18867        {
18868            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18869        } else {
18870            None
18871        }
18872    }
18873
18874    #[allow(irrefutable_let_patterns)]
18875    pub fn into_register_listener2(
18876        self,
18877    ) -> Option<(
18878        String,
18879        Usage2,
18880        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18881        UsageGainReporterControlHandle,
18882    )> {
18883        if let UsageGainReporterRequest::RegisterListener2 {
18884            device_unique_id,
18885            usage,
18886            usage_gain_listener,
18887            control_handle,
18888        } = self
18889        {
18890            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18891        } else {
18892            None
18893        }
18894    }
18895
18896    /// Name of the method defined in FIDL
18897    pub fn method_name(&self) -> &'static str {
18898        match *self {
18899            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
18900            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
18901            UsageGainReporterRequest::_UnknownMethod {
18902                method_type: fidl::MethodType::OneWay,
18903                ..
18904            } => "unknown one-way method",
18905            UsageGainReporterRequest::_UnknownMethod {
18906                method_type: fidl::MethodType::TwoWay,
18907                ..
18908            } => "unknown two-way method",
18909        }
18910    }
18911}
18912
18913#[derive(Debug, Clone)]
18914pub struct UsageGainReporterControlHandle {
18915    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18916}
18917
18918impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
18919    fn shutdown(&self) {
18920        self.inner.shutdown()
18921    }
18922    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18923        self.inner.shutdown_with_epitaph(status)
18924    }
18925
18926    fn is_closed(&self) -> bool {
18927        self.inner.channel().is_closed()
18928    }
18929    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18930        self.inner.channel().on_closed()
18931    }
18932
18933    #[cfg(target_os = "fuchsia")]
18934    fn signal_peer(
18935        &self,
18936        clear_mask: zx::Signals,
18937        set_mask: zx::Signals,
18938    ) -> Result<(), zx_status::Status> {
18939        use fidl::Peered;
18940        self.inner.channel().signal_peer(clear_mask, set_mask)
18941    }
18942}
18943
18944impl UsageGainReporterControlHandle {}
18945
18946#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18947pub struct UsageReporterMarker;
18948
18949impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
18950    type Proxy = UsageReporterProxy;
18951    type RequestStream = UsageReporterRequestStream;
18952    #[cfg(target_os = "fuchsia")]
18953    type SynchronousProxy = UsageReporterSynchronousProxy;
18954
18955    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
18956}
18957impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
18958
18959pub trait UsageReporterProxyInterface: Send + Sync {
18960    fn r#watch(
18961        &self,
18962        usage: &Usage,
18963        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
18964    ) -> Result<(), fidl::Error>;
18965    fn r#watch2(
18966        &self,
18967        usage: &Usage2,
18968        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
18969    ) -> Result<(), fidl::Error>;
18970}
18971#[derive(Debug)]
18972#[cfg(target_os = "fuchsia")]
18973pub struct UsageReporterSynchronousProxy {
18974    client: fidl::client::sync::Client,
18975}
18976
18977#[cfg(target_os = "fuchsia")]
18978impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
18979    type Proxy = UsageReporterProxy;
18980    type Protocol = UsageReporterMarker;
18981
18982    fn from_channel(inner: fidl::Channel) -> Self {
18983        Self::new(inner)
18984    }
18985
18986    fn into_channel(self) -> fidl::Channel {
18987        self.client.into_channel()
18988    }
18989
18990    fn as_channel(&self) -> &fidl::Channel {
18991        self.client.as_channel()
18992    }
18993}
18994
18995#[cfg(target_os = "fuchsia")]
18996impl UsageReporterSynchronousProxy {
18997    pub fn new(channel: fidl::Channel) -> Self {
18998        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18999        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19000    }
19001
19002    pub fn into_channel(self) -> fidl::Channel {
19003        self.client.into_channel()
19004    }
19005
19006    /// Waits until an event arrives and returns it. It is safe for other
19007    /// threads to make concurrent requests while waiting for an event.
19008    pub fn wait_for_event(
19009        &self,
19010        deadline: zx::MonotonicInstant,
19011    ) -> Result<UsageReporterEvent, fidl::Error> {
19012        UsageReporterEvent::decode(self.client.wait_for_event(deadline)?)
19013    }
19014
19015    pub fn r#watch(
19016        &self,
19017        mut usage: &Usage,
19018        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19019    ) -> Result<(), fidl::Error> {
19020        self.client.send::<UsageReporterWatchRequest>(
19021            (usage, usage_watcher),
19022            0x769e6fb17075c959,
19023            fidl::encoding::DynamicFlags::empty(),
19024        )
19025    }
19026
19027    pub fn r#watch2(
19028        &self,
19029        mut usage: &Usage2,
19030        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19031    ) -> Result<(), fidl::Error> {
19032        self.client.send::<UsageReporterWatch2Request>(
19033            (usage, usage_watcher),
19034            0x4a43c4c82f5d8ce8,
19035            fidl::encoding::DynamicFlags::FLEXIBLE,
19036        )
19037    }
19038}
19039
19040#[cfg(target_os = "fuchsia")]
19041impl From<UsageReporterSynchronousProxy> for zx::Handle {
19042    fn from(value: UsageReporterSynchronousProxy) -> Self {
19043        value.into_channel().into()
19044    }
19045}
19046
19047#[cfg(target_os = "fuchsia")]
19048impl From<fidl::Channel> for UsageReporterSynchronousProxy {
19049    fn from(value: fidl::Channel) -> Self {
19050        Self::new(value)
19051    }
19052}
19053
19054#[cfg(target_os = "fuchsia")]
19055impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
19056    type Protocol = UsageReporterMarker;
19057
19058    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
19059        Self::new(value.into_channel())
19060    }
19061}
19062
19063#[derive(Debug, Clone)]
19064pub struct UsageReporterProxy {
19065    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19066}
19067
19068impl fidl::endpoints::Proxy for UsageReporterProxy {
19069    type Protocol = UsageReporterMarker;
19070
19071    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19072        Self::new(inner)
19073    }
19074
19075    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19076        self.client.into_channel().map_err(|client| Self { client })
19077    }
19078
19079    fn as_channel(&self) -> &::fidl::AsyncChannel {
19080        self.client.as_channel()
19081    }
19082}
19083
19084impl UsageReporterProxy {
19085    /// Create a new Proxy for fuchsia.media/UsageReporter.
19086    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19087        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19088        Self { client: fidl::client::Client::new(channel, protocol_name) }
19089    }
19090
19091    /// Get a Stream of events from the remote end of the protocol.
19092    ///
19093    /// # Panics
19094    ///
19095    /// Panics if the event stream was already taken.
19096    pub fn take_event_stream(&self) -> UsageReporterEventStream {
19097        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
19098    }
19099
19100    pub fn r#watch(
19101        &self,
19102        mut usage: &Usage,
19103        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19104    ) -> Result<(), fidl::Error> {
19105        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
19106    }
19107
19108    pub fn r#watch2(
19109        &self,
19110        mut usage: &Usage2,
19111        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19112    ) -> Result<(), fidl::Error> {
19113        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
19114    }
19115}
19116
19117impl UsageReporterProxyInterface for UsageReporterProxy {
19118    fn r#watch(
19119        &self,
19120        mut usage: &Usage,
19121        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19122    ) -> Result<(), fidl::Error> {
19123        self.client.send::<UsageReporterWatchRequest>(
19124            (usage, usage_watcher),
19125            0x769e6fb17075c959,
19126            fidl::encoding::DynamicFlags::empty(),
19127        )
19128    }
19129
19130    fn r#watch2(
19131        &self,
19132        mut usage: &Usage2,
19133        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19134    ) -> Result<(), fidl::Error> {
19135        self.client.send::<UsageReporterWatch2Request>(
19136            (usage, usage_watcher),
19137            0x4a43c4c82f5d8ce8,
19138            fidl::encoding::DynamicFlags::FLEXIBLE,
19139        )
19140    }
19141}
19142
19143pub struct UsageReporterEventStream {
19144    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19145}
19146
19147impl std::marker::Unpin for UsageReporterEventStream {}
19148
19149impl futures::stream::FusedStream for UsageReporterEventStream {
19150    fn is_terminated(&self) -> bool {
19151        self.event_receiver.is_terminated()
19152    }
19153}
19154
19155impl futures::Stream for UsageReporterEventStream {
19156    type Item = Result<UsageReporterEvent, fidl::Error>;
19157
19158    fn poll_next(
19159        mut self: std::pin::Pin<&mut Self>,
19160        cx: &mut std::task::Context<'_>,
19161    ) -> std::task::Poll<Option<Self::Item>> {
19162        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19163            &mut self.event_receiver,
19164            cx
19165        )?) {
19166            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
19167            None => std::task::Poll::Ready(None),
19168        }
19169    }
19170}
19171
19172#[derive(Debug)]
19173pub enum UsageReporterEvent {
19174    #[non_exhaustive]
19175    _UnknownEvent {
19176        /// Ordinal of the event that was sent.
19177        ordinal: u64,
19178    },
19179}
19180
19181impl UsageReporterEvent {
19182    /// Decodes a message buffer as a [`UsageReporterEvent`].
19183    fn decode(
19184        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19185    ) -> Result<UsageReporterEvent, fidl::Error> {
19186        let (bytes, _handles) = buf.split_mut();
19187        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19188        debug_assert_eq!(tx_header.tx_id, 0);
19189        match tx_header.ordinal {
19190            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19191                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
19192            }
19193            _ => Err(fidl::Error::UnknownOrdinal {
19194                ordinal: tx_header.ordinal,
19195                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19196            }),
19197        }
19198    }
19199}
19200
19201/// A Stream of incoming requests for fuchsia.media/UsageReporter.
19202pub struct UsageReporterRequestStream {
19203    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19204    is_terminated: bool,
19205}
19206
19207impl std::marker::Unpin for UsageReporterRequestStream {}
19208
19209impl futures::stream::FusedStream for UsageReporterRequestStream {
19210    fn is_terminated(&self) -> bool {
19211        self.is_terminated
19212    }
19213}
19214
19215impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
19216    type Protocol = UsageReporterMarker;
19217    type ControlHandle = UsageReporterControlHandle;
19218
19219    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19220        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19221    }
19222
19223    fn control_handle(&self) -> Self::ControlHandle {
19224        UsageReporterControlHandle { inner: self.inner.clone() }
19225    }
19226
19227    fn into_inner(
19228        self,
19229    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19230    {
19231        (self.inner, self.is_terminated)
19232    }
19233
19234    fn from_inner(
19235        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19236        is_terminated: bool,
19237    ) -> Self {
19238        Self { inner, is_terminated }
19239    }
19240}
19241
19242impl futures::Stream for UsageReporterRequestStream {
19243    type Item = Result<UsageReporterRequest, fidl::Error>;
19244
19245    fn poll_next(
19246        mut self: std::pin::Pin<&mut Self>,
19247        cx: &mut std::task::Context<'_>,
19248    ) -> std::task::Poll<Option<Self::Item>> {
19249        let this = &mut *self;
19250        if this.inner.check_shutdown(cx) {
19251            this.is_terminated = true;
19252            return std::task::Poll::Ready(None);
19253        }
19254        if this.is_terminated {
19255            panic!("polled UsageReporterRequestStream after completion");
19256        }
19257        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19258            |bytes, handles| {
19259                match this.inner.channel().read_etc(cx, bytes, handles) {
19260                    std::task::Poll::Ready(Ok(())) => {}
19261                    std::task::Poll::Pending => return std::task::Poll::Pending,
19262                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19263                        this.is_terminated = true;
19264                        return std::task::Poll::Ready(None);
19265                    }
19266                    std::task::Poll::Ready(Err(e)) => {
19267                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19268                            e.into(),
19269                        ))));
19270                    }
19271                }
19272
19273                // A message has been received from the channel
19274                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19275
19276                std::task::Poll::Ready(Some(match header.ordinal {
19277                    0x769e6fb17075c959 => {
19278                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19279                        let mut req = fidl::new_empty!(
19280                            UsageReporterWatchRequest,
19281                            fidl::encoding::DefaultFuchsiaResourceDialect
19282                        );
19283                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
19284                        let control_handle =
19285                            UsageReporterControlHandle { inner: this.inner.clone() };
19286                        Ok(UsageReporterRequest::Watch {
19287                            usage: req.usage,
19288                            usage_watcher: req.usage_watcher,
19289
19290                            control_handle,
19291                        })
19292                    }
19293                    0x4a43c4c82f5d8ce8 => {
19294                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19295                        let mut req = fidl::new_empty!(
19296                            UsageReporterWatch2Request,
19297                            fidl::encoding::DefaultFuchsiaResourceDialect
19298                        );
19299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
19300                        let control_handle =
19301                            UsageReporterControlHandle { inner: this.inner.clone() };
19302                        Ok(UsageReporterRequest::Watch2 {
19303                            usage: req.usage,
19304                            usage_watcher: req.usage_watcher,
19305
19306                            control_handle,
19307                        })
19308                    }
19309                    _ if header.tx_id == 0
19310                        && header
19311                            .dynamic_flags()
19312                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19313                    {
19314                        Ok(UsageReporterRequest::_UnknownMethod {
19315                            ordinal: header.ordinal,
19316                            control_handle: UsageReporterControlHandle {
19317                                inner: this.inner.clone(),
19318                            },
19319                            method_type: fidl::MethodType::OneWay,
19320                        })
19321                    }
19322                    _ if header
19323                        .dynamic_flags()
19324                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19325                    {
19326                        this.inner.send_framework_err(
19327                            fidl::encoding::FrameworkErr::UnknownMethod,
19328                            header.tx_id,
19329                            header.ordinal,
19330                            header.dynamic_flags(),
19331                            (bytes, handles),
19332                        )?;
19333                        Ok(UsageReporterRequest::_UnknownMethod {
19334                            ordinal: header.ordinal,
19335                            control_handle: UsageReporterControlHandle {
19336                                inner: this.inner.clone(),
19337                            },
19338                            method_type: fidl::MethodType::TwoWay,
19339                        })
19340                    }
19341                    _ => Err(fidl::Error::UnknownOrdinal {
19342                        ordinal: header.ordinal,
19343                        protocol_name:
19344                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19345                    }),
19346                }))
19347            },
19348        )
19349    }
19350}
19351
19352/// A protocol for setting up watchers of audio usages.
19353#[derive(Debug)]
19354pub enum UsageReporterRequest {
19355    Watch {
19356        usage: Usage,
19357        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19358        control_handle: UsageReporterControlHandle,
19359    },
19360    Watch2 {
19361        usage: Usage2,
19362        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19363        control_handle: UsageReporterControlHandle,
19364    },
19365    /// An interaction was received which does not match any known method.
19366    #[non_exhaustive]
19367    _UnknownMethod {
19368        /// Ordinal of the method that was called.
19369        ordinal: u64,
19370        control_handle: UsageReporterControlHandle,
19371        method_type: fidl::MethodType,
19372    },
19373}
19374
19375impl UsageReporterRequest {
19376    #[allow(irrefutable_let_patterns)]
19377    pub fn into_watch(
19378        self,
19379    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
19380    {
19381        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
19382            Some((usage, usage_watcher, control_handle))
19383        } else {
19384            None
19385        }
19386    }
19387
19388    #[allow(irrefutable_let_patterns)]
19389    pub fn into_watch2(
19390        self,
19391    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
19392    {
19393        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
19394            Some((usage, usage_watcher, control_handle))
19395        } else {
19396            None
19397        }
19398    }
19399
19400    /// Name of the method defined in FIDL
19401    pub fn method_name(&self) -> &'static str {
19402        match *self {
19403            UsageReporterRequest::Watch { .. } => "watch",
19404            UsageReporterRequest::Watch2 { .. } => "watch2",
19405            UsageReporterRequest::_UnknownMethod {
19406                method_type: fidl::MethodType::OneWay, ..
19407            } => "unknown one-way method",
19408            UsageReporterRequest::_UnknownMethod {
19409                method_type: fidl::MethodType::TwoWay, ..
19410            } => "unknown two-way method",
19411        }
19412    }
19413}
19414
19415#[derive(Debug, Clone)]
19416pub struct UsageReporterControlHandle {
19417    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19418}
19419
19420impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
19421    fn shutdown(&self) {
19422        self.inner.shutdown()
19423    }
19424    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19425        self.inner.shutdown_with_epitaph(status)
19426    }
19427
19428    fn is_closed(&self) -> bool {
19429        self.inner.channel().is_closed()
19430    }
19431    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19432        self.inner.channel().on_closed()
19433    }
19434
19435    #[cfg(target_os = "fuchsia")]
19436    fn signal_peer(
19437        &self,
19438        clear_mask: zx::Signals,
19439        set_mask: zx::Signals,
19440    ) -> Result<(), zx_status::Status> {
19441        use fidl::Peered;
19442        self.inner.channel().signal_peer(clear_mask, set_mask)
19443    }
19444}
19445
19446impl UsageReporterControlHandle {}
19447
19448#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19449pub struct UsageWatcherMarker;
19450
19451impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
19452    type Proxy = UsageWatcherProxy;
19453    type RequestStream = UsageWatcherRequestStream;
19454    #[cfg(target_os = "fuchsia")]
19455    type SynchronousProxy = UsageWatcherSynchronousProxy;
19456
19457    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
19458}
19459
19460pub trait UsageWatcherProxyInterface: Send + Sync {
19461    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19462    fn r#on_state_changed(
19463        &self,
19464        usage: &Usage,
19465        state: &UsageState,
19466    ) -> Self::OnStateChangedResponseFut;
19467}
19468#[derive(Debug)]
19469#[cfg(target_os = "fuchsia")]
19470pub struct UsageWatcherSynchronousProxy {
19471    client: fidl::client::sync::Client,
19472}
19473
19474#[cfg(target_os = "fuchsia")]
19475impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
19476    type Proxy = UsageWatcherProxy;
19477    type Protocol = UsageWatcherMarker;
19478
19479    fn from_channel(inner: fidl::Channel) -> Self {
19480        Self::new(inner)
19481    }
19482
19483    fn into_channel(self) -> fidl::Channel {
19484        self.client.into_channel()
19485    }
19486
19487    fn as_channel(&self) -> &fidl::Channel {
19488        self.client.as_channel()
19489    }
19490}
19491
19492#[cfg(target_os = "fuchsia")]
19493impl UsageWatcherSynchronousProxy {
19494    pub fn new(channel: fidl::Channel) -> Self {
19495        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19496        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19497    }
19498
19499    pub fn into_channel(self) -> fidl::Channel {
19500        self.client.into_channel()
19501    }
19502
19503    /// Waits until an event arrives and returns it. It is safe for other
19504    /// threads to make concurrent requests while waiting for an event.
19505    pub fn wait_for_event(
19506        &self,
19507        deadline: zx::MonotonicInstant,
19508    ) -> Result<UsageWatcherEvent, fidl::Error> {
19509        UsageWatcherEvent::decode(self.client.wait_for_event(deadline)?)
19510    }
19511
19512    /// Called on first connection and whenever the watched usage changes. The provided
19513    /// usage will always be the bound usage; it is provided so that an implementation of
19514    /// this protocol may be bound to more than one usage.
19515    ///
19516    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19517    /// events will eventually be disconnected.
19518    pub fn r#on_state_changed(
19519        &self,
19520        mut usage: &Usage,
19521        mut state: &UsageState,
19522        ___deadline: zx::MonotonicInstant,
19523    ) -> Result<(), fidl::Error> {
19524        let _response = self
19525            .client
19526            .send_query::<UsageWatcherOnStateChangedRequest, fidl::encoding::EmptyPayload>(
19527                (usage, state),
19528                0x5b955c5768ec75c5,
19529                fidl::encoding::DynamicFlags::empty(),
19530                ___deadline,
19531            )?;
19532        Ok(_response)
19533    }
19534}
19535
19536#[cfg(target_os = "fuchsia")]
19537impl From<UsageWatcherSynchronousProxy> for zx::Handle {
19538    fn from(value: UsageWatcherSynchronousProxy) -> Self {
19539        value.into_channel().into()
19540    }
19541}
19542
19543#[cfg(target_os = "fuchsia")]
19544impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
19545    fn from(value: fidl::Channel) -> Self {
19546        Self::new(value)
19547    }
19548}
19549
19550#[cfg(target_os = "fuchsia")]
19551impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
19552    type Protocol = UsageWatcherMarker;
19553
19554    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
19555        Self::new(value.into_channel())
19556    }
19557}
19558
19559#[derive(Debug, Clone)]
19560pub struct UsageWatcherProxy {
19561    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19562}
19563
19564impl fidl::endpoints::Proxy for UsageWatcherProxy {
19565    type Protocol = UsageWatcherMarker;
19566
19567    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19568        Self::new(inner)
19569    }
19570
19571    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19572        self.client.into_channel().map_err(|client| Self { client })
19573    }
19574
19575    fn as_channel(&self) -> &::fidl::AsyncChannel {
19576        self.client.as_channel()
19577    }
19578}
19579
19580impl UsageWatcherProxy {
19581    /// Create a new Proxy for fuchsia.media/UsageWatcher.
19582    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19583        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19584        Self { client: fidl::client::Client::new(channel, protocol_name) }
19585    }
19586
19587    /// Get a Stream of events from the remote end of the protocol.
19588    ///
19589    /// # Panics
19590    ///
19591    /// Panics if the event stream was already taken.
19592    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
19593        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
19594    }
19595
19596    /// Called on first connection and whenever the watched usage changes. The provided
19597    /// usage will always be the bound usage; it is provided so that an implementation of
19598    /// this protocol may be bound to more than one usage.
19599    ///
19600    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19601    /// events will eventually be disconnected.
19602    pub fn r#on_state_changed(
19603        &self,
19604        mut usage: &Usage,
19605        mut state: &UsageState,
19606    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
19607        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
19608    }
19609}
19610
19611impl UsageWatcherProxyInterface for UsageWatcherProxy {
19612    type OnStateChangedResponseFut =
19613        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
19614    fn r#on_state_changed(
19615        &self,
19616        mut usage: &Usage,
19617        mut state: &UsageState,
19618    ) -> Self::OnStateChangedResponseFut {
19619        fn _decode(
19620            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
19621        ) -> Result<(), fidl::Error> {
19622            let _response = fidl::client::decode_transaction_body::<
19623                fidl::encoding::EmptyPayload,
19624                fidl::encoding::DefaultFuchsiaResourceDialect,
19625                0x5b955c5768ec75c5,
19626            >(_buf?)?;
19627            Ok(_response)
19628        }
19629        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
19630            (usage, state),
19631            0x5b955c5768ec75c5,
19632            fidl::encoding::DynamicFlags::empty(),
19633            _decode,
19634        )
19635    }
19636}
19637
19638pub struct UsageWatcherEventStream {
19639    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19640}
19641
19642impl std::marker::Unpin for UsageWatcherEventStream {}
19643
19644impl futures::stream::FusedStream for UsageWatcherEventStream {
19645    fn is_terminated(&self) -> bool {
19646        self.event_receiver.is_terminated()
19647    }
19648}
19649
19650impl futures::Stream for UsageWatcherEventStream {
19651    type Item = Result<UsageWatcherEvent, fidl::Error>;
19652
19653    fn poll_next(
19654        mut self: std::pin::Pin<&mut Self>,
19655        cx: &mut std::task::Context<'_>,
19656    ) -> std::task::Poll<Option<Self::Item>> {
19657        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19658            &mut self.event_receiver,
19659            cx
19660        )?) {
19661            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
19662            None => std::task::Poll::Ready(None),
19663        }
19664    }
19665}
19666
19667#[derive(Debug)]
19668pub enum UsageWatcherEvent {}
19669
19670impl UsageWatcherEvent {
19671    /// Decodes a message buffer as a [`UsageWatcherEvent`].
19672    fn decode(
19673        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19674    ) -> Result<UsageWatcherEvent, fidl::Error> {
19675        let (bytes, _handles) = buf.split_mut();
19676        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19677        debug_assert_eq!(tx_header.tx_id, 0);
19678        match tx_header.ordinal {
19679            _ => Err(fidl::Error::UnknownOrdinal {
19680                ordinal: tx_header.ordinal,
19681                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19682            }),
19683        }
19684    }
19685}
19686
19687/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
19688pub struct UsageWatcherRequestStream {
19689    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19690    is_terminated: bool,
19691}
19692
19693impl std::marker::Unpin for UsageWatcherRequestStream {}
19694
19695impl futures::stream::FusedStream for UsageWatcherRequestStream {
19696    fn is_terminated(&self) -> bool {
19697        self.is_terminated
19698    }
19699}
19700
19701impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
19702    type Protocol = UsageWatcherMarker;
19703    type ControlHandle = UsageWatcherControlHandle;
19704
19705    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19706        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19707    }
19708
19709    fn control_handle(&self) -> Self::ControlHandle {
19710        UsageWatcherControlHandle { inner: self.inner.clone() }
19711    }
19712
19713    fn into_inner(
19714        self,
19715    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19716    {
19717        (self.inner, self.is_terminated)
19718    }
19719
19720    fn from_inner(
19721        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19722        is_terminated: bool,
19723    ) -> Self {
19724        Self { inner, is_terminated }
19725    }
19726}
19727
19728impl futures::Stream for UsageWatcherRequestStream {
19729    type Item = Result<UsageWatcherRequest, fidl::Error>;
19730
19731    fn poll_next(
19732        mut self: std::pin::Pin<&mut Self>,
19733        cx: &mut std::task::Context<'_>,
19734    ) -> std::task::Poll<Option<Self::Item>> {
19735        let this = &mut *self;
19736        if this.inner.check_shutdown(cx) {
19737            this.is_terminated = true;
19738            return std::task::Poll::Ready(None);
19739        }
19740        if this.is_terminated {
19741            panic!("polled UsageWatcherRequestStream after completion");
19742        }
19743        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19744            |bytes, handles| {
19745                match this.inner.channel().read_etc(cx, bytes, handles) {
19746                    std::task::Poll::Ready(Ok(())) => {}
19747                    std::task::Poll::Pending => return std::task::Poll::Pending,
19748                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19749                        this.is_terminated = true;
19750                        return std::task::Poll::Ready(None);
19751                    }
19752                    std::task::Poll::Ready(Err(e)) => {
19753                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19754                            e.into(),
19755                        ))));
19756                    }
19757                }
19758
19759                // A message has been received from the channel
19760                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19761
19762                std::task::Poll::Ready(Some(match header.ordinal {
19763                    0x5b955c5768ec75c5 => {
19764                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19765                        let mut req = fidl::new_empty!(
19766                            UsageWatcherOnStateChangedRequest,
19767                            fidl::encoding::DefaultFuchsiaResourceDialect
19768                        );
19769                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
19770                        let control_handle =
19771                            UsageWatcherControlHandle { inner: this.inner.clone() };
19772                        Ok(UsageWatcherRequest::OnStateChanged {
19773                            usage: req.usage,
19774                            state: req.state,
19775
19776                            responder: UsageWatcherOnStateChangedResponder {
19777                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19778                                tx_id: header.tx_id,
19779                            },
19780                        })
19781                    }
19782                    _ => Err(fidl::Error::UnknownOrdinal {
19783                        ordinal: header.ordinal,
19784                        protocol_name:
19785                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19786                    }),
19787                }))
19788            },
19789        )
19790    }
19791}
19792
19793/// A protocol for listening to changes to the policy state of an audio usage.
19794///
19795/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
19796#[derive(Debug)]
19797pub enum UsageWatcherRequest {
19798    /// Called on first connection and whenever the watched usage changes. The provided
19799    /// usage will always be the bound usage; it is provided so that an implementation of
19800    /// this protocol may be bound to more than one usage.
19801    ///
19802    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19803    /// events will eventually be disconnected.
19804    OnStateChanged {
19805        usage: Usage,
19806        state: UsageState,
19807        responder: UsageWatcherOnStateChangedResponder,
19808    },
19809}
19810
19811impl UsageWatcherRequest {
19812    #[allow(irrefutable_let_patterns)]
19813    pub fn into_on_state_changed(
19814        self,
19815    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
19816        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
19817            Some((usage, state, responder))
19818        } else {
19819            None
19820        }
19821    }
19822
19823    /// Name of the method defined in FIDL
19824    pub fn method_name(&self) -> &'static str {
19825        match *self {
19826            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
19827        }
19828    }
19829}
19830
19831#[derive(Debug, Clone)]
19832pub struct UsageWatcherControlHandle {
19833    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19834}
19835
19836impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
19837    fn shutdown(&self) {
19838        self.inner.shutdown()
19839    }
19840    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19841        self.inner.shutdown_with_epitaph(status)
19842    }
19843
19844    fn is_closed(&self) -> bool {
19845        self.inner.channel().is_closed()
19846    }
19847    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19848        self.inner.channel().on_closed()
19849    }
19850
19851    #[cfg(target_os = "fuchsia")]
19852    fn signal_peer(
19853        &self,
19854        clear_mask: zx::Signals,
19855        set_mask: zx::Signals,
19856    ) -> Result<(), zx_status::Status> {
19857        use fidl::Peered;
19858        self.inner.channel().signal_peer(clear_mask, set_mask)
19859    }
19860}
19861
19862impl UsageWatcherControlHandle {}
19863
19864#[must_use = "FIDL methods require a response to be sent"]
19865#[derive(Debug)]
19866pub struct UsageWatcherOnStateChangedResponder {
19867    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
19868    tx_id: u32,
19869}
19870
19871/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
19872/// if the responder is dropped without sending a response, so that the client
19873/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19874impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
19875    fn drop(&mut self) {
19876        self.control_handle.shutdown();
19877        // Safety: drops once, never accessed again
19878        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19879    }
19880}
19881
19882impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
19883    type ControlHandle = UsageWatcherControlHandle;
19884
19885    fn control_handle(&self) -> &UsageWatcherControlHandle {
19886        &self.control_handle
19887    }
19888
19889    fn drop_without_shutdown(mut self) {
19890        // Safety: drops once, never accessed again due to mem::forget
19891        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19892        // Prevent Drop from running (which would shut down the channel)
19893        std::mem::forget(self);
19894    }
19895}
19896
19897impl UsageWatcherOnStateChangedResponder {
19898    /// Sends a response to the FIDL transaction.
19899    ///
19900    /// Sets the channel to shutdown if an error occurs.
19901    pub fn send(self) -> Result<(), fidl::Error> {
19902        let _result = self.send_raw();
19903        if _result.is_err() {
19904            self.control_handle.shutdown();
19905        }
19906        self.drop_without_shutdown();
19907        _result
19908    }
19909
19910    /// Similar to "send" but does not shutdown the channel if an error occurs.
19911    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
19912        let _result = self.send_raw();
19913        self.drop_without_shutdown();
19914        _result
19915    }
19916
19917    fn send_raw(&self) -> Result<(), fidl::Error> {
19918        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
19919            (),
19920            self.tx_id,
19921            0x5b955c5768ec75c5,
19922            fidl::encoding::DynamicFlags::empty(),
19923        )
19924    }
19925}
19926
19927#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19928pub struct UsageWatcher2Marker;
19929
19930impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
19931    type Proxy = UsageWatcher2Proxy;
19932    type RequestStream = UsageWatcher2RequestStream;
19933    #[cfg(target_os = "fuchsia")]
19934    type SynchronousProxy = UsageWatcher2SynchronousProxy;
19935
19936    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
19937}
19938
19939pub trait UsageWatcher2ProxyInterface: Send + Sync {
19940    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19941    fn r#on_state_changed(
19942        &self,
19943        usage: &Usage2,
19944        state: &UsageState,
19945    ) -> Self::OnStateChangedResponseFut;
19946}
19947#[derive(Debug)]
19948#[cfg(target_os = "fuchsia")]
19949pub struct UsageWatcher2SynchronousProxy {
19950    client: fidl::client::sync::Client,
19951}
19952
19953#[cfg(target_os = "fuchsia")]
19954impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
19955    type Proxy = UsageWatcher2Proxy;
19956    type Protocol = UsageWatcher2Marker;
19957
19958    fn from_channel(inner: fidl::Channel) -> Self {
19959        Self::new(inner)
19960    }
19961
19962    fn into_channel(self) -> fidl::Channel {
19963        self.client.into_channel()
19964    }
19965
19966    fn as_channel(&self) -> &fidl::Channel {
19967        self.client.as_channel()
19968    }
19969}
19970
19971#[cfg(target_os = "fuchsia")]
19972impl UsageWatcher2SynchronousProxy {
19973    pub fn new(channel: fidl::Channel) -> Self {
19974        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19975        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19976    }
19977
19978    pub fn into_channel(self) -> fidl::Channel {
19979        self.client.into_channel()
19980    }
19981
19982    /// Waits until an event arrives and returns it. It is safe for other
19983    /// threads to make concurrent requests while waiting for an event.
19984    pub fn wait_for_event(
19985        &self,
19986        deadline: zx::MonotonicInstant,
19987    ) -> Result<UsageWatcher2Event, fidl::Error> {
19988        UsageWatcher2Event::decode(self.client.wait_for_event(deadline)?)
19989    }
19990
19991    /// Called on first connection and whenever the watched usage changes. The provided
19992    /// usage will always be the bound usage; it is provided so that an implementation of
19993    /// this protocol may be bound to more than one usage.
19994    ///
19995    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19996    /// events will eventually be disconnected.
19997    pub fn r#on_state_changed(
19998        &self,
19999        mut usage: &Usage2,
20000        mut state: &UsageState,
20001        ___deadline: zx::MonotonicInstant,
20002    ) -> Result<(), fidl::Error> {
20003        let _response = self
20004            .client
20005            .send_query::<UsageWatcher2OnStateChangedRequest, fidl::encoding::EmptyPayload>(
20006                (usage, state),
20007                0xca31a8b13c324d4,
20008                fidl::encoding::DynamicFlags::empty(),
20009                ___deadline,
20010            )?;
20011        Ok(_response)
20012    }
20013}
20014
20015#[cfg(target_os = "fuchsia")]
20016impl From<UsageWatcher2SynchronousProxy> for zx::Handle {
20017    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
20018        value.into_channel().into()
20019    }
20020}
20021
20022#[cfg(target_os = "fuchsia")]
20023impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
20024    fn from(value: fidl::Channel) -> Self {
20025        Self::new(value)
20026    }
20027}
20028
20029#[cfg(target_os = "fuchsia")]
20030impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
20031    type Protocol = UsageWatcher2Marker;
20032
20033    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
20034        Self::new(value.into_channel())
20035    }
20036}
20037
20038#[derive(Debug, Clone)]
20039pub struct UsageWatcher2Proxy {
20040    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20041}
20042
20043impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
20044    type Protocol = UsageWatcher2Marker;
20045
20046    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20047        Self::new(inner)
20048    }
20049
20050    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20051        self.client.into_channel().map_err(|client| Self { client })
20052    }
20053
20054    fn as_channel(&self) -> &::fidl::AsyncChannel {
20055        self.client.as_channel()
20056    }
20057}
20058
20059impl UsageWatcher2Proxy {
20060    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
20061    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20062        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20063        Self { client: fidl::client::Client::new(channel, protocol_name) }
20064    }
20065
20066    /// Get a Stream of events from the remote end of the protocol.
20067    ///
20068    /// # Panics
20069    ///
20070    /// Panics if the event stream was already taken.
20071    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
20072        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
20073    }
20074
20075    /// Called on first connection and whenever the watched usage changes. The provided
20076    /// usage will always be the bound usage; it is provided so that an implementation of
20077    /// this protocol may be bound to more than one usage.
20078    ///
20079    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20080    /// events will eventually be disconnected.
20081    pub fn r#on_state_changed(
20082        &self,
20083        mut usage: &Usage2,
20084        mut state: &UsageState,
20085    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20086        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
20087    }
20088}
20089
20090impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
20091    type OnStateChangedResponseFut =
20092        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20093    fn r#on_state_changed(
20094        &self,
20095        mut usage: &Usage2,
20096        mut state: &UsageState,
20097    ) -> Self::OnStateChangedResponseFut {
20098        fn _decode(
20099            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20100        ) -> Result<(), fidl::Error> {
20101            let _response = fidl::client::decode_transaction_body::<
20102                fidl::encoding::EmptyPayload,
20103                fidl::encoding::DefaultFuchsiaResourceDialect,
20104                0xca31a8b13c324d4,
20105            >(_buf?)?;
20106            Ok(_response)
20107        }
20108        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
20109            (usage, state),
20110            0xca31a8b13c324d4,
20111            fidl::encoding::DynamicFlags::empty(),
20112            _decode,
20113        )
20114    }
20115}
20116
20117pub struct UsageWatcher2EventStream {
20118    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20119}
20120
20121impl std::marker::Unpin for UsageWatcher2EventStream {}
20122
20123impl futures::stream::FusedStream for UsageWatcher2EventStream {
20124    fn is_terminated(&self) -> bool {
20125        self.event_receiver.is_terminated()
20126    }
20127}
20128
20129impl futures::Stream for UsageWatcher2EventStream {
20130    type Item = Result<UsageWatcher2Event, fidl::Error>;
20131
20132    fn poll_next(
20133        mut self: std::pin::Pin<&mut Self>,
20134        cx: &mut std::task::Context<'_>,
20135    ) -> std::task::Poll<Option<Self::Item>> {
20136        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20137            &mut self.event_receiver,
20138            cx
20139        )?) {
20140            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
20141            None => std::task::Poll::Ready(None),
20142        }
20143    }
20144}
20145
20146#[derive(Debug)]
20147pub enum UsageWatcher2Event {}
20148
20149impl UsageWatcher2Event {
20150    /// Decodes a message buffer as a [`UsageWatcher2Event`].
20151    fn decode(
20152        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20153    ) -> Result<UsageWatcher2Event, fidl::Error> {
20154        let (bytes, _handles) = buf.split_mut();
20155        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20156        debug_assert_eq!(tx_header.tx_id, 0);
20157        match tx_header.ordinal {
20158            _ => Err(fidl::Error::UnknownOrdinal {
20159                ordinal: tx_header.ordinal,
20160                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20161            }),
20162        }
20163    }
20164}
20165
20166/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
20167pub struct UsageWatcher2RequestStream {
20168    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20169    is_terminated: bool,
20170}
20171
20172impl std::marker::Unpin for UsageWatcher2RequestStream {}
20173
20174impl futures::stream::FusedStream for UsageWatcher2RequestStream {
20175    fn is_terminated(&self) -> bool {
20176        self.is_terminated
20177    }
20178}
20179
20180impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
20181    type Protocol = UsageWatcher2Marker;
20182    type ControlHandle = UsageWatcher2ControlHandle;
20183
20184    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20185        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20186    }
20187
20188    fn control_handle(&self) -> Self::ControlHandle {
20189        UsageWatcher2ControlHandle { inner: self.inner.clone() }
20190    }
20191
20192    fn into_inner(
20193        self,
20194    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20195    {
20196        (self.inner, self.is_terminated)
20197    }
20198
20199    fn from_inner(
20200        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20201        is_terminated: bool,
20202    ) -> Self {
20203        Self { inner, is_terminated }
20204    }
20205}
20206
20207impl futures::Stream for UsageWatcher2RequestStream {
20208    type Item = Result<UsageWatcher2Request, fidl::Error>;
20209
20210    fn poll_next(
20211        mut self: std::pin::Pin<&mut Self>,
20212        cx: &mut std::task::Context<'_>,
20213    ) -> std::task::Poll<Option<Self::Item>> {
20214        let this = &mut *self;
20215        if this.inner.check_shutdown(cx) {
20216            this.is_terminated = true;
20217            return std::task::Poll::Ready(None);
20218        }
20219        if this.is_terminated {
20220            panic!("polled UsageWatcher2RequestStream after completion");
20221        }
20222        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20223            |bytes, handles| {
20224                match this.inner.channel().read_etc(cx, bytes, handles) {
20225                    std::task::Poll::Ready(Ok(())) => {}
20226                    std::task::Poll::Pending => return std::task::Poll::Pending,
20227                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20228                        this.is_terminated = true;
20229                        return std::task::Poll::Ready(None);
20230                    }
20231                    std::task::Poll::Ready(Err(e)) => {
20232                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20233                            e.into(),
20234                        ))));
20235                    }
20236                }
20237
20238                // A message has been received from the channel
20239                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20240
20241                std::task::Poll::Ready(Some(match header.ordinal {
20242                    0xca31a8b13c324d4 => {
20243                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20244                        let mut req = fidl::new_empty!(
20245                            UsageWatcher2OnStateChangedRequest,
20246                            fidl::encoding::DefaultFuchsiaResourceDialect
20247                        );
20248                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20249                        let control_handle =
20250                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
20251                        Ok(UsageWatcher2Request::OnStateChanged {
20252                            usage: req.usage,
20253                            state: req.state,
20254
20255                            responder: UsageWatcher2OnStateChangedResponder {
20256                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20257                                tx_id: header.tx_id,
20258                            },
20259                        })
20260                    }
20261                    _ => Err(fidl::Error::UnknownOrdinal {
20262                        ordinal: header.ordinal,
20263                        protocol_name:
20264                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20265                    }),
20266                }))
20267            },
20268        )
20269    }
20270}
20271
20272#[derive(Debug)]
20273pub enum UsageWatcher2Request {
20274    /// Called on first connection and whenever the watched usage changes. The provided
20275    /// usage will always be the bound usage; it is provided so that an implementation of
20276    /// this protocol may be bound to more than one usage.
20277    ///
20278    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20279    /// events will eventually be disconnected.
20280    OnStateChanged {
20281        usage: Usage2,
20282        state: UsageState,
20283        responder: UsageWatcher2OnStateChangedResponder,
20284    },
20285}
20286
20287impl UsageWatcher2Request {
20288    #[allow(irrefutable_let_patterns)]
20289    pub fn into_on_state_changed(
20290        self,
20291    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
20292        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
20293            Some((usage, state, responder))
20294        } else {
20295            None
20296        }
20297    }
20298
20299    /// Name of the method defined in FIDL
20300    pub fn method_name(&self) -> &'static str {
20301        match *self {
20302            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
20303        }
20304    }
20305}
20306
20307#[derive(Debug, Clone)]
20308pub struct UsageWatcher2ControlHandle {
20309    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20310}
20311
20312impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
20313    fn shutdown(&self) {
20314        self.inner.shutdown()
20315    }
20316    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20317        self.inner.shutdown_with_epitaph(status)
20318    }
20319
20320    fn is_closed(&self) -> bool {
20321        self.inner.channel().is_closed()
20322    }
20323    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20324        self.inner.channel().on_closed()
20325    }
20326
20327    #[cfg(target_os = "fuchsia")]
20328    fn signal_peer(
20329        &self,
20330        clear_mask: zx::Signals,
20331        set_mask: zx::Signals,
20332    ) -> Result<(), zx_status::Status> {
20333        use fidl::Peered;
20334        self.inner.channel().signal_peer(clear_mask, set_mask)
20335    }
20336}
20337
20338impl UsageWatcher2ControlHandle {}
20339
20340#[must_use = "FIDL methods require a response to be sent"]
20341#[derive(Debug)]
20342pub struct UsageWatcher2OnStateChangedResponder {
20343    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
20344    tx_id: u32,
20345}
20346
20347/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
20348/// if the responder is dropped without sending a response, so that the client
20349/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20350impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
20351    fn drop(&mut self) {
20352        self.control_handle.shutdown();
20353        // Safety: drops once, never accessed again
20354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20355    }
20356}
20357
20358impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
20359    type ControlHandle = UsageWatcher2ControlHandle;
20360
20361    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
20362        &self.control_handle
20363    }
20364
20365    fn drop_without_shutdown(mut self) {
20366        // Safety: drops once, never accessed again due to mem::forget
20367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20368        // Prevent Drop from running (which would shut down the channel)
20369        std::mem::forget(self);
20370    }
20371}
20372
20373impl UsageWatcher2OnStateChangedResponder {
20374    /// Sends a response to the FIDL transaction.
20375    ///
20376    /// Sets the channel to shutdown if an error occurs.
20377    pub fn send(self) -> Result<(), fidl::Error> {
20378        let _result = self.send_raw();
20379        if _result.is_err() {
20380            self.control_handle.shutdown();
20381        }
20382        self.drop_without_shutdown();
20383        _result
20384    }
20385
20386    /// Similar to "send" but does not shutdown the channel if an error occurs.
20387    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20388        let _result = self.send_raw();
20389        self.drop_without_shutdown();
20390        _result
20391    }
20392
20393    fn send_raw(&self) -> Result<(), fidl::Error> {
20394        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20395            (),
20396            self.tx_id,
20397            0xca31a8b13c324d4,
20398            fidl::encoding::DynamicFlags::empty(),
20399        )
20400    }
20401}
20402
20403mod internal {
20404    use super::*;
20405
20406    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
20407        type Borrowed<'a> = &'a mut Self;
20408        fn take_or_borrow<'a>(
20409            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20410        ) -> Self::Borrowed<'a> {
20411            value
20412        }
20413    }
20414
20415    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
20416        type Owned = Self;
20417
20418        #[inline(always)]
20419        fn inline_align(_context: fidl::encoding::Context) -> usize {
20420            4
20421        }
20422
20423        #[inline(always)]
20424        fn inline_size(_context: fidl::encoding::Context) -> usize {
20425            4
20426        }
20427    }
20428
20429    unsafe impl
20430        fidl::encoding::Encode<
20431            AudioCapturerBindGainControlRequest,
20432            fidl::encoding::DefaultFuchsiaResourceDialect,
20433        > for &mut AudioCapturerBindGainControlRequest
20434    {
20435        #[inline]
20436        unsafe fn encode(
20437            self,
20438            encoder: &mut fidl::encoding::Encoder<
20439                '_,
20440                fidl::encoding::DefaultFuchsiaResourceDialect,
20441            >,
20442            offset: usize,
20443            _depth: fidl::encoding::Depth,
20444        ) -> fidl::Result<()> {
20445            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20446            // Delegate to tuple encoding.
20447            fidl::encoding::Encode::<
20448                AudioCapturerBindGainControlRequest,
20449                fidl::encoding::DefaultFuchsiaResourceDialect,
20450            >::encode(
20451                (<fidl::encoding::Endpoint<
20452                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20453                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20454                    &mut self.gain_control_request,
20455                ),),
20456                encoder,
20457                offset,
20458                _depth,
20459            )
20460        }
20461    }
20462    unsafe impl<
20463        T0: fidl::encoding::Encode<
20464                fidl::encoding::Endpoint<
20465                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20466                >,
20467                fidl::encoding::DefaultFuchsiaResourceDialect,
20468            >,
20469    >
20470        fidl::encoding::Encode<
20471            AudioCapturerBindGainControlRequest,
20472            fidl::encoding::DefaultFuchsiaResourceDialect,
20473        > for (T0,)
20474    {
20475        #[inline]
20476        unsafe fn encode(
20477            self,
20478            encoder: &mut fidl::encoding::Encoder<
20479                '_,
20480                fidl::encoding::DefaultFuchsiaResourceDialect,
20481            >,
20482            offset: usize,
20483            depth: fidl::encoding::Depth,
20484        ) -> fidl::Result<()> {
20485            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20486            // Zero out padding regions. There's no need to apply masks
20487            // because the unmasked parts will be overwritten by fields.
20488            // Write the fields.
20489            self.0.encode(encoder, offset + 0, depth)?;
20490            Ok(())
20491        }
20492    }
20493
20494    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20495        for AudioCapturerBindGainControlRequest
20496    {
20497        #[inline(always)]
20498        fn new_empty() -> Self {
20499            Self {
20500                gain_control_request: fidl::new_empty!(
20501                    fidl::encoding::Endpoint<
20502                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20503                    >,
20504                    fidl::encoding::DefaultFuchsiaResourceDialect
20505                ),
20506            }
20507        }
20508
20509        #[inline]
20510        unsafe fn decode(
20511            &mut self,
20512            decoder: &mut fidl::encoding::Decoder<
20513                '_,
20514                fidl::encoding::DefaultFuchsiaResourceDialect,
20515            >,
20516            offset: usize,
20517            _depth: fidl::encoding::Depth,
20518        ) -> fidl::Result<()> {
20519            decoder.debug_check_bounds::<Self>(offset);
20520            // Verify that padding bytes are zero.
20521            fidl::decode!(
20522                fidl::encoding::Endpoint<
20523                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20524                >,
20525                fidl::encoding::DefaultFuchsiaResourceDialect,
20526                &mut self.gain_control_request,
20527                decoder,
20528                offset + 0,
20529                _depth
20530            )?;
20531            Ok(())
20532        }
20533    }
20534
20535    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
20536        type Borrowed<'a> = &'a mut Self;
20537        fn take_or_borrow<'a>(
20538            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20539        ) -> Self::Borrowed<'a> {
20540            value
20541        }
20542    }
20543
20544    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
20545        type Owned = Self;
20546
20547        #[inline(always)]
20548        fn inline_align(_context: fidl::encoding::Context) -> usize {
20549            4
20550        }
20551
20552        #[inline(always)]
20553        fn inline_size(_context: fidl::encoding::Context) -> usize {
20554            4
20555        }
20556    }
20557
20558    unsafe impl
20559        fidl::encoding::Encode<
20560            AudioCapturerGetReferenceClockResponse,
20561            fidl::encoding::DefaultFuchsiaResourceDialect,
20562        > for &mut AudioCapturerGetReferenceClockResponse
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::<AudioCapturerGetReferenceClockResponse>(offset);
20575            // Delegate to tuple encoding.
20576            fidl::encoding::Encode::<
20577                AudioCapturerGetReferenceClockResponse,
20578                fidl::encoding::DefaultFuchsiaResourceDialect,
20579            >::encode(
20580                (<fidl::encoding::HandleType<
20581                    fidl::Clock,
20582                    { fidl::ObjectType::CLOCK.into_raw() },
20583                    2147483648,
20584                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20585                    &mut self.reference_clock,
20586                ),),
20587                encoder,
20588                offset,
20589                _depth,
20590            )
20591        }
20592    }
20593    unsafe impl<
20594        T0: fidl::encoding::Encode<
20595                fidl::encoding::HandleType<
20596                    fidl::Clock,
20597                    { fidl::ObjectType::CLOCK.into_raw() },
20598                    2147483648,
20599                >,
20600                fidl::encoding::DefaultFuchsiaResourceDialect,
20601            >,
20602    >
20603        fidl::encoding::Encode<
20604            AudioCapturerGetReferenceClockResponse,
20605            fidl::encoding::DefaultFuchsiaResourceDialect,
20606        > for (T0,)
20607    {
20608        #[inline]
20609        unsafe fn encode(
20610            self,
20611            encoder: &mut fidl::encoding::Encoder<
20612                '_,
20613                fidl::encoding::DefaultFuchsiaResourceDialect,
20614            >,
20615            offset: usize,
20616            depth: fidl::encoding::Depth,
20617        ) -> fidl::Result<()> {
20618            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20619            // Zero out padding regions. There's no need to apply masks
20620            // because the unmasked parts will be overwritten by fields.
20621            // Write the fields.
20622            self.0.encode(encoder, offset + 0, depth)?;
20623            Ok(())
20624        }
20625    }
20626
20627    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20628        for AudioCapturerGetReferenceClockResponse
20629    {
20630        #[inline(always)]
20631        fn new_empty() -> Self {
20632            Self {
20633                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
20634            }
20635        }
20636
20637        #[inline]
20638        unsafe fn decode(
20639            &mut self,
20640            decoder: &mut fidl::encoding::Decoder<
20641                '_,
20642                fidl::encoding::DefaultFuchsiaResourceDialect,
20643            >,
20644            offset: usize,
20645            _depth: fidl::encoding::Depth,
20646        ) -> fidl::Result<()> {
20647            decoder.debug_check_bounds::<Self>(offset);
20648            // Verify that padding bytes are zero.
20649            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20650            Ok(())
20651        }
20652    }
20653
20654    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
20655        type Borrowed<'a> = &'a mut Self;
20656        fn take_or_borrow<'a>(
20657            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20658        ) -> Self::Borrowed<'a> {
20659            value
20660        }
20661    }
20662
20663    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
20664        type Owned = Self;
20665
20666        #[inline(always)]
20667        fn inline_align(_context: fidl::encoding::Context) -> usize {
20668            4
20669        }
20670
20671        #[inline(always)]
20672        fn inline_size(_context: fidl::encoding::Context) -> usize {
20673            4
20674        }
20675    }
20676
20677    unsafe impl
20678        fidl::encoding::Encode<
20679            AudioCapturerSetReferenceClockRequest,
20680            fidl::encoding::DefaultFuchsiaResourceDialect,
20681        > for &mut AudioCapturerSetReferenceClockRequest
20682    {
20683        #[inline]
20684        unsafe fn encode(
20685            self,
20686            encoder: &mut fidl::encoding::Encoder<
20687                '_,
20688                fidl::encoding::DefaultFuchsiaResourceDialect,
20689            >,
20690            offset: usize,
20691            _depth: fidl::encoding::Depth,
20692        ) -> fidl::Result<()> {
20693            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20694            // Delegate to tuple encoding.
20695            fidl::encoding::Encode::<
20696                AudioCapturerSetReferenceClockRequest,
20697                fidl::encoding::DefaultFuchsiaResourceDialect,
20698            >::encode(
20699                (<fidl::encoding::Optional<
20700                    fidl::encoding::HandleType<
20701                        fidl::Clock,
20702                        { fidl::ObjectType::CLOCK.into_raw() },
20703                        2147483648,
20704                    >,
20705                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20706                    &mut self.reference_clock,
20707                ),),
20708                encoder,
20709                offset,
20710                _depth,
20711            )
20712        }
20713    }
20714    unsafe impl<
20715        T0: fidl::encoding::Encode<
20716                fidl::encoding::Optional<
20717                    fidl::encoding::HandleType<
20718                        fidl::Clock,
20719                        { fidl::ObjectType::CLOCK.into_raw() },
20720                        2147483648,
20721                    >,
20722                >,
20723                fidl::encoding::DefaultFuchsiaResourceDialect,
20724            >,
20725    >
20726        fidl::encoding::Encode<
20727            AudioCapturerSetReferenceClockRequest,
20728            fidl::encoding::DefaultFuchsiaResourceDialect,
20729        > for (T0,)
20730    {
20731        #[inline]
20732        unsafe fn encode(
20733            self,
20734            encoder: &mut fidl::encoding::Encoder<
20735                '_,
20736                fidl::encoding::DefaultFuchsiaResourceDialect,
20737            >,
20738            offset: usize,
20739            depth: fidl::encoding::Depth,
20740        ) -> fidl::Result<()> {
20741            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20742            // Zero out padding regions. There's no need to apply masks
20743            // because the unmasked parts will be overwritten by fields.
20744            // Write the fields.
20745            self.0.encode(encoder, offset + 0, depth)?;
20746            Ok(())
20747        }
20748    }
20749
20750    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20751        for AudioCapturerSetReferenceClockRequest
20752    {
20753        #[inline(always)]
20754        fn new_empty() -> Self {
20755            Self {
20756                reference_clock: fidl::new_empty!(
20757                    fidl::encoding::Optional<
20758                        fidl::encoding::HandleType<
20759                            fidl::Clock,
20760                            { fidl::ObjectType::CLOCK.into_raw() },
20761                            2147483648,
20762                        >,
20763                    >,
20764                    fidl::encoding::DefaultFuchsiaResourceDialect
20765                ),
20766            }
20767        }
20768
20769        #[inline]
20770        unsafe fn decode(
20771            &mut self,
20772            decoder: &mut fidl::encoding::Decoder<
20773                '_,
20774                fidl::encoding::DefaultFuchsiaResourceDialect,
20775            >,
20776            offset: usize,
20777            _depth: fidl::encoding::Depth,
20778        ) -> fidl::Result<()> {
20779            decoder.debug_check_bounds::<Self>(offset);
20780            // Verify that padding bytes are zero.
20781            fidl::decode!(
20782                fidl::encoding::Optional<
20783                    fidl::encoding::HandleType<
20784                        fidl::Clock,
20785                        { fidl::ObjectType::CLOCK.into_raw() },
20786                        2147483648,
20787                    >,
20788                >,
20789                fidl::encoding::DefaultFuchsiaResourceDialect,
20790                &mut self.reference_clock,
20791                decoder,
20792                offset + 0,
20793                _depth
20794            )?;
20795            Ok(())
20796        }
20797    }
20798
20799    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
20800        type Borrowed<'a> = &'a mut Self;
20801        fn take_or_borrow<'a>(
20802            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20803        ) -> Self::Borrowed<'a> {
20804            value
20805        }
20806    }
20807
20808    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
20809        type Owned = Self;
20810
20811        #[inline(always)]
20812        fn inline_align(_context: fidl::encoding::Context) -> usize {
20813            4
20814        }
20815
20816        #[inline(always)]
20817        fn inline_size(_context: fidl::encoding::Context) -> usize {
20818            4
20819        }
20820    }
20821
20822    unsafe impl
20823        fidl::encoding::Encode<
20824            AudioConsumerBindVolumeControlRequest,
20825            fidl::encoding::DefaultFuchsiaResourceDialect,
20826        > for &mut AudioConsumerBindVolumeControlRequest
20827    {
20828        #[inline]
20829        unsafe fn encode(
20830            self,
20831            encoder: &mut fidl::encoding::Encoder<
20832                '_,
20833                fidl::encoding::DefaultFuchsiaResourceDialect,
20834            >,
20835            offset: usize,
20836            _depth: fidl::encoding::Depth,
20837        ) -> fidl::Result<()> {
20838            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20839            // Delegate to tuple encoding.
20840            fidl::encoding::Encode::<
20841                AudioConsumerBindVolumeControlRequest,
20842                fidl::encoding::DefaultFuchsiaResourceDialect,
20843            >::encode(
20844                (<fidl::encoding::Endpoint<
20845                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20846                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20847                    &mut self.volume_control_request,
20848                ),),
20849                encoder,
20850                offset,
20851                _depth,
20852            )
20853        }
20854    }
20855    unsafe impl<
20856        T0: fidl::encoding::Encode<
20857                fidl::encoding::Endpoint<
20858                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20859                >,
20860                fidl::encoding::DefaultFuchsiaResourceDialect,
20861            >,
20862    >
20863        fidl::encoding::Encode<
20864            AudioConsumerBindVolumeControlRequest,
20865            fidl::encoding::DefaultFuchsiaResourceDialect,
20866        > for (T0,)
20867    {
20868        #[inline]
20869        unsafe fn encode(
20870            self,
20871            encoder: &mut fidl::encoding::Encoder<
20872                '_,
20873                fidl::encoding::DefaultFuchsiaResourceDialect,
20874            >,
20875            offset: usize,
20876            depth: fidl::encoding::Depth,
20877        ) -> fidl::Result<()> {
20878            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20879            // Zero out padding regions. There's no need to apply masks
20880            // because the unmasked parts will be overwritten by fields.
20881            // Write the fields.
20882            self.0.encode(encoder, offset + 0, depth)?;
20883            Ok(())
20884        }
20885    }
20886
20887    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20888        for AudioConsumerBindVolumeControlRequest
20889    {
20890        #[inline(always)]
20891        fn new_empty() -> Self {
20892            Self {
20893                volume_control_request: fidl::new_empty!(
20894                    fidl::encoding::Endpoint<
20895                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20896                    >,
20897                    fidl::encoding::DefaultFuchsiaResourceDialect
20898                ),
20899            }
20900        }
20901
20902        #[inline]
20903        unsafe fn decode(
20904            &mut self,
20905            decoder: &mut fidl::encoding::Decoder<
20906                '_,
20907                fidl::encoding::DefaultFuchsiaResourceDialect,
20908            >,
20909            offset: usize,
20910            _depth: fidl::encoding::Depth,
20911        ) -> fidl::Result<()> {
20912            decoder.debug_check_bounds::<Self>(offset);
20913            // Verify that padding bytes are zero.
20914            fidl::decode!(
20915                fidl::encoding::Endpoint<
20916                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20917                >,
20918                fidl::encoding::DefaultFuchsiaResourceDialect,
20919                &mut self.volume_control_request,
20920                decoder,
20921                offset + 0,
20922                _depth
20923            )?;
20924            Ok(())
20925        }
20926    }
20927
20928    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
20929        type Borrowed<'a> = &'a mut Self;
20930        fn take_or_borrow<'a>(
20931            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20932        ) -> Self::Borrowed<'a> {
20933            value
20934        }
20935    }
20936
20937    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
20938        type Owned = Self;
20939
20940        #[inline(always)]
20941        fn inline_align(_context: fidl::encoding::Context) -> usize {
20942            8
20943        }
20944
20945        #[inline(always)]
20946        fn inline_size(_context: fidl::encoding::Context) -> usize {
20947            48
20948        }
20949    }
20950
20951    unsafe impl
20952        fidl::encoding::Encode<
20953            AudioConsumerCreateStreamSinkRequest,
20954            fidl::encoding::DefaultFuchsiaResourceDialect,
20955        > for &mut AudioConsumerCreateStreamSinkRequest
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::<AudioConsumerCreateStreamSinkRequest>(offset);
20968            // Delegate to tuple encoding.
20969            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
20970                (
20971                    <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),
20972                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
20973                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
20974                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
20975                ),
20976                encoder, offset, _depth
20977            )
20978        }
20979    }
20980    unsafe impl<
20981        T0: fidl::encoding::Encode<
20982                fidl::encoding::Vector<
20983                    fidl::encoding::HandleType<
20984                        fidl::Vmo,
20985                        { fidl::ObjectType::VMO.into_raw() },
20986                        2147483648,
20987                    >,
20988                    16,
20989                >,
20990                fidl::encoding::DefaultFuchsiaResourceDialect,
20991            >,
20992        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
20993        T2: fidl::encoding::Encode<
20994                fidl::encoding::Boxed<Compression>,
20995                fidl::encoding::DefaultFuchsiaResourceDialect,
20996            >,
20997        T3: fidl::encoding::Encode<
20998                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
20999                fidl::encoding::DefaultFuchsiaResourceDialect,
21000            >,
21001    >
21002        fidl::encoding::Encode<
21003            AudioConsumerCreateStreamSinkRequest,
21004            fidl::encoding::DefaultFuchsiaResourceDialect,
21005        > for (T0, T1, T2, T3)
21006    {
21007        #[inline]
21008        unsafe fn encode(
21009            self,
21010            encoder: &mut fidl::encoding::Encoder<
21011                '_,
21012                fidl::encoding::DefaultFuchsiaResourceDialect,
21013            >,
21014            offset: usize,
21015            depth: fidl::encoding::Depth,
21016        ) -> fidl::Result<()> {
21017            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21018            // Zero out padding regions. There's no need to apply masks
21019            // because the unmasked parts will be overwritten by fields.
21020            unsafe {
21021                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
21022                (ptr as *mut u64).write_unaligned(0);
21023            }
21024            unsafe {
21025                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
21026                (ptr as *mut u64).write_unaligned(0);
21027            }
21028            // Write the fields.
21029            self.0.encode(encoder, offset + 0, depth)?;
21030            self.1.encode(encoder, offset + 16, depth)?;
21031            self.2.encode(encoder, offset + 32, depth)?;
21032            self.3.encode(encoder, offset + 40, depth)?;
21033            Ok(())
21034        }
21035    }
21036
21037    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21038        for AudioConsumerCreateStreamSinkRequest
21039    {
21040        #[inline(always)]
21041        fn new_empty() -> Self {
21042            Self {
21043                buffers: fidl::new_empty!(
21044                    fidl::encoding::Vector<
21045                        fidl::encoding::HandleType<
21046                            fidl::Vmo,
21047                            { fidl::ObjectType::VMO.into_raw() },
21048                            2147483648,
21049                        >,
21050                        16,
21051                    >,
21052                    fidl::encoding::DefaultFuchsiaResourceDialect
21053                ),
21054                stream_type: fidl::new_empty!(
21055                    AudioStreamType,
21056                    fidl::encoding::DefaultFuchsiaResourceDialect
21057                ),
21058                compression: fidl::new_empty!(
21059                    fidl::encoding::Boxed<Compression>,
21060                    fidl::encoding::DefaultFuchsiaResourceDialect
21061                ),
21062                stream_sink_request: fidl::new_empty!(
21063                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21064                    fidl::encoding::DefaultFuchsiaResourceDialect
21065                ),
21066            }
21067        }
21068
21069        #[inline]
21070        unsafe fn decode(
21071            &mut self,
21072            decoder: &mut fidl::encoding::Decoder<
21073                '_,
21074                fidl::encoding::DefaultFuchsiaResourceDialect,
21075            >,
21076            offset: usize,
21077            _depth: fidl::encoding::Depth,
21078        ) -> fidl::Result<()> {
21079            decoder.debug_check_bounds::<Self>(offset);
21080            // Verify that padding bytes are zero.
21081            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
21082            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21083            let mask = 0xffffffff00000000u64;
21084            let maskedval = padval & mask;
21085            if maskedval != 0 {
21086                return Err(fidl::Error::NonZeroPadding {
21087                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
21088                });
21089            }
21090            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
21091            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21092            let mask = 0xffffffff00000000u64;
21093            let maskedval = padval & mask;
21094            if maskedval != 0 {
21095                return Err(fidl::Error::NonZeroPadding {
21096                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
21097                });
21098            }
21099            fidl::decode!(
21100                fidl::encoding::Vector<
21101                    fidl::encoding::HandleType<
21102                        fidl::Vmo,
21103                        { fidl::ObjectType::VMO.into_raw() },
21104                        2147483648,
21105                    >,
21106                    16,
21107                >,
21108                fidl::encoding::DefaultFuchsiaResourceDialect,
21109                &mut self.buffers,
21110                decoder,
21111                offset + 0,
21112                _depth
21113            )?;
21114            fidl::decode!(
21115                AudioStreamType,
21116                fidl::encoding::DefaultFuchsiaResourceDialect,
21117                &mut self.stream_type,
21118                decoder,
21119                offset + 16,
21120                _depth
21121            )?;
21122            fidl::decode!(
21123                fidl::encoding::Boxed<Compression>,
21124                fidl::encoding::DefaultFuchsiaResourceDialect,
21125                &mut self.compression,
21126                decoder,
21127                offset + 32,
21128                _depth
21129            )?;
21130            fidl::decode!(
21131                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21132                fidl::encoding::DefaultFuchsiaResourceDialect,
21133                &mut self.stream_sink_request,
21134                decoder,
21135                offset + 40,
21136                _depth
21137            )?;
21138            Ok(())
21139        }
21140    }
21141
21142    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
21143        type Borrowed<'a> = &'a mut Self;
21144        fn take_or_borrow<'a>(
21145            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21146        ) -> Self::Borrowed<'a> {
21147            value
21148        }
21149    }
21150
21151    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
21152        type Owned = Self;
21153
21154        #[inline(always)]
21155        fn inline_align(_context: fidl::encoding::Context) -> usize {
21156            8
21157        }
21158
21159        #[inline(always)]
21160        fn inline_size(_context: fidl::encoding::Context) -> usize {
21161            24
21162        }
21163    }
21164
21165    unsafe impl
21166        fidl::encoding::Encode<
21167            AudioCoreBindUsageVolumeControl2Request,
21168            fidl::encoding::DefaultFuchsiaResourceDialect,
21169        > for &mut AudioCoreBindUsageVolumeControl2Request
21170    {
21171        #[inline]
21172        unsafe fn encode(
21173            self,
21174            encoder: &mut fidl::encoding::Encoder<
21175                '_,
21176                fidl::encoding::DefaultFuchsiaResourceDialect,
21177            >,
21178            offset: usize,
21179            _depth: fidl::encoding::Depth,
21180        ) -> fidl::Result<()> {
21181            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21182            // Delegate to tuple encoding.
21183            fidl::encoding::Encode::<
21184                AudioCoreBindUsageVolumeControl2Request,
21185                fidl::encoding::DefaultFuchsiaResourceDialect,
21186            >::encode(
21187                (
21188                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21189                    <fidl::encoding::Endpoint<
21190                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21191                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21192                        &mut self.volume_control,
21193                    ),
21194                ),
21195                encoder,
21196                offset,
21197                _depth,
21198            )
21199        }
21200    }
21201    unsafe impl<
21202        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
21203        T1: fidl::encoding::Encode<
21204                fidl::encoding::Endpoint<
21205                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21206                >,
21207                fidl::encoding::DefaultFuchsiaResourceDialect,
21208            >,
21209    >
21210        fidl::encoding::Encode<
21211            AudioCoreBindUsageVolumeControl2Request,
21212            fidl::encoding::DefaultFuchsiaResourceDialect,
21213        > for (T0, T1)
21214    {
21215        #[inline]
21216        unsafe fn encode(
21217            self,
21218            encoder: &mut fidl::encoding::Encoder<
21219                '_,
21220                fidl::encoding::DefaultFuchsiaResourceDialect,
21221            >,
21222            offset: usize,
21223            depth: fidl::encoding::Depth,
21224        ) -> fidl::Result<()> {
21225            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21226            // Zero out padding regions. There's no need to apply masks
21227            // because the unmasked parts will be overwritten by fields.
21228            unsafe {
21229                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21230                (ptr as *mut u64).write_unaligned(0);
21231            }
21232            // Write the fields.
21233            self.0.encode(encoder, offset + 0, depth)?;
21234            self.1.encode(encoder, offset + 16, depth)?;
21235            Ok(())
21236        }
21237    }
21238
21239    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21240        for AudioCoreBindUsageVolumeControl2Request
21241    {
21242        #[inline(always)]
21243        fn new_empty() -> Self {
21244            Self {
21245                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
21246                volume_control: fidl::new_empty!(
21247                    fidl::encoding::Endpoint<
21248                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21249                    >,
21250                    fidl::encoding::DefaultFuchsiaResourceDialect
21251                ),
21252            }
21253        }
21254
21255        #[inline]
21256        unsafe fn decode(
21257            &mut self,
21258            decoder: &mut fidl::encoding::Decoder<
21259                '_,
21260                fidl::encoding::DefaultFuchsiaResourceDialect,
21261            >,
21262            offset: usize,
21263            _depth: fidl::encoding::Depth,
21264        ) -> fidl::Result<()> {
21265            decoder.debug_check_bounds::<Self>(offset);
21266            // Verify that padding bytes are zero.
21267            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21268            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21269            let mask = 0xffffffff00000000u64;
21270            let maskedval = padval & mask;
21271            if maskedval != 0 {
21272                return Err(fidl::Error::NonZeroPadding {
21273                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21274                });
21275            }
21276            fidl::decode!(
21277                Usage2,
21278                fidl::encoding::DefaultFuchsiaResourceDialect,
21279                &mut self.usage,
21280                decoder,
21281                offset + 0,
21282                _depth
21283            )?;
21284            fidl::decode!(
21285                fidl::encoding::Endpoint<
21286                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21287                >,
21288                fidl::encoding::DefaultFuchsiaResourceDialect,
21289                &mut self.volume_control,
21290                decoder,
21291                offset + 16,
21292                _depth
21293            )?;
21294            Ok(())
21295        }
21296    }
21297
21298    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
21299        type Borrowed<'a> = &'a mut Self;
21300        fn take_or_borrow<'a>(
21301            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21302        ) -> Self::Borrowed<'a> {
21303            value
21304        }
21305    }
21306
21307    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
21308        type Owned = Self;
21309
21310        #[inline(always)]
21311        fn inline_align(_context: fidl::encoding::Context) -> usize {
21312            8
21313        }
21314
21315        #[inline(always)]
21316        fn inline_size(_context: fidl::encoding::Context) -> usize {
21317            24
21318        }
21319    }
21320
21321    unsafe impl
21322        fidl::encoding::Encode<
21323            AudioCoreBindUsageVolumeControlRequest,
21324            fidl::encoding::DefaultFuchsiaResourceDialect,
21325        > for &mut AudioCoreBindUsageVolumeControlRequest
21326    {
21327        #[inline]
21328        unsafe fn encode(
21329            self,
21330            encoder: &mut fidl::encoding::Encoder<
21331                '_,
21332                fidl::encoding::DefaultFuchsiaResourceDialect,
21333            >,
21334            offset: usize,
21335            _depth: fidl::encoding::Depth,
21336        ) -> fidl::Result<()> {
21337            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21338            // Delegate to tuple encoding.
21339            fidl::encoding::Encode::<
21340                AudioCoreBindUsageVolumeControlRequest,
21341                fidl::encoding::DefaultFuchsiaResourceDialect,
21342            >::encode(
21343                (
21344                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21345                    <fidl::encoding::Endpoint<
21346                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21347                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21348                        &mut self.volume_control,
21349                    ),
21350                ),
21351                encoder,
21352                offset,
21353                _depth,
21354            )
21355        }
21356    }
21357    unsafe impl<
21358        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
21359        T1: fidl::encoding::Encode<
21360                fidl::encoding::Endpoint<
21361                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21362                >,
21363                fidl::encoding::DefaultFuchsiaResourceDialect,
21364            >,
21365    >
21366        fidl::encoding::Encode<
21367            AudioCoreBindUsageVolumeControlRequest,
21368            fidl::encoding::DefaultFuchsiaResourceDialect,
21369        > for (T0, T1)
21370    {
21371        #[inline]
21372        unsafe fn encode(
21373            self,
21374            encoder: &mut fidl::encoding::Encoder<
21375                '_,
21376                fidl::encoding::DefaultFuchsiaResourceDialect,
21377            >,
21378            offset: usize,
21379            depth: fidl::encoding::Depth,
21380        ) -> fidl::Result<()> {
21381            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21382            // Zero out padding regions. There's no need to apply masks
21383            // because the unmasked parts will be overwritten by fields.
21384            unsafe {
21385                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21386                (ptr as *mut u64).write_unaligned(0);
21387            }
21388            // Write the fields.
21389            self.0.encode(encoder, offset + 0, depth)?;
21390            self.1.encode(encoder, offset + 16, depth)?;
21391            Ok(())
21392        }
21393    }
21394
21395    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21396        for AudioCoreBindUsageVolumeControlRequest
21397    {
21398        #[inline(always)]
21399        fn new_empty() -> Self {
21400            Self {
21401                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
21402                volume_control: fidl::new_empty!(
21403                    fidl::encoding::Endpoint<
21404                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21405                    >,
21406                    fidl::encoding::DefaultFuchsiaResourceDialect
21407                ),
21408            }
21409        }
21410
21411        #[inline]
21412        unsafe fn decode(
21413            &mut self,
21414            decoder: &mut fidl::encoding::Decoder<
21415                '_,
21416                fidl::encoding::DefaultFuchsiaResourceDialect,
21417            >,
21418            offset: usize,
21419            _depth: fidl::encoding::Depth,
21420        ) -> fidl::Result<()> {
21421            decoder.debug_check_bounds::<Self>(offset);
21422            // Verify that padding bytes are zero.
21423            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21424            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21425            let mask = 0xffffffff00000000u64;
21426            let maskedval = padval & mask;
21427            if maskedval != 0 {
21428                return Err(fidl::Error::NonZeroPadding {
21429                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21430                });
21431            }
21432            fidl::decode!(
21433                Usage,
21434                fidl::encoding::DefaultFuchsiaResourceDialect,
21435                &mut self.usage,
21436                decoder,
21437                offset + 0,
21438                _depth
21439            )?;
21440            fidl::decode!(
21441                fidl::encoding::Endpoint<
21442                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21443                >,
21444                fidl::encoding::DefaultFuchsiaResourceDialect,
21445                &mut self.volume_control,
21446                decoder,
21447                offset + 16,
21448                _depth
21449            )?;
21450            Ok(())
21451        }
21452    }
21453
21454    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
21455        type Borrowed<'a> = &'a mut Self;
21456        fn take_or_borrow<'a>(
21457            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21458        ) -> Self::Borrowed<'a> {
21459            value
21460        }
21461    }
21462
21463    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
21464        type Owned = Self;
21465
21466        #[inline(always)]
21467        fn inline_align(_context: fidl::encoding::Context) -> usize {
21468            4
21469        }
21470
21471        #[inline(always)]
21472        fn inline_size(_context: fidl::encoding::Context) -> usize {
21473            8
21474        }
21475    }
21476
21477    unsafe impl
21478        fidl::encoding::Encode<
21479            AudioCoreCreateAudioCapturerRequest,
21480            fidl::encoding::DefaultFuchsiaResourceDialect,
21481        > for &mut AudioCoreCreateAudioCapturerRequest
21482    {
21483        #[inline]
21484        unsafe fn encode(
21485            self,
21486            encoder: &mut fidl::encoding::Encoder<
21487                '_,
21488                fidl::encoding::DefaultFuchsiaResourceDialect,
21489            >,
21490            offset: usize,
21491            _depth: fidl::encoding::Depth,
21492        ) -> fidl::Result<()> {
21493            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21494            // Delegate to tuple encoding.
21495            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21496                (
21497                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21498                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
21499                ),
21500                encoder, offset, _depth
21501            )
21502        }
21503    }
21504    unsafe impl<
21505        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21506        T1: fidl::encoding::Encode<
21507                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21508                fidl::encoding::DefaultFuchsiaResourceDialect,
21509            >,
21510    >
21511        fidl::encoding::Encode<
21512            AudioCoreCreateAudioCapturerRequest,
21513            fidl::encoding::DefaultFuchsiaResourceDialect,
21514        > for (T0, T1)
21515    {
21516        #[inline]
21517        unsafe fn encode(
21518            self,
21519            encoder: &mut fidl::encoding::Encoder<
21520                '_,
21521                fidl::encoding::DefaultFuchsiaResourceDialect,
21522            >,
21523            offset: usize,
21524            depth: fidl::encoding::Depth,
21525        ) -> fidl::Result<()> {
21526            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21527            // Zero out padding regions. There's no need to apply masks
21528            // because the unmasked parts will be overwritten by fields.
21529            unsafe {
21530                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
21531                (ptr as *mut u32).write_unaligned(0);
21532            }
21533            // Write the fields.
21534            self.0.encode(encoder, offset + 0, depth)?;
21535            self.1.encode(encoder, offset + 4, depth)?;
21536            Ok(())
21537        }
21538    }
21539
21540    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21541        for AudioCoreCreateAudioCapturerRequest
21542    {
21543        #[inline(always)]
21544        fn new_empty() -> Self {
21545            Self {
21546                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21547                audio_in_request: fidl::new_empty!(
21548                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21549                    fidl::encoding::DefaultFuchsiaResourceDialect
21550                ),
21551            }
21552        }
21553
21554        #[inline]
21555        unsafe fn decode(
21556            &mut self,
21557            decoder: &mut fidl::encoding::Decoder<
21558                '_,
21559                fidl::encoding::DefaultFuchsiaResourceDialect,
21560            >,
21561            offset: usize,
21562            _depth: fidl::encoding::Depth,
21563        ) -> fidl::Result<()> {
21564            decoder.debug_check_bounds::<Self>(offset);
21565            // Verify that padding bytes are zero.
21566            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
21567            let padval = unsafe { (ptr as *const u32).read_unaligned() };
21568            let mask = 0xffffff00u32;
21569            let maskedval = padval & mask;
21570            if maskedval != 0 {
21571                return Err(fidl::Error::NonZeroPadding {
21572                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
21573                });
21574            }
21575            fidl::decode!(
21576                bool,
21577                fidl::encoding::DefaultFuchsiaResourceDialect,
21578                &mut self.loopback,
21579                decoder,
21580                offset + 0,
21581                _depth
21582            )?;
21583            fidl::decode!(
21584                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21585                fidl::encoding::DefaultFuchsiaResourceDialect,
21586                &mut self.audio_in_request,
21587                decoder,
21588                offset + 4,
21589                _depth
21590            )?;
21591            Ok(())
21592        }
21593    }
21594
21595    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21596        type Borrowed<'a> = &'a mut Self;
21597        fn take_or_borrow<'a>(
21598            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21599        ) -> Self::Borrowed<'a> {
21600            value
21601        }
21602    }
21603
21604    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21605        type Owned = Self;
21606
21607        #[inline(always)]
21608        fn inline_align(_context: fidl::encoding::Context) -> usize {
21609            8
21610        }
21611
21612        #[inline(always)]
21613        fn inline_size(_context: fidl::encoding::Context) -> usize {
21614            40
21615        }
21616    }
21617
21618    unsafe impl
21619        fidl::encoding::Encode<
21620            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21621            fidl::encoding::DefaultFuchsiaResourceDialect,
21622        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
21623    {
21624        #[inline]
21625        unsafe fn encode(
21626            self,
21627            encoder: &mut fidl::encoding::Encoder<
21628                '_,
21629                fidl::encoding::DefaultFuchsiaResourceDialect,
21630            >,
21631            offset: usize,
21632            _depth: fidl::encoding::Depth,
21633        ) -> fidl::Result<()> {
21634            encoder
21635                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21636            // Delegate to tuple encoding.
21637            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21638                (
21639                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21640                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
21641                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21642                ),
21643                encoder, offset, _depth
21644            )
21645        }
21646    }
21647    unsafe impl<
21648        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21649        T1: fidl::encoding::Encode<
21650                AudioCapturerConfiguration,
21651                fidl::encoding::DefaultFuchsiaResourceDialect,
21652            >,
21653        T2: fidl::encoding::Encode<
21654                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21655                fidl::encoding::DefaultFuchsiaResourceDialect,
21656            >,
21657    >
21658        fidl::encoding::Encode<
21659            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21660            fidl::encoding::DefaultFuchsiaResourceDialect,
21661        > for (T0, T1, T2)
21662    {
21663        #[inline]
21664        unsafe fn encode(
21665            self,
21666            encoder: &mut fidl::encoding::Encoder<
21667                '_,
21668                fidl::encoding::DefaultFuchsiaResourceDialect,
21669            >,
21670            offset: usize,
21671            depth: fidl::encoding::Depth,
21672        ) -> fidl::Result<()> {
21673            encoder
21674                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21675            // Zero out padding regions. There's no need to apply masks
21676            // because the unmasked parts will be overwritten by fields.
21677            unsafe {
21678                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
21679                (ptr as *mut u64).write_unaligned(0);
21680            }
21681            unsafe {
21682                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21683                (ptr as *mut u64).write_unaligned(0);
21684            }
21685            // Write the fields.
21686            self.0.encode(encoder, offset + 0, depth)?;
21687            self.1.encode(encoder, offset + 16, depth)?;
21688            self.2.encode(encoder, offset + 32, depth)?;
21689            Ok(())
21690        }
21691    }
21692
21693    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21694        for AudioCoreCreateAudioCapturerWithConfigurationRequest
21695    {
21696        #[inline(always)]
21697        fn new_empty() -> Self {
21698            Self {
21699                stream_type: fidl::new_empty!(
21700                    AudioStreamType,
21701                    fidl::encoding::DefaultFuchsiaResourceDialect
21702                ),
21703                configuration: fidl::new_empty!(
21704                    AudioCapturerConfiguration,
21705                    fidl::encoding::DefaultFuchsiaResourceDialect
21706                ),
21707                audio_capturer_request: fidl::new_empty!(
21708                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21709                    fidl::encoding::DefaultFuchsiaResourceDialect
21710                ),
21711            }
21712        }
21713
21714        #[inline]
21715        unsafe fn decode(
21716            &mut self,
21717            decoder: &mut fidl::encoding::Decoder<
21718                '_,
21719                fidl::encoding::DefaultFuchsiaResourceDialect,
21720            >,
21721            offset: usize,
21722            _depth: fidl::encoding::Depth,
21723        ) -> fidl::Result<()> {
21724            decoder.debug_check_bounds::<Self>(offset);
21725            // Verify that padding bytes are zero.
21726            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21727            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21728            let mask = 0xffffffff00000000u64;
21729            let maskedval = padval & mask;
21730            if maskedval != 0 {
21731                return Err(fidl::Error::NonZeroPadding {
21732                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21733                });
21734            }
21735            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21736            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21737            let mask = 0xffffffff00000000u64;
21738            let maskedval = padval & mask;
21739            if maskedval != 0 {
21740                return Err(fidl::Error::NonZeroPadding {
21741                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21742                });
21743            }
21744            fidl::decode!(
21745                AudioStreamType,
21746                fidl::encoding::DefaultFuchsiaResourceDialect,
21747                &mut self.stream_type,
21748                decoder,
21749                offset + 0,
21750                _depth
21751            )?;
21752            fidl::decode!(
21753                AudioCapturerConfiguration,
21754                fidl::encoding::DefaultFuchsiaResourceDialect,
21755                &mut self.configuration,
21756                decoder,
21757                offset + 16,
21758                _depth
21759            )?;
21760            fidl::decode!(
21761                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21762                fidl::encoding::DefaultFuchsiaResourceDialect,
21763                &mut self.audio_capturer_request,
21764                decoder,
21765                offset + 32,
21766                _depth
21767            )?;
21768            Ok(())
21769        }
21770    }
21771
21772    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
21773        type Borrowed<'a> = &'a mut Self;
21774        fn take_or_borrow<'a>(
21775            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21776        ) -> Self::Borrowed<'a> {
21777            value
21778        }
21779    }
21780
21781    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
21782        type Owned = Self;
21783
21784        #[inline(always)]
21785        fn inline_align(_context: fidl::encoding::Context) -> usize {
21786            4
21787        }
21788
21789        #[inline(always)]
21790        fn inline_size(_context: fidl::encoding::Context) -> usize {
21791            4
21792        }
21793    }
21794
21795    unsafe impl
21796        fidl::encoding::Encode<
21797            AudioCoreCreateAudioRendererRequest,
21798            fidl::encoding::DefaultFuchsiaResourceDialect,
21799        > for &mut AudioCoreCreateAudioRendererRequest
21800    {
21801        #[inline]
21802        unsafe fn encode(
21803            self,
21804            encoder: &mut fidl::encoding::Encoder<
21805                '_,
21806                fidl::encoding::DefaultFuchsiaResourceDialect,
21807            >,
21808            offset: usize,
21809            _depth: fidl::encoding::Depth,
21810        ) -> fidl::Result<()> {
21811            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21812            // Delegate to tuple encoding.
21813            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21814                (
21815                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
21816                ),
21817                encoder, offset, _depth
21818            )
21819        }
21820    }
21821    unsafe impl<
21822        T0: fidl::encoding::Encode<
21823                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21824                fidl::encoding::DefaultFuchsiaResourceDialect,
21825            >,
21826    >
21827        fidl::encoding::Encode<
21828            AudioCoreCreateAudioRendererRequest,
21829            fidl::encoding::DefaultFuchsiaResourceDialect,
21830        > for (T0,)
21831    {
21832        #[inline]
21833        unsafe fn encode(
21834            self,
21835            encoder: &mut fidl::encoding::Encoder<
21836                '_,
21837                fidl::encoding::DefaultFuchsiaResourceDialect,
21838            >,
21839            offset: usize,
21840            depth: fidl::encoding::Depth,
21841        ) -> fidl::Result<()> {
21842            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21843            // Zero out padding regions. There's no need to apply masks
21844            // because the unmasked parts will be overwritten by fields.
21845            // Write the fields.
21846            self.0.encode(encoder, offset + 0, depth)?;
21847            Ok(())
21848        }
21849    }
21850
21851    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21852        for AudioCoreCreateAudioRendererRequest
21853    {
21854        #[inline(always)]
21855        fn new_empty() -> Self {
21856            Self {
21857                audio_out_request: fidl::new_empty!(
21858                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21859                    fidl::encoding::DefaultFuchsiaResourceDialect
21860                ),
21861            }
21862        }
21863
21864        #[inline]
21865        unsafe fn decode(
21866            &mut self,
21867            decoder: &mut fidl::encoding::Decoder<
21868                '_,
21869                fidl::encoding::DefaultFuchsiaResourceDialect,
21870            >,
21871            offset: usize,
21872            _depth: fidl::encoding::Depth,
21873        ) -> fidl::Result<()> {
21874            decoder.debug_check_bounds::<Self>(offset);
21875            // Verify that padding bytes are zero.
21876            fidl::decode!(
21877                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21878                fidl::encoding::DefaultFuchsiaResourceDialect,
21879                &mut self.audio_out_request,
21880                decoder,
21881                offset + 0,
21882                _depth
21883            )?;
21884            Ok(())
21885        }
21886    }
21887
21888    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
21889        type Borrowed<'a> = &'a mut Self;
21890        fn take_or_borrow<'a>(
21891            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21892        ) -> Self::Borrowed<'a> {
21893            value
21894        }
21895    }
21896
21897    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
21898        type Owned = Self;
21899
21900        #[inline(always)]
21901        fn inline_align(_context: fidl::encoding::Context) -> usize {
21902            4
21903        }
21904
21905        #[inline(always)]
21906        fn inline_size(_context: fidl::encoding::Context) -> usize {
21907            8
21908        }
21909    }
21910
21911    unsafe impl
21912        fidl::encoding::Encode<
21913            AudioCreateAudioCapturerRequest,
21914            fidl::encoding::DefaultFuchsiaResourceDialect,
21915        > for &mut AudioCreateAudioCapturerRequest
21916    {
21917        #[inline]
21918        unsafe fn encode(
21919            self,
21920            encoder: &mut fidl::encoding::Encoder<
21921                '_,
21922                fidl::encoding::DefaultFuchsiaResourceDialect,
21923            >,
21924            offset: usize,
21925            _depth: fidl::encoding::Depth,
21926        ) -> fidl::Result<()> {
21927            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
21928            // Delegate to tuple encoding.
21929            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21930                (
21931                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21932                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21933                ),
21934                encoder, offset, _depth
21935            )
21936        }
21937    }
21938    unsafe impl<
21939        T0: fidl::encoding::Encode<
21940                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21941                fidl::encoding::DefaultFuchsiaResourceDialect,
21942            >,
21943        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21944    >
21945        fidl::encoding::Encode<
21946            AudioCreateAudioCapturerRequest,
21947            fidl::encoding::DefaultFuchsiaResourceDialect,
21948        > for (T0, T1)
21949    {
21950        #[inline]
21951        unsafe fn encode(
21952            self,
21953            encoder: &mut fidl::encoding::Encoder<
21954                '_,
21955                fidl::encoding::DefaultFuchsiaResourceDialect,
21956            >,
21957            offset: usize,
21958            depth: fidl::encoding::Depth,
21959        ) -> fidl::Result<()> {
21960            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
21961            // Zero out padding regions. There's no need to apply masks
21962            // because the unmasked parts will be overwritten by fields.
21963            unsafe {
21964                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
21965                (ptr as *mut u32).write_unaligned(0);
21966            }
21967            // Write the fields.
21968            self.0.encode(encoder, offset + 0, depth)?;
21969            self.1.encode(encoder, offset + 4, depth)?;
21970            Ok(())
21971        }
21972    }
21973
21974    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21975        for AudioCreateAudioCapturerRequest
21976    {
21977        #[inline(always)]
21978        fn new_empty() -> Self {
21979            Self {
21980                audio_capturer_request: fidl::new_empty!(
21981                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21982                    fidl::encoding::DefaultFuchsiaResourceDialect
21983                ),
21984                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21985            }
21986        }
21987
21988        #[inline]
21989        unsafe fn decode(
21990            &mut self,
21991            decoder: &mut fidl::encoding::Decoder<
21992                '_,
21993                fidl::encoding::DefaultFuchsiaResourceDialect,
21994            >,
21995            offset: usize,
21996            _depth: fidl::encoding::Depth,
21997        ) -> fidl::Result<()> {
21998            decoder.debug_check_bounds::<Self>(offset);
21999            // Verify that padding bytes are zero.
22000            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
22001            let padval = unsafe { (ptr as *const u32).read_unaligned() };
22002            let mask = 0xffffff00u32;
22003            let maskedval = padval & mask;
22004            if maskedval != 0 {
22005                return Err(fidl::Error::NonZeroPadding {
22006                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
22007                });
22008            }
22009            fidl::decode!(
22010                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22011                fidl::encoding::DefaultFuchsiaResourceDialect,
22012                &mut self.audio_capturer_request,
22013                decoder,
22014                offset + 0,
22015                _depth
22016            )?;
22017            fidl::decode!(
22018                bool,
22019                fidl::encoding::DefaultFuchsiaResourceDialect,
22020                &mut self.loopback,
22021                decoder,
22022                offset + 4,
22023                _depth
22024            )?;
22025            Ok(())
22026        }
22027    }
22028
22029    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
22030        type Borrowed<'a> = &'a mut Self;
22031        fn take_or_borrow<'a>(
22032            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22033        ) -> Self::Borrowed<'a> {
22034            value
22035        }
22036    }
22037
22038    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
22039        type Owned = Self;
22040
22041        #[inline(always)]
22042        fn inline_align(_context: fidl::encoding::Context) -> usize {
22043            4
22044        }
22045
22046        #[inline(always)]
22047        fn inline_size(_context: fidl::encoding::Context) -> usize {
22048            4
22049        }
22050    }
22051
22052    unsafe impl
22053        fidl::encoding::Encode<
22054            AudioCreateAudioRendererRequest,
22055            fidl::encoding::DefaultFuchsiaResourceDialect,
22056        > for &mut AudioCreateAudioRendererRequest
22057    {
22058        #[inline]
22059        unsafe fn encode(
22060            self,
22061            encoder: &mut fidl::encoding::Encoder<
22062                '_,
22063                fidl::encoding::DefaultFuchsiaResourceDialect,
22064            >,
22065            offset: usize,
22066            _depth: fidl::encoding::Depth,
22067        ) -> fidl::Result<()> {
22068            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22069            // Delegate to tuple encoding.
22070            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22071                (
22072                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
22073                ),
22074                encoder, offset, _depth
22075            )
22076        }
22077    }
22078    unsafe impl<
22079        T0: fidl::encoding::Encode<
22080                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22081                fidl::encoding::DefaultFuchsiaResourceDialect,
22082            >,
22083    >
22084        fidl::encoding::Encode<
22085            AudioCreateAudioRendererRequest,
22086            fidl::encoding::DefaultFuchsiaResourceDialect,
22087        > for (T0,)
22088    {
22089        #[inline]
22090        unsafe fn encode(
22091            self,
22092            encoder: &mut fidl::encoding::Encoder<
22093                '_,
22094                fidl::encoding::DefaultFuchsiaResourceDialect,
22095            >,
22096            offset: usize,
22097            depth: fidl::encoding::Depth,
22098        ) -> fidl::Result<()> {
22099            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22100            // Zero out padding regions. There's no need to apply masks
22101            // because the unmasked parts will be overwritten by fields.
22102            // Write the fields.
22103            self.0.encode(encoder, offset + 0, depth)?;
22104            Ok(())
22105        }
22106    }
22107
22108    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22109        for AudioCreateAudioRendererRequest
22110    {
22111        #[inline(always)]
22112        fn new_empty() -> Self {
22113            Self {
22114                audio_renderer_request: fidl::new_empty!(
22115                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22116                    fidl::encoding::DefaultFuchsiaResourceDialect
22117                ),
22118            }
22119        }
22120
22121        #[inline]
22122        unsafe fn decode(
22123            &mut self,
22124            decoder: &mut fidl::encoding::Decoder<
22125                '_,
22126                fidl::encoding::DefaultFuchsiaResourceDialect,
22127            >,
22128            offset: usize,
22129            _depth: fidl::encoding::Depth,
22130        ) -> fidl::Result<()> {
22131            decoder.debug_check_bounds::<Self>(offset);
22132            // Verify that padding bytes are zero.
22133            fidl::decode!(
22134                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22135                fidl::encoding::DefaultFuchsiaResourceDialect,
22136                &mut self.audio_renderer_request,
22137                decoder,
22138                offset + 0,
22139                _depth
22140            )?;
22141            Ok(())
22142        }
22143    }
22144
22145    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22146        type Borrowed<'a> = &'a mut Self;
22147        fn take_or_borrow<'a>(
22148            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22149        ) -> Self::Borrowed<'a> {
22150            value
22151        }
22152    }
22153
22154    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22155        type Owned = Self;
22156
22157        #[inline(always)]
22158        fn inline_align(_context: fidl::encoding::Context) -> usize {
22159            8
22160        }
22161
22162        #[inline(always)]
22163        fn inline_size(_context: fidl::encoding::Context) -> usize {
22164            24
22165        }
22166    }
22167
22168    unsafe impl
22169        fidl::encoding::Encode<
22170            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22171            fidl::encoding::DefaultFuchsiaResourceDialect,
22172        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
22173    {
22174        #[inline]
22175        unsafe fn encode(
22176            self,
22177            encoder: &mut fidl::encoding::Encoder<
22178                '_,
22179                fidl::encoding::DefaultFuchsiaResourceDialect,
22180            >,
22181            offset: usize,
22182            _depth: fidl::encoding::Depth,
22183        ) -> fidl::Result<()> {
22184            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22185            // Delegate to tuple encoding.
22186            fidl::encoding::Encode::<
22187                AudioDeviceEnumeratorAddDeviceByChannelRequest,
22188                fidl::encoding::DefaultFuchsiaResourceDialect,
22189            >::encode(
22190                (
22191                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
22192                        &self.device_name,
22193                    ),
22194                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
22195                    <fidl::encoding::Endpoint<
22196                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22197                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22198                        &mut self.channel
22199                    ),
22200                ),
22201                encoder,
22202                offset,
22203                _depth,
22204            )
22205        }
22206    }
22207    unsafe impl<
22208        T0: fidl::encoding::Encode<
22209                fidl::encoding::BoundedString<256>,
22210                fidl::encoding::DefaultFuchsiaResourceDialect,
22211            >,
22212        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22213        T2: fidl::encoding::Encode<
22214                fidl::encoding::Endpoint<
22215                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22216                >,
22217                fidl::encoding::DefaultFuchsiaResourceDialect,
22218            >,
22219    >
22220        fidl::encoding::Encode<
22221            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22222            fidl::encoding::DefaultFuchsiaResourceDialect,
22223        > for (T0, T1, T2)
22224    {
22225        #[inline]
22226        unsafe fn encode(
22227            self,
22228            encoder: &mut fidl::encoding::Encoder<
22229                '_,
22230                fidl::encoding::DefaultFuchsiaResourceDialect,
22231            >,
22232            offset: usize,
22233            depth: fidl::encoding::Depth,
22234        ) -> fidl::Result<()> {
22235            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22236            // Zero out padding regions. There's no need to apply masks
22237            // because the unmasked parts will be overwritten by fields.
22238            unsafe {
22239                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22240                (ptr as *mut u64).write_unaligned(0);
22241            }
22242            // Write the fields.
22243            self.0.encode(encoder, offset + 0, depth)?;
22244            self.1.encode(encoder, offset + 16, depth)?;
22245            self.2.encode(encoder, offset + 20, depth)?;
22246            Ok(())
22247        }
22248    }
22249
22250    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22251        for AudioDeviceEnumeratorAddDeviceByChannelRequest
22252    {
22253        #[inline(always)]
22254        fn new_empty() -> Self {
22255            Self {
22256                device_name: fidl::new_empty!(
22257                    fidl::encoding::BoundedString<256>,
22258                    fidl::encoding::DefaultFuchsiaResourceDialect
22259                ),
22260                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22261                channel: fidl::new_empty!(
22262                    fidl::encoding::Endpoint<
22263                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22264                    >,
22265                    fidl::encoding::DefaultFuchsiaResourceDialect
22266                ),
22267            }
22268        }
22269
22270        #[inline]
22271        unsafe fn decode(
22272            &mut self,
22273            decoder: &mut fidl::encoding::Decoder<
22274                '_,
22275                fidl::encoding::DefaultFuchsiaResourceDialect,
22276            >,
22277            offset: usize,
22278            _depth: fidl::encoding::Depth,
22279        ) -> fidl::Result<()> {
22280            decoder.debug_check_bounds::<Self>(offset);
22281            // Verify that padding bytes are zero.
22282            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22283            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22284            let mask = 0xffffff00u64;
22285            let maskedval = padval & mask;
22286            if maskedval != 0 {
22287                return Err(fidl::Error::NonZeroPadding {
22288                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22289                });
22290            }
22291            fidl::decode!(
22292                fidl::encoding::BoundedString<256>,
22293                fidl::encoding::DefaultFuchsiaResourceDialect,
22294                &mut self.device_name,
22295                decoder,
22296                offset + 0,
22297                _depth
22298            )?;
22299            fidl::decode!(
22300                bool,
22301                fidl::encoding::DefaultFuchsiaResourceDialect,
22302                &mut self.is_input,
22303                decoder,
22304                offset + 16,
22305                _depth
22306            )?;
22307            fidl::decode!(
22308                fidl::encoding::Endpoint<
22309                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22310                >,
22311                fidl::encoding::DefaultFuchsiaResourceDialect,
22312                &mut self.channel,
22313                decoder,
22314                offset + 20,
22315                _depth
22316            )?;
22317            Ok(())
22318        }
22319    }
22320
22321    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
22322        type Borrowed<'a> = &'a mut Self;
22323        fn take_or_borrow<'a>(
22324            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22325        ) -> Self::Borrowed<'a> {
22326            value
22327        }
22328    }
22329
22330    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
22331        type Owned = Self;
22332
22333        #[inline(always)]
22334        fn inline_align(_context: fidl::encoding::Context) -> usize {
22335            4
22336        }
22337
22338        #[inline(always)]
22339        fn inline_size(_context: fidl::encoding::Context) -> usize {
22340            4
22341        }
22342    }
22343
22344    unsafe impl
22345        fidl::encoding::Encode<
22346            AudioRendererBindGainControlRequest,
22347            fidl::encoding::DefaultFuchsiaResourceDialect,
22348        > for &mut AudioRendererBindGainControlRequest
22349    {
22350        #[inline]
22351        unsafe fn encode(
22352            self,
22353            encoder: &mut fidl::encoding::Encoder<
22354                '_,
22355                fidl::encoding::DefaultFuchsiaResourceDialect,
22356            >,
22357            offset: usize,
22358            _depth: fidl::encoding::Depth,
22359        ) -> fidl::Result<()> {
22360            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22361            // Delegate to tuple encoding.
22362            fidl::encoding::Encode::<
22363                AudioRendererBindGainControlRequest,
22364                fidl::encoding::DefaultFuchsiaResourceDialect,
22365            >::encode(
22366                (<fidl::encoding::Endpoint<
22367                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22368                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22369                    &mut self.gain_control_request,
22370                ),),
22371                encoder,
22372                offset,
22373                _depth,
22374            )
22375        }
22376    }
22377    unsafe impl<
22378        T0: fidl::encoding::Encode<
22379                fidl::encoding::Endpoint<
22380                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22381                >,
22382                fidl::encoding::DefaultFuchsiaResourceDialect,
22383            >,
22384    >
22385        fidl::encoding::Encode<
22386            AudioRendererBindGainControlRequest,
22387            fidl::encoding::DefaultFuchsiaResourceDialect,
22388        > for (T0,)
22389    {
22390        #[inline]
22391        unsafe fn encode(
22392            self,
22393            encoder: &mut fidl::encoding::Encoder<
22394                '_,
22395                fidl::encoding::DefaultFuchsiaResourceDialect,
22396            >,
22397            offset: usize,
22398            depth: fidl::encoding::Depth,
22399        ) -> fidl::Result<()> {
22400            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22401            // Zero out padding regions. There's no need to apply masks
22402            // because the unmasked parts will be overwritten by fields.
22403            // Write the fields.
22404            self.0.encode(encoder, offset + 0, depth)?;
22405            Ok(())
22406        }
22407    }
22408
22409    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22410        for AudioRendererBindGainControlRequest
22411    {
22412        #[inline(always)]
22413        fn new_empty() -> Self {
22414            Self {
22415                gain_control_request: fidl::new_empty!(
22416                    fidl::encoding::Endpoint<
22417                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22418                    >,
22419                    fidl::encoding::DefaultFuchsiaResourceDialect
22420                ),
22421            }
22422        }
22423
22424        #[inline]
22425        unsafe fn decode(
22426            &mut self,
22427            decoder: &mut fidl::encoding::Decoder<
22428                '_,
22429                fidl::encoding::DefaultFuchsiaResourceDialect,
22430            >,
22431            offset: usize,
22432            _depth: fidl::encoding::Depth,
22433        ) -> fidl::Result<()> {
22434            decoder.debug_check_bounds::<Self>(offset);
22435            // Verify that padding bytes are zero.
22436            fidl::decode!(
22437                fidl::encoding::Endpoint<
22438                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22439                >,
22440                fidl::encoding::DefaultFuchsiaResourceDialect,
22441                &mut self.gain_control_request,
22442                decoder,
22443                offset + 0,
22444                _depth
22445            )?;
22446            Ok(())
22447        }
22448    }
22449
22450    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
22451        type Borrowed<'a> = &'a mut Self;
22452        fn take_or_borrow<'a>(
22453            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22454        ) -> Self::Borrowed<'a> {
22455            value
22456        }
22457    }
22458
22459    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
22460        type Owned = Self;
22461
22462        #[inline(always)]
22463        fn inline_align(_context: fidl::encoding::Context) -> usize {
22464            4
22465        }
22466
22467        #[inline(always)]
22468        fn inline_size(_context: fidl::encoding::Context) -> usize {
22469            4
22470        }
22471    }
22472
22473    unsafe impl
22474        fidl::encoding::Encode<
22475            AudioRendererGetReferenceClockResponse,
22476            fidl::encoding::DefaultFuchsiaResourceDialect,
22477        > for &mut AudioRendererGetReferenceClockResponse
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::<AudioRendererGetReferenceClockResponse>(offset);
22490            // Delegate to tuple encoding.
22491            fidl::encoding::Encode::<
22492                AudioRendererGetReferenceClockResponse,
22493                fidl::encoding::DefaultFuchsiaResourceDialect,
22494            >::encode(
22495                (<fidl::encoding::HandleType<
22496                    fidl::Clock,
22497                    { fidl::ObjectType::CLOCK.into_raw() },
22498                    2147483648,
22499                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22500                    &mut self.reference_clock,
22501                ),),
22502                encoder,
22503                offset,
22504                _depth,
22505            )
22506        }
22507    }
22508    unsafe impl<
22509        T0: fidl::encoding::Encode<
22510                fidl::encoding::HandleType<
22511                    fidl::Clock,
22512                    { fidl::ObjectType::CLOCK.into_raw() },
22513                    2147483648,
22514                >,
22515                fidl::encoding::DefaultFuchsiaResourceDialect,
22516            >,
22517    >
22518        fidl::encoding::Encode<
22519            AudioRendererGetReferenceClockResponse,
22520            fidl::encoding::DefaultFuchsiaResourceDialect,
22521        > for (T0,)
22522    {
22523        #[inline]
22524        unsafe fn encode(
22525            self,
22526            encoder: &mut fidl::encoding::Encoder<
22527                '_,
22528                fidl::encoding::DefaultFuchsiaResourceDialect,
22529            >,
22530            offset: usize,
22531            depth: fidl::encoding::Depth,
22532        ) -> fidl::Result<()> {
22533            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22534            // Zero out padding regions. There's no need to apply masks
22535            // because the unmasked parts will be overwritten by fields.
22536            // Write the fields.
22537            self.0.encode(encoder, offset + 0, depth)?;
22538            Ok(())
22539        }
22540    }
22541
22542    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22543        for AudioRendererGetReferenceClockResponse
22544    {
22545        #[inline(always)]
22546        fn new_empty() -> Self {
22547            Self {
22548                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22549            }
22550        }
22551
22552        #[inline]
22553        unsafe fn decode(
22554            &mut self,
22555            decoder: &mut fidl::encoding::Decoder<
22556                '_,
22557                fidl::encoding::DefaultFuchsiaResourceDialect,
22558            >,
22559            offset: usize,
22560            _depth: fidl::encoding::Depth,
22561        ) -> fidl::Result<()> {
22562            decoder.debug_check_bounds::<Self>(offset);
22563            // Verify that padding bytes are zero.
22564            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22565            Ok(())
22566        }
22567    }
22568
22569    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
22570        type Borrowed<'a> = &'a mut Self;
22571        fn take_or_borrow<'a>(
22572            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22573        ) -> Self::Borrowed<'a> {
22574            value
22575        }
22576    }
22577
22578    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
22579        type Owned = Self;
22580
22581        #[inline(always)]
22582        fn inline_align(_context: fidl::encoding::Context) -> usize {
22583            4
22584        }
22585
22586        #[inline(always)]
22587        fn inline_size(_context: fidl::encoding::Context) -> usize {
22588            4
22589        }
22590    }
22591
22592    unsafe impl
22593        fidl::encoding::Encode<
22594            AudioRendererSetReferenceClockRequest,
22595            fidl::encoding::DefaultFuchsiaResourceDialect,
22596        > for &mut AudioRendererSetReferenceClockRequest
22597    {
22598        #[inline]
22599        unsafe fn encode(
22600            self,
22601            encoder: &mut fidl::encoding::Encoder<
22602                '_,
22603                fidl::encoding::DefaultFuchsiaResourceDialect,
22604            >,
22605            offset: usize,
22606            _depth: fidl::encoding::Depth,
22607        ) -> fidl::Result<()> {
22608            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22609            // Delegate to tuple encoding.
22610            fidl::encoding::Encode::<
22611                AudioRendererSetReferenceClockRequest,
22612                fidl::encoding::DefaultFuchsiaResourceDialect,
22613            >::encode(
22614                (<fidl::encoding::Optional<
22615                    fidl::encoding::HandleType<
22616                        fidl::Clock,
22617                        { fidl::ObjectType::CLOCK.into_raw() },
22618                        2147483648,
22619                    >,
22620                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22621                    &mut self.reference_clock,
22622                ),),
22623                encoder,
22624                offset,
22625                _depth,
22626            )
22627        }
22628    }
22629    unsafe impl<
22630        T0: fidl::encoding::Encode<
22631                fidl::encoding::Optional<
22632                    fidl::encoding::HandleType<
22633                        fidl::Clock,
22634                        { fidl::ObjectType::CLOCK.into_raw() },
22635                        2147483648,
22636                    >,
22637                >,
22638                fidl::encoding::DefaultFuchsiaResourceDialect,
22639            >,
22640    >
22641        fidl::encoding::Encode<
22642            AudioRendererSetReferenceClockRequest,
22643            fidl::encoding::DefaultFuchsiaResourceDialect,
22644        > for (T0,)
22645    {
22646        #[inline]
22647        unsafe fn encode(
22648            self,
22649            encoder: &mut fidl::encoding::Encoder<
22650                '_,
22651                fidl::encoding::DefaultFuchsiaResourceDialect,
22652            >,
22653            offset: usize,
22654            depth: fidl::encoding::Depth,
22655        ) -> fidl::Result<()> {
22656            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22657            // Zero out padding regions. There's no need to apply masks
22658            // because the unmasked parts will be overwritten by fields.
22659            // Write the fields.
22660            self.0.encode(encoder, offset + 0, depth)?;
22661            Ok(())
22662        }
22663    }
22664
22665    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22666        for AudioRendererSetReferenceClockRequest
22667    {
22668        #[inline(always)]
22669        fn new_empty() -> Self {
22670            Self {
22671                reference_clock: fidl::new_empty!(
22672                    fidl::encoding::Optional<
22673                        fidl::encoding::HandleType<
22674                            fidl::Clock,
22675                            { fidl::ObjectType::CLOCK.into_raw() },
22676                            2147483648,
22677                        >,
22678                    >,
22679                    fidl::encoding::DefaultFuchsiaResourceDialect
22680                ),
22681            }
22682        }
22683
22684        #[inline]
22685        unsafe fn decode(
22686            &mut self,
22687            decoder: &mut fidl::encoding::Decoder<
22688                '_,
22689                fidl::encoding::DefaultFuchsiaResourceDialect,
22690            >,
22691            offset: usize,
22692            _depth: fidl::encoding::Depth,
22693        ) -> fidl::Result<()> {
22694            decoder.debug_check_bounds::<Self>(offset);
22695            // Verify that padding bytes are zero.
22696            fidl::decode!(
22697                fidl::encoding::Optional<
22698                    fidl::encoding::HandleType<
22699                        fidl::Clock,
22700                        { fidl::ObjectType::CLOCK.into_raw() },
22701                        2147483648,
22702                    >,
22703                >,
22704                fidl::encoding::DefaultFuchsiaResourceDialect,
22705                &mut self.reference_clock,
22706                decoder,
22707                offset + 0,
22708                _depth
22709            )?;
22710            Ok(())
22711        }
22712    }
22713
22714    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22715        type Borrowed<'a> = &'a mut Self;
22716        fn take_or_borrow<'a>(
22717            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22718        ) -> Self::Borrowed<'a> {
22719            value
22720        }
22721    }
22722
22723    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22724        type Owned = Self;
22725
22726        #[inline(always)]
22727        fn inline_align(_context: fidl::encoding::Context) -> usize {
22728            8
22729        }
22730
22731        #[inline(always)]
22732        fn inline_size(_context: fidl::encoding::Context) -> usize {
22733            40
22734        }
22735    }
22736
22737    unsafe impl
22738        fidl::encoding::Encode<
22739            ProfileProviderRegisterHandlerWithCapacityRequest,
22740            fidl::encoding::DefaultFuchsiaResourceDialect,
22741        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
22742    {
22743        #[inline]
22744        unsafe fn encode(
22745            self,
22746            encoder: &mut fidl::encoding::Encoder<
22747                '_,
22748                fidl::encoding::DefaultFuchsiaResourceDialect,
22749            >,
22750            offset: usize,
22751            _depth: fidl::encoding::Depth,
22752        ) -> fidl::Result<()> {
22753            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22754            // Delegate to tuple encoding.
22755            fidl::encoding::Encode::<
22756                ProfileProviderRegisterHandlerWithCapacityRequest,
22757                fidl::encoding::DefaultFuchsiaResourceDialect,
22758            >::encode(
22759                (
22760                    <fidl::encoding::HandleType<
22761                        fidl::Thread,
22762                        { fidl::ObjectType::THREAD.into_raw() },
22763                        2147483648,
22764                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22765                        &mut self.thread_handle,
22766                    ),
22767                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22768                        &self.name,
22769                    ),
22770                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
22771                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
22772                ),
22773                encoder,
22774                offset,
22775                _depth,
22776            )
22777        }
22778    }
22779    unsafe impl<
22780        T0: fidl::encoding::Encode<
22781                fidl::encoding::HandleType<
22782                    fidl::Thread,
22783                    { fidl::ObjectType::THREAD.into_raw() },
22784                    2147483648,
22785                >,
22786                fidl::encoding::DefaultFuchsiaResourceDialect,
22787            >,
22788        T1: fidl::encoding::Encode<
22789                fidl::encoding::BoundedString<64>,
22790                fidl::encoding::DefaultFuchsiaResourceDialect,
22791            >,
22792        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
22793        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
22794    >
22795        fidl::encoding::Encode<
22796            ProfileProviderRegisterHandlerWithCapacityRequest,
22797            fidl::encoding::DefaultFuchsiaResourceDialect,
22798        > for (T0, T1, T2, T3)
22799    {
22800        #[inline]
22801        unsafe fn encode(
22802            self,
22803            encoder: &mut fidl::encoding::Encoder<
22804                '_,
22805                fidl::encoding::DefaultFuchsiaResourceDialect,
22806            >,
22807            offset: usize,
22808            depth: fidl::encoding::Depth,
22809        ) -> fidl::Result<()> {
22810            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22811            // Zero out padding regions. There's no need to apply masks
22812            // because the unmasked parts will be overwritten by fields.
22813            unsafe {
22814                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
22815                (ptr as *mut u64).write_unaligned(0);
22816            }
22817            unsafe {
22818                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
22819                (ptr as *mut u64).write_unaligned(0);
22820            }
22821            // Write the fields.
22822            self.0.encode(encoder, offset + 0, depth)?;
22823            self.1.encode(encoder, offset + 8, depth)?;
22824            self.2.encode(encoder, offset + 24, depth)?;
22825            self.3.encode(encoder, offset + 32, depth)?;
22826            Ok(())
22827        }
22828    }
22829
22830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22831        for ProfileProviderRegisterHandlerWithCapacityRequest
22832    {
22833        #[inline(always)]
22834        fn new_empty() -> Self {
22835            Self {
22836                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22837                name: fidl::new_empty!(
22838                    fidl::encoding::BoundedString<64>,
22839                    fidl::encoding::DefaultFuchsiaResourceDialect
22840                ),
22841                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
22842                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
22843            }
22844        }
22845
22846        #[inline]
22847        unsafe fn decode(
22848            &mut self,
22849            decoder: &mut fidl::encoding::Decoder<
22850                '_,
22851                fidl::encoding::DefaultFuchsiaResourceDialect,
22852            >,
22853            offset: usize,
22854            _depth: fidl::encoding::Depth,
22855        ) -> fidl::Result<()> {
22856            decoder.debug_check_bounds::<Self>(offset);
22857            // Verify that padding bytes are zero.
22858            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
22859            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22860            let mask = 0xffffffff00000000u64;
22861            let maskedval = padval & mask;
22862            if maskedval != 0 {
22863                return Err(fidl::Error::NonZeroPadding {
22864                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
22865                });
22866            }
22867            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
22868            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22869            let mask = 0xffffffff00000000u64;
22870            let maskedval = padval & mask;
22871            if maskedval != 0 {
22872                return Err(fidl::Error::NonZeroPadding {
22873                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
22874                });
22875            }
22876            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
22877            fidl::decode!(
22878                fidl::encoding::BoundedString<64>,
22879                fidl::encoding::DefaultFuchsiaResourceDialect,
22880                &mut self.name,
22881                decoder,
22882                offset + 8,
22883                _depth
22884            )?;
22885            fidl::decode!(
22886                i64,
22887                fidl::encoding::DefaultFuchsiaResourceDialect,
22888                &mut self.period,
22889                decoder,
22890                offset + 24,
22891                _depth
22892            )?;
22893            fidl::decode!(
22894                f32,
22895                fidl::encoding::DefaultFuchsiaResourceDialect,
22896                &mut self.capacity,
22897                decoder,
22898                offset + 32,
22899                _depth
22900            )?;
22901            Ok(())
22902        }
22903    }
22904
22905    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22906        type Borrowed<'a> = &'a mut Self;
22907        fn take_or_borrow<'a>(
22908            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22909        ) -> Self::Borrowed<'a> {
22910            value
22911        }
22912    }
22913
22914    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22915        type Owned = Self;
22916
22917        #[inline(always)]
22918        fn inline_align(_context: fidl::encoding::Context) -> usize {
22919            8
22920        }
22921
22922        #[inline(always)]
22923        fn inline_size(_context: fidl::encoding::Context) -> usize {
22924            24
22925        }
22926    }
22927
22928    unsafe impl
22929        fidl::encoding::Encode<
22930            ProfileProviderRegisterMemoryRangeRequest,
22931            fidl::encoding::DefaultFuchsiaResourceDialect,
22932        > for &mut ProfileProviderRegisterMemoryRangeRequest
22933    {
22934        #[inline]
22935        unsafe fn encode(
22936            self,
22937            encoder: &mut fidl::encoding::Encoder<
22938                '_,
22939                fidl::encoding::DefaultFuchsiaResourceDialect,
22940            >,
22941            offset: usize,
22942            _depth: fidl::encoding::Depth,
22943        ) -> fidl::Result<()> {
22944            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
22945            // Delegate to tuple encoding.
22946            fidl::encoding::Encode::<
22947                ProfileProviderRegisterMemoryRangeRequest,
22948                fidl::encoding::DefaultFuchsiaResourceDialect,
22949            >::encode(
22950                (
22951                    <fidl::encoding::HandleType<
22952                        fidl::Vmar,
22953                        { fidl::ObjectType::VMAR.into_raw() },
22954                        2147483648,
22955                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22956                        &mut self.vmar_handle
22957                    ),
22958                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22959                        &self.name,
22960                    ),
22961                ),
22962                encoder,
22963                offset,
22964                _depth,
22965            )
22966        }
22967    }
22968    unsafe impl<
22969        T0: fidl::encoding::Encode<
22970                fidl::encoding::HandleType<
22971                    fidl::Vmar,
22972                    { fidl::ObjectType::VMAR.into_raw() },
22973                    2147483648,
22974                >,
22975                fidl::encoding::DefaultFuchsiaResourceDialect,
22976            >,
22977        T1: fidl::encoding::Encode<
22978                fidl::encoding::BoundedString<64>,
22979                fidl::encoding::DefaultFuchsiaResourceDialect,
22980            >,
22981    >
22982        fidl::encoding::Encode<
22983            ProfileProviderRegisterMemoryRangeRequest,
22984            fidl::encoding::DefaultFuchsiaResourceDialect,
22985        > for (T0, T1)
22986    {
22987        #[inline]
22988        unsafe fn encode(
22989            self,
22990            encoder: &mut fidl::encoding::Encoder<
22991                '_,
22992                fidl::encoding::DefaultFuchsiaResourceDialect,
22993            >,
22994            offset: usize,
22995            depth: fidl::encoding::Depth,
22996        ) -> fidl::Result<()> {
22997            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
22998            // Zero out padding regions. There's no need to apply masks
22999            // because the unmasked parts will be overwritten by fields.
23000            unsafe {
23001                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23002                (ptr as *mut u64).write_unaligned(0);
23003            }
23004            // Write the fields.
23005            self.0.encode(encoder, offset + 0, depth)?;
23006            self.1.encode(encoder, offset + 8, depth)?;
23007            Ok(())
23008        }
23009    }
23010
23011    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23012        for ProfileProviderRegisterMemoryRangeRequest
23013    {
23014        #[inline(always)]
23015        fn new_empty() -> Self {
23016            Self {
23017                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23018                name: fidl::new_empty!(
23019                    fidl::encoding::BoundedString<64>,
23020                    fidl::encoding::DefaultFuchsiaResourceDialect
23021                ),
23022            }
23023        }
23024
23025        #[inline]
23026        unsafe fn decode(
23027            &mut self,
23028            decoder: &mut fidl::encoding::Decoder<
23029                '_,
23030                fidl::encoding::DefaultFuchsiaResourceDialect,
23031            >,
23032            offset: usize,
23033            _depth: fidl::encoding::Depth,
23034        ) -> fidl::Result<()> {
23035            decoder.debug_check_bounds::<Self>(offset);
23036            // Verify that padding bytes are zero.
23037            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23038            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23039            let mask = 0xffffffff00000000u64;
23040            let maskedval = padval & mask;
23041            if maskedval != 0 {
23042                return Err(fidl::Error::NonZeroPadding {
23043                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23044                });
23045            }
23046            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23047            fidl::decode!(
23048                fidl::encoding::BoundedString<64>,
23049                fidl::encoding::DefaultFuchsiaResourceDialect,
23050                &mut self.name,
23051                decoder,
23052                offset + 8,
23053                _depth
23054            )?;
23055            Ok(())
23056        }
23057    }
23058
23059    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
23060        type Borrowed<'a> = &'a mut Self;
23061        fn take_or_borrow<'a>(
23062            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23063        ) -> Self::Borrowed<'a> {
23064            value
23065        }
23066    }
23067
23068    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
23069        type Owned = Self;
23070
23071        #[inline(always)]
23072        fn inline_align(_context: fidl::encoding::Context) -> usize {
23073            8
23074        }
23075
23076        #[inline(always)]
23077        fn inline_size(_context: fidl::encoding::Context) -> usize {
23078            24
23079        }
23080    }
23081
23082    unsafe impl
23083        fidl::encoding::Encode<
23084            ProfileProviderUnregisterHandlerRequest,
23085            fidl::encoding::DefaultFuchsiaResourceDialect,
23086        > for &mut ProfileProviderUnregisterHandlerRequest
23087    {
23088        #[inline]
23089        unsafe fn encode(
23090            self,
23091            encoder: &mut fidl::encoding::Encoder<
23092                '_,
23093                fidl::encoding::DefaultFuchsiaResourceDialect,
23094            >,
23095            offset: usize,
23096            _depth: fidl::encoding::Depth,
23097        ) -> fidl::Result<()> {
23098            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23099            // Delegate to tuple encoding.
23100            fidl::encoding::Encode::<
23101                ProfileProviderUnregisterHandlerRequest,
23102                fidl::encoding::DefaultFuchsiaResourceDialect,
23103            >::encode(
23104                (
23105                    <fidl::encoding::HandleType<
23106                        fidl::Thread,
23107                        { fidl::ObjectType::THREAD.into_raw() },
23108                        2147483648,
23109                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23110                        &mut self.thread_handle,
23111                    ),
23112                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23113                        &self.name,
23114                    ),
23115                ),
23116                encoder,
23117                offset,
23118                _depth,
23119            )
23120        }
23121    }
23122    unsafe impl<
23123        T0: fidl::encoding::Encode<
23124                fidl::encoding::HandleType<
23125                    fidl::Thread,
23126                    { fidl::ObjectType::THREAD.into_raw() },
23127                    2147483648,
23128                >,
23129                fidl::encoding::DefaultFuchsiaResourceDialect,
23130            >,
23131        T1: fidl::encoding::Encode<
23132                fidl::encoding::BoundedString<64>,
23133                fidl::encoding::DefaultFuchsiaResourceDialect,
23134            >,
23135    >
23136        fidl::encoding::Encode<
23137            ProfileProviderUnregisterHandlerRequest,
23138            fidl::encoding::DefaultFuchsiaResourceDialect,
23139        > for (T0, T1)
23140    {
23141        #[inline]
23142        unsafe fn encode(
23143            self,
23144            encoder: &mut fidl::encoding::Encoder<
23145                '_,
23146                fidl::encoding::DefaultFuchsiaResourceDialect,
23147            >,
23148            offset: usize,
23149            depth: fidl::encoding::Depth,
23150        ) -> fidl::Result<()> {
23151            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23152            // Zero out padding regions. There's no need to apply masks
23153            // because the unmasked parts will be overwritten by fields.
23154            unsafe {
23155                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23156                (ptr as *mut u64).write_unaligned(0);
23157            }
23158            // Write the fields.
23159            self.0.encode(encoder, offset + 0, depth)?;
23160            self.1.encode(encoder, offset + 8, depth)?;
23161            Ok(())
23162        }
23163    }
23164
23165    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23166        for ProfileProviderUnregisterHandlerRequest
23167    {
23168        #[inline(always)]
23169        fn new_empty() -> Self {
23170            Self {
23171                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23172                name: fidl::new_empty!(
23173                    fidl::encoding::BoundedString<64>,
23174                    fidl::encoding::DefaultFuchsiaResourceDialect
23175                ),
23176            }
23177        }
23178
23179        #[inline]
23180        unsafe fn decode(
23181            &mut self,
23182            decoder: &mut fidl::encoding::Decoder<
23183                '_,
23184                fidl::encoding::DefaultFuchsiaResourceDialect,
23185            >,
23186            offset: usize,
23187            _depth: fidl::encoding::Depth,
23188        ) -> fidl::Result<()> {
23189            decoder.debug_check_bounds::<Self>(offset);
23190            // Verify that padding bytes are zero.
23191            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23192            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23193            let mask = 0xffffffff00000000u64;
23194            let maskedval = padval & mask;
23195            if maskedval != 0 {
23196                return Err(fidl::Error::NonZeroPadding {
23197                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23198                });
23199            }
23200            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23201            fidl::decode!(
23202                fidl::encoding::BoundedString<64>,
23203                fidl::encoding::DefaultFuchsiaResourceDialect,
23204                &mut self.name,
23205                decoder,
23206                offset + 8,
23207                _depth
23208            )?;
23209            Ok(())
23210        }
23211    }
23212
23213    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23214        type Borrowed<'a> = &'a mut Self;
23215        fn take_or_borrow<'a>(
23216            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23217        ) -> Self::Borrowed<'a> {
23218            value
23219        }
23220    }
23221
23222    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23223        type Owned = Self;
23224
23225        #[inline(always)]
23226        fn inline_align(_context: fidl::encoding::Context) -> usize {
23227            4
23228        }
23229
23230        #[inline(always)]
23231        fn inline_size(_context: fidl::encoding::Context) -> usize {
23232            4
23233        }
23234    }
23235
23236    unsafe impl
23237        fidl::encoding::Encode<
23238            ProfileProviderUnregisterMemoryRangeRequest,
23239            fidl::encoding::DefaultFuchsiaResourceDialect,
23240        > for &mut ProfileProviderUnregisterMemoryRangeRequest
23241    {
23242        #[inline]
23243        unsafe fn encode(
23244            self,
23245            encoder: &mut fidl::encoding::Encoder<
23246                '_,
23247                fidl::encoding::DefaultFuchsiaResourceDialect,
23248            >,
23249            offset: usize,
23250            _depth: fidl::encoding::Depth,
23251        ) -> fidl::Result<()> {
23252            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23253            // Delegate to tuple encoding.
23254            fidl::encoding::Encode::<
23255                ProfileProviderUnregisterMemoryRangeRequest,
23256                fidl::encoding::DefaultFuchsiaResourceDialect,
23257            >::encode(
23258                (<fidl::encoding::HandleType<
23259                    fidl::Vmar,
23260                    { fidl::ObjectType::VMAR.into_raw() },
23261                    2147483648,
23262                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23263                    &mut self.vmar_handle
23264                ),),
23265                encoder,
23266                offset,
23267                _depth,
23268            )
23269        }
23270    }
23271    unsafe impl<
23272        T0: fidl::encoding::Encode<
23273                fidl::encoding::HandleType<
23274                    fidl::Vmar,
23275                    { fidl::ObjectType::VMAR.into_raw() },
23276                    2147483648,
23277                >,
23278                fidl::encoding::DefaultFuchsiaResourceDialect,
23279            >,
23280    >
23281        fidl::encoding::Encode<
23282            ProfileProviderUnregisterMemoryRangeRequest,
23283            fidl::encoding::DefaultFuchsiaResourceDialect,
23284        > for (T0,)
23285    {
23286        #[inline]
23287        unsafe fn encode(
23288            self,
23289            encoder: &mut fidl::encoding::Encoder<
23290                '_,
23291                fidl::encoding::DefaultFuchsiaResourceDialect,
23292            >,
23293            offset: usize,
23294            depth: fidl::encoding::Depth,
23295        ) -> fidl::Result<()> {
23296            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23297            // Zero out padding regions. There's no need to apply masks
23298            // because the unmasked parts will be overwritten by fields.
23299            // Write the fields.
23300            self.0.encode(encoder, offset + 0, depth)?;
23301            Ok(())
23302        }
23303    }
23304
23305    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23306        for ProfileProviderUnregisterMemoryRangeRequest
23307    {
23308        #[inline(always)]
23309        fn new_empty() -> Self {
23310            Self {
23311                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23312            }
23313        }
23314
23315        #[inline]
23316        unsafe fn decode(
23317            &mut self,
23318            decoder: &mut fidl::encoding::Decoder<
23319                '_,
23320                fidl::encoding::DefaultFuchsiaResourceDialect,
23321            >,
23322            offset: usize,
23323            _depth: fidl::encoding::Depth,
23324        ) -> fidl::Result<()> {
23325            decoder.debug_check_bounds::<Self>(offset);
23326            // Verify that padding bytes are zero.
23327            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23328            Ok(())
23329        }
23330    }
23331
23332    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23333        type Borrowed<'a> = &'a mut Self;
23334        fn take_or_borrow<'a>(
23335            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23336        ) -> Self::Borrowed<'a> {
23337            value
23338        }
23339    }
23340
23341    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23342        type Owned = Self;
23343
23344        #[inline(always)]
23345        fn inline_align(_context: fidl::encoding::Context) -> usize {
23346            8
23347        }
23348
23349        #[inline(always)]
23350        fn inline_size(_context: fidl::encoding::Context) -> usize {
23351            16
23352        }
23353    }
23354
23355    unsafe impl
23356        fidl::encoding::Encode<
23357            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23358            fidl::encoding::DefaultFuchsiaResourceDialect,
23359        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
23360    {
23361        #[inline]
23362        unsafe fn encode(
23363            self,
23364            encoder: &mut fidl::encoding::Encoder<
23365                '_,
23366                fidl::encoding::DefaultFuchsiaResourceDialect,
23367            >,
23368            offset: usize,
23369            _depth: fidl::encoding::Depth,
23370        ) -> fidl::Result<()> {
23371            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23372                offset,
23373            );
23374            // Delegate to tuple encoding.
23375            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23376                (
23377                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
23378                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23379                ),
23380                encoder, offset, _depth
23381            )
23382        }
23383    }
23384    unsafe impl<
23385        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
23386        T1: fidl::encoding::Encode<
23387                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23388                fidl::encoding::DefaultFuchsiaResourceDialect,
23389            >,
23390    >
23391        fidl::encoding::Encode<
23392            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23393            fidl::encoding::DefaultFuchsiaResourceDialect,
23394        > for (T0, T1)
23395    {
23396        #[inline]
23397        unsafe fn encode(
23398            self,
23399            encoder: &mut fidl::encoding::Encoder<
23400                '_,
23401                fidl::encoding::DefaultFuchsiaResourceDialect,
23402            >,
23403            offset: usize,
23404            depth: fidl::encoding::Depth,
23405        ) -> fidl::Result<()> {
23406            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23407                offset,
23408            );
23409            // Zero out padding regions. There's no need to apply masks
23410            // because the unmasked parts will be overwritten by fields.
23411            unsafe {
23412                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23413                (ptr as *mut u64).write_unaligned(0);
23414            }
23415            // Write the fields.
23416            self.0.encode(encoder, offset + 0, depth)?;
23417            self.1.encode(encoder, offset + 8, depth)?;
23418            Ok(())
23419        }
23420    }
23421
23422    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23423        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
23424    {
23425        #[inline(always)]
23426        fn new_empty() -> Self {
23427            Self {
23428                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
23429                audio_consumer_request: fidl::new_empty!(
23430                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23431                    fidl::encoding::DefaultFuchsiaResourceDialect
23432                ),
23433            }
23434        }
23435
23436        #[inline]
23437        unsafe fn decode(
23438            &mut self,
23439            decoder: &mut fidl::encoding::Decoder<
23440                '_,
23441                fidl::encoding::DefaultFuchsiaResourceDialect,
23442            >,
23443            offset: usize,
23444            _depth: fidl::encoding::Depth,
23445        ) -> fidl::Result<()> {
23446            decoder.debug_check_bounds::<Self>(offset);
23447            // Verify that padding bytes are zero.
23448            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23449            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23450            let mask = 0xffffffff00000000u64;
23451            let maskedval = padval & mask;
23452            if maskedval != 0 {
23453                return Err(fidl::Error::NonZeroPadding {
23454                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23455                });
23456            }
23457            fidl::decode!(
23458                u64,
23459                fidl::encoding::DefaultFuchsiaResourceDialect,
23460                &mut self.session_id,
23461                decoder,
23462                offset + 0,
23463                _depth
23464            )?;
23465            fidl::decode!(
23466                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23467                fidl::encoding::DefaultFuchsiaResourceDialect,
23468                &mut self.audio_consumer_request,
23469                decoder,
23470                offset + 8,
23471                _depth
23472            )?;
23473            Ok(())
23474        }
23475    }
23476
23477    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
23478        type Borrowed<'a> = &'a mut Self;
23479        fn take_or_borrow<'a>(
23480            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23481        ) -> Self::Borrowed<'a> {
23482            value
23483        }
23484    }
23485
23486    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
23487        type Owned = Self;
23488
23489        #[inline(always)]
23490        fn inline_align(_context: fidl::encoding::Context) -> usize {
23491            4
23492        }
23493
23494        #[inline(always)]
23495        fn inline_size(_context: fidl::encoding::Context) -> usize {
23496            8
23497        }
23498    }
23499
23500    unsafe impl
23501        fidl::encoding::Encode<
23502            StreamBufferSetAddPayloadBufferRequest,
23503            fidl::encoding::DefaultFuchsiaResourceDialect,
23504        > for &mut StreamBufferSetAddPayloadBufferRequest
23505    {
23506        #[inline]
23507        unsafe fn encode(
23508            self,
23509            encoder: &mut fidl::encoding::Encoder<
23510                '_,
23511                fidl::encoding::DefaultFuchsiaResourceDialect,
23512            >,
23513            offset: usize,
23514            _depth: fidl::encoding::Depth,
23515        ) -> fidl::Result<()> {
23516            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23517            // Delegate to tuple encoding.
23518            fidl::encoding::Encode::<
23519                StreamBufferSetAddPayloadBufferRequest,
23520                fidl::encoding::DefaultFuchsiaResourceDialect,
23521            >::encode(
23522                (
23523                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
23524                    <fidl::encoding::HandleType<
23525                        fidl::Vmo,
23526                        { fidl::ObjectType::VMO.into_raw() },
23527                        2147483648,
23528                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23529                        &mut self.payload_buffer,
23530                    ),
23531                ),
23532                encoder,
23533                offset,
23534                _depth,
23535            )
23536        }
23537    }
23538    unsafe impl<
23539        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
23540        T1: fidl::encoding::Encode<
23541                fidl::encoding::HandleType<
23542                    fidl::Vmo,
23543                    { fidl::ObjectType::VMO.into_raw() },
23544                    2147483648,
23545                >,
23546                fidl::encoding::DefaultFuchsiaResourceDialect,
23547            >,
23548    >
23549        fidl::encoding::Encode<
23550            StreamBufferSetAddPayloadBufferRequest,
23551            fidl::encoding::DefaultFuchsiaResourceDialect,
23552        > for (T0, T1)
23553    {
23554        #[inline]
23555        unsafe fn encode(
23556            self,
23557            encoder: &mut fidl::encoding::Encoder<
23558                '_,
23559                fidl::encoding::DefaultFuchsiaResourceDialect,
23560            >,
23561            offset: usize,
23562            depth: fidl::encoding::Depth,
23563        ) -> fidl::Result<()> {
23564            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23565            // Zero out padding regions. There's no need to apply masks
23566            // because the unmasked parts will be overwritten by fields.
23567            // Write the fields.
23568            self.0.encode(encoder, offset + 0, depth)?;
23569            self.1.encode(encoder, offset + 4, depth)?;
23570            Ok(())
23571        }
23572    }
23573
23574    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23575        for StreamBufferSetAddPayloadBufferRequest
23576    {
23577        #[inline(always)]
23578        fn new_empty() -> Self {
23579            Self {
23580                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
23581                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23582            }
23583        }
23584
23585        #[inline]
23586        unsafe fn decode(
23587            &mut self,
23588            decoder: &mut fidl::encoding::Decoder<
23589                '_,
23590                fidl::encoding::DefaultFuchsiaResourceDialect,
23591            >,
23592            offset: usize,
23593            _depth: fidl::encoding::Depth,
23594        ) -> fidl::Result<()> {
23595            decoder.debug_check_bounds::<Self>(offset);
23596            // Verify that padding bytes are zero.
23597            fidl::decode!(
23598                u32,
23599                fidl::encoding::DefaultFuchsiaResourceDialect,
23600                &mut self.id,
23601                decoder,
23602                offset + 0,
23603                _depth
23604            )?;
23605            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
23606            Ok(())
23607        }
23608    }
23609
23610    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23611        type Borrowed<'a> = &'a mut Self;
23612        fn take_or_borrow<'a>(
23613            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23614        ) -> Self::Borrowed<'a> {
23615            value
23616        }
23617    }
23618
23619    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23620        type Owned = Self;
23621
23622        #[inline(always)]
23623        fn inline_align(_context: fidl::encoding::Context) -> usize {
23624            8
23625        }
23626
23627        #[inline(always)]
23628        fn inline_size(_context: fidl::encoding::Context) -> usize {
23629            16
23630        }
23631    }
23632
23633    unsafe impl
23634        fidl::encoding::Encode<
23635            StreamProcessorSetInputBufferPartialSettingsRequest,
23636            fidl::encoding::DefaultFuchsiaResourceDialect,
23637        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
23638    {
23639        #[inline]
23640        unsafe fn encode(
23641            self,
23642            encoder: &mut fidl::encoding::Encoder<
23643                '_,
23644                fidl::encoding::DefaultFuchsiaResourceDialect,
23645            >,
23646            offset: usize,
23647            _depth: fidl::encoding::Depth,
23648        ) -> fidl::Result<()> {
23649            encoder
23650                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23651            // Delegate to tuple encoding.
23652            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23653                (
23654                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
23655                ),
23656                encoder, offset, _depth
23657            )
23658        }
23659    }
23660    unsafe impl<
23661        T0: fidl::encoding::Encode<
23662                StreamBufferPartialSettings,
23663                fidl::encoding::DefaultFuchsiaResourceDialect,
23664            >,
23665    >
23666        fidl::encoding::Encode<
23667            StreamProcessorSetInputBufferPartialSettingsRequest,
23668            fidl::encoding::DefaultFuchsiaResourceDialect,
23669        > for (T0,)
23670    {
23671        #[inline]
23672        unsafe fn encode(
23673            self,
23674            encoder: &mut fidl::encoding::Encoder<
23675                '_,
23676                fidl::encoding::DefaultFuchsiaResourceDialect,
23677            >,
23678            offset: usize,
23679            depth: fidl::encoding::Depth,
23680        ) -> fidl::Result<()> {
23681            encoder
23682                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23683            // Zero out padding regions. There's no need to apply masks
23684            // because the unmasked parts will be overwritten by fields.
23685            // Write the fields.
23686            self.0.encode(encoder, offset + 0, depth)?;
23687            Ok(())
23688        }
23689    }
23690
23691    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23692        for StreamProcessorSetInputBufferPartialSettingsRequest
23693    {
23694        #[inline(always)]
23695        fn new_empty() -> Self {
23696            Self {
23697                input_settings: fidl::new_empty!(
23698                    StreamBufferPartialSettings,
23699                    fidl::encoding::DefaultFuchsiaResourceDialect
23700                ),
23701            }
23702        }
23703
23704        #[inline]
23705        unsafe fn decode(
23706            &mut self,
23707            decoder: &mut fidl::encoding::Decoder<
23708                '_,
23709                fidl::encoding::DefaultFuchsiaResourceDialect,
23710            >,
23711            offset: usize,
23712            _depth: fidl::encoding::Depth,
23713        ) -> fidl::Result<()> {
23714            decoder.debug_check_bounds::<Self>(offset);
23715            // Verify that padding bytes are zero.
23716            fidl::decode!(
23717                StreamBufferPartialSettings,
23718                fidl::encoding::DefaultFuchsiaResourceDialect,
23719                &mut self.input_settings,
23720                decoder,
23721                offset + 0,
23722                _depth
23723            )?;
23724            Ok(())
23725        }
23726    }
23727
23728    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23729        type Borrowed<'a> = &'a mut Self;
23730        fn take_or_borrow<'a>(
23731            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23732        ) -> Self::Borrowed<'a> {
23733            value
23734        }
23735    }
23736
23737    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23738        type Owned = Self;
23739
23740        #[inline(always)]
23741        fn inline_align(_context: fidl::encoding::Context) -> usize {
23742            8
23743        }
23744
23745        #[inline(always)]
23746        fn inline_size(_context: fidl::encoding::Context) -> usize {
23747            16
23748        }
23749    }
23750
23751    unsafe impl
23752        fidl::encoding::Encode<
23753            StreamProcessorSetOutputBufferPartialSettingsRequest,
23754            fidl::encoding::DefaultFuchsiaResourceDialect,
23755        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
23756    {
23757        #[inline]
23758        unsafe fn encode(
23759            self,
23760            encoder: &mut fidl::encoding::Encoder<
23761                '_,
23762                fidl::encoding::DefaultFuchsiaResourceDialect,
23763            >,
23764            offset: usize,
23765            _depth: fidl::encoding::Depth,
23766        ) -> fidl::Result<()> {
23767            encoder
23768                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23769            // Delegate to tuple encoding.
23770            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23771                (
23772                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
23773                ),
23774                encoder, offset, _depth
23775            )
23776        }
23777    }
23778    unsafe impl<
23779        T0: fidl::encoding::Encode<
23780                StreamBufferPartialSettings,
23781                fidl::encoding::DefaultFuchsiaResourceDialect,
23782            >,
23783    >
23784        fidl::encoding::Encode<
23785            StreamProcessorSetOutputBufferPartialSettingsRequest,
23786            fidl::encoding::DefaultFuchsiaResourceDialect,
23787        > for (T0,)
23788    {
23789        #[inline]
23790        unsafe fn encode(
23791            self,
23792            encoder: &mut fidl::encoding::Encoder<
23793                '_,
23794                fidl::encoding::DefaultFuchsiaResourceDialect,
23795            >,
23796            offset: usize,
23797            depth: fidl::encoding::Depth,
23798        ) -> fidl::Result<()> {
23799            encoder
23800                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23801            // Zero out padding regions. There's no need to apply masks
23802            // because the unmasked parts will be overwritten by fields.
23803            // Write the fields.
23804            self.0.encode(encoder, offset + 0, depth)?;
23805            Ok(())
23806        }
23807    }
23808
23809    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23810        for StreamProcessorSetOutputBufferPartialSettingsRequest
23811    {
23812        #[inline(always)]
23813        fn new_empty() -> Self {
23814            Self {
23815                output_settings: fidl::new_empty!(
23816                    StreamBufferPartialSettings,
23817                    fidl::encoding::DefaultFuchsiaResourceDialect
23818                ),
23819            }
23820        }
23821
23822        #[inline]
23823        unsafe fn decode(
23824            &mut self,
23825            decoder: &mut fidl::encoding::Decoder<
23826                '_,
23827                fidl::encoding::DefaultFuchsiaResourceDialect,
23828            >,
23829            offset: usize,
23830            _depth: fidl::encoding::Depth,
23831        ) -> fidl::Result<()> {
23832            decoder.debug_check_bounds::<Self>(offset);
23833            // Verify that padding bytes are zero.
23834            fidl::decode!(
23835                StreamBufferPartialSettings,
23836                fidl::encoding::DefaultFuchsiaResourceDialect,
23837                &mut self.output_settings,
23838                decoder,
23839                offset + 0,
23840                _depth
23841            )?;
23842            Ok(())
23843        }
23844    }
23845
23846    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23847        type Borrowed<'a> = &'a mut Self;
23848        fn take_or_borrow<'a>(
23849            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23850        ) -> Self::Borrowed<'a> {
23851            value
23852        }
23853    }
23854
23855    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23856        type Owned = Self;
23857
23858        #[inline(always)]
23859        fn inline_align(_context: fidl::encoding::Context) -> usize {
23860            4
23861        }
23862
23863        #[inline(always)]
23864        fn inline_size(_context: fidl::encoding::Context) -> usize {
23865            8
23866        }
23867    }
23868
23869    unsafe impl
23870        fidl::encoding::Encode<
23871            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23872            fidl::encoding::DefaultFuchsiaResourceDialect,
23873        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23874    {
23875        #[inline]
23876        unsafe fn encode(
23877            self,
23878            encoder: &mut fidl::encoding::Encoder<
23879                '_,
23880                fidl::encoding::DefaultFuchsiaResourceDialect,
23881            >,
23882            offset: usize,
23883            _depth: fidl::encoding::Depth,
23884        ) -> fidl::Result<()> {
23885            encoder
23886                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23887            // Delegate to tuple encoding.
23888            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23889                (
23890                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23891                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23892                ),
23893                encoder, offset, _depth
23894            )
23895        }
23896    }
23897    unsafe impl<
23898        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
23899        T1: fidl::encoding::Encode<
23900                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23901                fidl::encoding::DefaultFuchsiaResourceDialect,
23902            >,
23903    >
23904        fidl::encoding::Encode<
23905            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23906            fidl::encoding::DefaultFuchsiaResourceDialect,
23907        > for (T0, T1)
23908    {
23909        #[inline]
23910        unsafe fn encode(
23911            self,
23912            encoder: &mut fidl::encoding::Encoder<
23913                '_,
23914                fidl::encoding::DefaultFuchsiaResourceDialect,
23915            >,
23916            offset: usize,
23917            depth: fidl::encoding::Depth,
23918        ) -> fidl::Result<()> {
23919            encoder
23920                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23921            // Zero out padding regions. There's no need to apply masks
23922            // because the unmasked parts will be overwritten by fields.
23923            // Write the fields.
23924            self.0.encode(encoder, offset + 0, depth)?;
23925            self.1.encode(encoder, offset + 4, depth)?;
23926            Ok(())
23927        }
23928    }
23929
23930    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23931        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23932    {
23933        #[inline(always)]
23934        fn new_empty() -> Self {
23935            Self {
23936                usage: fidl::new_empty!(
23937                    AudioRenderUsage2,
23938                    fidl::encoding::DefaultFuchsiaResourceDialect
23939                ),
23940                audio_consumer_request: fidl::new_empty!(
23941                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23942                    fidl::encoding::DefaultFuchsiaResourceDialect
23943                ),
23944            }
23945        }
23946
23947        #[inline]
23948        unsafe fn decode(
23949            &mut self,
23950            decoder: &mut fidl::encoding::Decoder<
23951                '_,
23952                fidl::encoding::DefaultFuchsiaResourceDialect,
23953            >,
23954            offset: usize,
23955            _depth: fidl::encoding::Depth,
23956        ) -> fidl::Result<()> {
23957            decoder.debug_check_bounds::<Self>(offset);
23958            // Verify that padding bytes are zero.
23959            fidl::decode!(
23960                AudioRenderUsage2,
23961                fidl::encoding::DefaultFuchsiaResourceDialect,
23962                &mut self.usage,
23963                decoder,
23964                offset + 0,
23965                _depth
23966            )?;
23967            fidl::decode!(
23968                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23969                fidl::encoding::DefaultFuchsiaResourceDialect,
23970                &mut self.audio_consumer_request,
23971                decoder,
23972                offset + 4,
23973                _depth
23974            )?;
23975            Ok(())
23976        }
23977    }
23978
23979    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
23980        type Borrowed<'a> = &'a mut Self;
23981        fn take_or_borrow<'a>(
23982            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23983        ) -> Self::Borrowed<'a> {
23984            value
23985        }
23986    }
23987
23988    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
23989        type Owned = Self;
23990
23991        #[inline(always)]
23992        fn inline_align(_context: fidl::encoding::Context) -> usize {
23993            4
23994        }
23995
23996        #[inline(always)]
23997        fn inline_size(_context: fidl::encoding::Context) -> usize {
23998            8
23999        }
24000    }
24001
24002    unsafe impl
24003        fidl::encoding::Encode<
24004            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24005            fidl::encoding::DefaultFuchsiaResourceDialect,
24006        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
24007    {
24008        #[inline]
24009        unsafe fn encode(
24010            self,
24011            encoder: &mut fidl::encoding::Encoder<
24012                '_,
24013                fidl::encoding::DefaultFuchsiaResourceDialect,
24014            >,
24015            offset: usize,
24016            _depth: fidl::encoding::Depth,
24017        ) -> fidl::Result<()> {
24018            encoder
24019                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24020            // Delegate to tuple encoding.
24021            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24022                (
24023                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24024                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24025                ),
24026                encoder, offset, _depth
24027            )
24028        }
24029    }
24030    unsafe impl<
24031        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24032        T1: fidl::encoding::Encode<
24033                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24034                fidl::encoding::DefaultFuchsiaResourceDialect,
24035            >,
24036    >
24037        fidl::encoding::Encode<
24038            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24039            fidl::encoding::DefaultFuchsiaResourceDialect,
24040        > for (T0, T1)
24041    {
24042        #[inline]
24043        unsafe fn encode(
24044            self,
24045            encoder: &mut fidl::encoding::Encoder<
24046                '_,
24047                fidl::encoding::DefaultFuchsiaResourceDialect,
24048            >,
24049            offset: usize,
24050            depth: fidl::encoding::Depth,
24051        ) -> fidl::Result<()> {
24052            encoder
24053                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24054            // Zero out padding regions. There's no need to apply masks
24055            // because the unmasked parts will be overwritten by fields.
24056            // Write the fields.
24057            self.0.encode(encoder, offset + 0, depth)?;
24058            self.1.encode(encoder, offset + 4, depth)?;
24059            Ok(())
24060        }
24061    }
24062
24063    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24064        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
24065    {
24066        #[inline(always)]
24067        fn new_empty() -> Self {
24068            Self {
24069                usage: fidl::new_empty!(
24070                    AudioRenderUsage,
24071                    fidl::encoding::DefaultFuchsiaResourceDialect
24072                ),
24073                audio_consumer_request: fidl::new_empty!(
24074                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24075                    fidl::encoding::DefaultFuchsiaResourceDialect
24076                ),
24077            }
24078        }
24079
24080        #[inline]
24081        unsafe fn decode(
24082            &mut self,
24083            decoder: &mut fidl::encoding::Decoder<
24084                '_,
24085                fidl::encoding::DefaultFuchsiaResourceDialect,
24086            >,
24087            offset: usize,
24088            _depth: fidl::encoding::Depth,
24089        ) -> fidl::Result<()> {
24090            decoder.debug_check_bounds::<Self>(offset);
24091            // Verify that padding bytes are zero.
24092            fidl::decode!(
24093                AudioRenderUsage,
24094                fidl::encoding::DefaultFuchsiaResourceDialect,
24095                &mut self.usage,
24096                decoder,
24097                offset + 0,
24098                _depth
24099            )?;
24100            fidl::decode!(
24101                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24102                fidl::encoding::DefaultFuchsiaResourceDialect,
24103                &mut self.audio_consumer_request,
24104                decoder,
24105                offset + 4,
24106                _depth
24107            )?;
24108            Ok(())
24109        }
24110    }
24111
24112    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
24113        type Borrowed<'a> = &'a mut Self;
24114        fn take_or_borrow<'a>(
24115            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24116        ) -> Self::Borrowed<'a> {
24117            value
24118        }
24119    }
24120
24121    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
24122        type Owned = Self;
24123
24124        #[inline(always)]
24125        fn inline_align(_context: fidl::encoding::Context) -> usize {
24126            8
24127        }
24128
24129        #[inline(always)]
24130        fn inline_size(_context: fidl::encoding::Context) -> usize {
24131            40
24132        }
24133    }
24134
24135    unsafe impl
24136        fidl::encoding::Encode<
24137            UsageGainReporterRegisterListener2Request,
24138            fidl::encoding::DefaultFuchsiaResourceDialect,
24139        > for &mut UsageGainReporterRegisterListener2Request
24140    {
24141        #[inline]
24142        unsafe fn encode(
24143            self,
24144            encoder: &mut fidl::encoding::Encoder<
24145                '_,
24146                fidl::encoding::DefaultFuchsiaResourceDialect,
24147            >,
24148            offset: usize,
24149            _depth: fidl::encoding::Depth,
24150        ) -> fidl::Result<()> {
24151            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24152            // Delegate to tuple encoding.
24153            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24154                (
24155                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24156                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24157                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24158                ),
24159                encoder, offset, _depth
24160            )
24161        }
24162    }
24163    unsafe impl<
24164        T0: fidl::encoding::Encode<
24165                fidl::encoding::BoundedString<36>,
24166                fidl::encoding::DefaultFuchsiaResourceDialect,
24167            >,
24168        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24169        T2: fidl::encoding::Encode<
24170                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24171                fidl::encoding::DefaultFuchsiaResourceDialect,
24172            >,
24173    >
24174        fidl::encoding::Encode<
24175            UsageGainReporterRegisterListener2Request,
24176            fidl::encoding::DefaultFuchsiaResourceDialect,
24177        > for (T0, T1, T2)
24178    {
24179        #[inline]
24180        unsafe fn encode(
24181            self,
24182            encoder: &mut fidl::encoding::Encoder<
24183                '_,
24184                fidl::encoding::DefaultFuchsiaResourceDialect,
24185            >,
24186            offset: usize,
24187            depth: fidl::encoding::Depth,
24188        ) -> fidl::Result<()> {
24189            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24190            // Zero out padding regions. There's no need to apply masks
24191            // because the unmasked parts will be overwritten by fields.
24192            unsafe {
24193                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24194                (ptr as *mut u64).write_unaligned(0);
24195            }
24196            // Write the fields.
24197            self.0.encode(encoder, offset + 0, depth)?;
24198            self.1.encode(encoder, offset + 16, depth)?;
24199            self.2.encode(encoder, offset + 32, depth)?;
24200            Ok(())
24201        }
24202    }
24203
24204    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24205        for UsageGainReporterRegisterListener2Request
24206    {
24207        #[inline(always)]
24208        fn new_empty() -> Self {
24209            Self {
24210                device_unique_id: fidl::new_empty!(
24211                    fidl::encoding::BoundedString<36>,
24212                    fidl::encoding::DefaultFuchsiaResourceDialect
24213                ),
24214                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24215                usage_gain_listener: fidl::new_empty!(
24216                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24217                    fidl::encoding::DefaultFuchsiaResourceDialect
24218                ),
24219            }
24220        }
24221
24222        #[inline]
24223        unsafe fn decode(
24224            &mut self,
24225            decoder: &mut fidl::encoding::Decoder<
24226                '_,
24227                fidl::encoding::DefaultFuchsiaResourceDialect,
24228            >,
24229            offset: usize,
24230            _depth: fidl::encoding::Depth,
24231        ) -> fidl::Result<()> {
24232            decoder.debug_check_bounds::<Self>(offset);
24233            // Verify that padding bytes are zero.
24234            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24235            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24236            let mask = 0xffffffff00000000u64;
24237            let maskedval = padval & mask;
24238            if maskedval != 0 {
24239                return Err(fidl::Error::NonZeroPadding {
24240                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24241                });
24242            }
24243            fidl::decode!(
24244                fidl::encoding::BoundedString<36>,
24245                fidl::encoding::DefaultFuchsiaResourceDialect,
24246                &mut self.device_unique_id,
24247                decoder,
24248                offset + 0,
24249                _depth
24250            )?;
24251            fidl::decode!(
24252                Usage2,
24253                fidl::encoding::DefaultFuchsiaResourceDialect,
24254                &mut self.usage,
24255                decoder,
24256                offset + 16,
24257                _depth
24258            )?;
24259            fidl::decode!(
24260                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24261                fidl::encoding::DefaultFuchsiaResourceDialect,
24262                &mut self.usage_gain_listener,
24263                decoder,
24264                offset + 32,
24265                _depth
24266            )?;
24267            Ok(())
24268        }
24269    }
24270
24271    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
24272        type Borrowed<'a> = &'a mut Self;
24273        fn take_or_borrow<'a>(
24274            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24275        ) -> Self::Borrowed<'a> {
24276            value
24277        }
24278    }
24279
24280    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
24281        type Owned = Self;
24282
24283        #[inline(always)]
24284        fn inline_align(_context: fidl::encoding::Context) -> usize {
24285            8
24286        }
24287
24288        #[inline(always)]
24289        fn inline_size(_context: fidl::encoding::Context) -> usize {
24290            40
24291        }
24292    }
24293
24294    unsafe impl
24295        fidl::encoding::Encode<
24296            UsageGainReporterRegisterListenerRequest,
24297            fidl::encoding::DefaultFuchsiaResourceDialect,
24298        > for &mut UsageGainReporterRegisterListenerRequest
24299    {
24300        #[inline]
24301        unsafe fn encode(
24302            self,
24303            encoder: &mut fidl::encoding::Encoder<
24304                '_,
24305                fidl::encoding::DefaultFuchsiaResourceDialect,
24306            >,
24307            offset: usize,
24308            _depth: fidl::encoding::Depth,
24309        ) -> fidl::Result<()> {
24310            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24311            // Delegate to tuple encoding.
24312            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24313                (
24314                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24315                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24316                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24317                ),
24318                encoder, offset, _depth
24319            )
24320        }
24321    }
24322    unsafe impl<
24323        T0: fidl::encoding::Encode<
24324                fidl::encoding::BoundedString<36>,
24325                fidl::encoding::DefaultFuchsiaResourceDialect,
24326            >,
24327        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24328        T2: fidl::encoding::Encode<
24329                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24330                fidl::encoding::DefaultFuchsiaResourceDialect,
24331            >,
24332    >
24333        fidl::encoding::Encode<
24334            UsageGainReporterRegisterListenerRequest,
24335            fidl::encoding::DefaultFuchsiaResourceDialect,
24336        > for (T0, T1, T2)
24337    {
24338        #[inline]
24339        unsafe fn encode(
24340            self,
24341            encoder: &mut fidl::encoding::Encoder<
24342                '_,
24343                fidl::encoding::DefaultFuchsiaResourceDialect,
24344            >,
24345            offset: usize,
24346            depth: fidl::encoding::Depth,
24347        ) -> fidl::Result<()> {
24348            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24349            // Zero out padding regions. There's no need to apply masks
24350            // because the unmasked parts will be overwritten by fields.
24351            unsafe {
24352                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24353                (ptr as *mut u64).write_unaligned(0);
24354            }
24355            // Write the fields.
24356            self.0.encode(encoder, offset + 0, depth)?;
24357            self.1.encode(encoder, offset + 16, depth)?;
24358            self.2.encode(encoder, offset + 32, depth)?;
24359            Ok(())
24360        }
24361    }
24362
24363    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24364        for UsageGainReporterRegisterListenerRequest
24365    {
24366        #[inline(always)]
24367        fn new_empty() -> Self {
24368            Self {
24369                device_unique_id: fidl::new_empty!(
24370                    fidl::encoding::BoundedString<36>,
24371                    fidl::encoding::DefaultFuchsiaResourceDialect
24372                ),
24373                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24374                usage_gain_listener: fidl::new_empty!(
24375                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24376                    fidl::encoding::DefaultFuchsiaResourceDialect
24377                ),
24378            }
24379        }
24380
24381        #[inline]
24382        unsafe fn decode(
24383            &mut self,
24384            decoder: &mut fidl::encoding::Decoder<
24385                '_,
24386                fidl::encoding::DefaultFuchsiaResourceDialect,
24387            >,
24388            offset: usize,
24389            _depth: fidl::encoding::Depth,
24390        ) -> fidl::Result<()> {
24391            decoder.debug_check_bounds::<Self>(offset);
24392            // Verify that padding bytes are zero.
24393            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24394            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24395            let mask = 0xffffffff00000000u64;
24396            let maskedval = padval & mask;
24397            if maskedval != 0 {
24398                return Err(fidl::Error::NonZeroPadding {
24399                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24400                });
24401            }
24402            fidl::decode!(
24403                fidl::encoding::BoundedString<36>,
24404                fidl::encoding::DefaultFuchsiaResourceDialect,
24405                &mut self.device_unique_id,
24406                decoder,
24407                offset + 0,
24408                _depth
24409            )?;
24410            fidl::decode!(
24411                Usage,
24412                fidl::encoding::DefaultFuchsiaResourceDialect,
24413                &mut self.usage,
24414                decoder,
24415                offset + 16,
24416                _depth
24417            )?;
24418            fidl::decode!(
24419                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24420                fidl::encoding::DefaultFuchsiaResourceDialect,
24421                &mut self.usage_gain_listener,
24422                decoder,
24423                offset + 32,
24424                _depth
24425            )?;
24426            Ok(())
24427        }
24428    }
24429
24430    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
24431        type Borrowed<'a> = &'a mut Self;
24432        fn take_or_borrow<'a>(
24433            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24434        ) -> Self::Borrowed<'a> {
24435            value
24436        }
24437    }
24438
24439    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
24440        type Owned = Self;
24441
24442        #[inline(always)]
24443        fn inline_align(_context: fidl::encoding::Context) -> usize {
24444            8
24445        }
24446
24447        #[inline(always)]
24448        fn inline_size(_context: fidl::encoding::Context) -> usize {
24449            24
24450        }
24451    }
24452
24453    unsafe impl
24454        fidl::encoding::Encode<
24455            UsageReporterWatch2Request,
24456            fidl::encoding::DefaultFuchsiaResourceDialect,
24457        > for &mut UsageReporterWatch2Request
24458    {
24459        #[inline]
24460        unsafe fn encode(
24461            self,
24462            encoder: &mut fidl::encoding::Encoder<
24463                '_,
24464                fidl::encoding::DefaultFuchsiaResourceDialect,
24465            >,
24466            offset: usize,
24467            _depth: fidl::encoding::Depth,
24468        ) -> fidl::Result<()> {
24469            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24470            // Delegate to tuple encoding.
24471            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24472                (
24473                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24474                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24475                ),
24476                encoder, offset, _depth
24477            )
24478        }
24479    }
24480    unsafe impl<
24481        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24482        T1: fidl::encoding::Encode<
24483                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24484                fidl::encoding::DefaultFuchsiaResourceDialect,
24485            >,
24486    >
24487        fidl::encoding::Encode<
24488            UsageReporterWatch2Request,
24489            fidl::encoding::DefaultFuchsiaResourceDialect,
24490        > for (T0, T1)
24491    {
24492        #[inline]
24493        unsafe fn encode(
24494            self,
24495            encoder: &mut fidl::encoding::Encoder<
24496                '_,
24497                fidl::encoding::DefaultFuchsiaResourceDialect,
24498            >,
24499            offset: usize,
24500            depth: fidl::encoding::Depth,
24501        ) -> fidl::Result<()> {
24502            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24503            // Zero out padding regions. There's no need to apply masks
24504            // because the unmasked parts will be overwritten by fields.
24505            unsafe {
24506                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24507                (ptr as *mut u64).write_unaligned(0);
24508            }
24509            // Write the fields.
24510            self.0.encode(encoder, offset + 0, depth)?;
24511            self.1.encode(encoder, offset + 16, depth)?;
24512            Ok(())
24513        }
24514    }
24515
24516    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24517        for UsageReporterWatch2Request
24518    {
24519        #[inline(always)]
24520        fn new_empty() -> Self {
24521            Self {
24522                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24523                usage_watcher: fidl::new_empty!(
24524                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24525                    fidl::encoding::DefaultFuchsiaResourceDialect
24526                ),
24527            }
24528        }
24529
24530        #[inline]
24531        unsafe fn decode(
24532            &mut self,
24533            decoder: &mut fidl::encoding::Decoder<
24534                '_,
24535                fidl::encoding::DefaultFuchsiaResourceDialect,
24536            >,
24537            offset: usize,
24538            _depth: fidl::encoding::Depth,
24539        ) -> fidl::Result<()> {
24540            decoder.debug_check_bounds::<Self>(offset);
24541            // Verify that padding bytes are zero.
24542            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24543            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24544            let mask = 0xffffffff00000000u64;
24545            let maskedval = padval & mask;
24546            if maskedval != 0 {
24547                return Err(fidl::Error::NonZeroPadding {
24548                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24549                });
24550            }
24551            fidl::decode!(
24552                Usage2,
24553                fidl::encoding::DefaultFuchsiaResourceDialect,
24554                &mut self.usage,
24555                decoder,
24556                offset + 0,
24557                _depth
24558            )?;
24559            fidl::decode!(
24560                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24561                fidl::encoding::DefaultFuchsiaResourceDialect,
24562                &mut self.usage_watcher,
24563                decoder,
24564                offset + 16,
24565                _depth
24566            )?;
24567            Ok(())
24568        }
24569    }
24570
24571    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
24572        type Borrowed<'a> = &'a mut Self;
24573        fn take_or_borrow<'a>(
24574            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24575        ) -> Self::Borrowed<'a> {
24576            value
24577        }
24578    }
24579
24580    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
24581        type Owned = Self;
24582
24583        #[inline(always)]
24584        fn inline_align(_context: fidl::encoding::Context) -> usize {
24585            8
24586        }
24587
24588        #[inline(always)]
24589        fn inline_size(_context: fidl::encoding::Context) -> usize {
24590            24
24591        }
24592    }
24593
24594    unsafe impl
24595        fidl::encoding::Encode<
24596            UsageReporterWatchRequest,
24597            fidl::encoding::DefaultFuchsiaResourceDialect,
24598        > for &mut UsageReporterWatchRequest
24599    {
24600        #[inline]
24601        unsafe fn encode(
24602            self,
24603            encoder: &mut fidl::encoding::Encoder<
24604                '_,
24605                fidl::encoding::DefaultFuchsiaResourceDialect,
24606            >,
24607            offset: usize,
24608            _depth: fidl::encoding::Depth,
24609        ) -> fidl::Result<()> {
24610            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24611            // Delegate to tuple encoding.
24612            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24613                (
24614                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24615                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24616                ),
24617                encoder, offset, _depth
24618            )
24619        }
24620    }
24621    unsafe impl<
24622        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24623        T1: fidl::encoding::Encode<
24624                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24625                fidl::encoding::DefaultFuchsiaResourceDialect,
24626            >,
24627    >
24628        fidl::encoding::Encode<
24629            UsageReporterWatchRequest,
24630            fidl::encoding::DefaultFuchsiaResourceDialect,
24631        > for (T0, T1)
24632    {
24633        #[inline]
24634        unsafe fn encode(
24635            self,
24636            encoder: &mut fidl::encoding::Encoder<
24637                '_,
24638                fidl::encoding::DefaultFuchsiaResourceDialect,
24639            >,
24640            offset: usize,
24641            depth: fidl::encoding::Depth,
24642        ) -> fidl::Result<()> {
24643            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24644            // Zero out padding regions. There's no need to apply masks
24645            // because the unmasked parts will be overwritten by fields.
24646            unsafe {
24647                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24648                (ptr as *mut u64).write_unaligned(0);
24649            }
24650            // Write the fields.
24651            self.0.encode(encoder, offset + 0, depth)?;
24652            self.1.encode(encoder, offset + 16, depth)?;
24653            Ok(())
24654        }
24655    }
24656
24657    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24658        for UsageReporterWatchRequest
24659    {
24660        #[inline(always)]
24661        fn new_empty() -> Self {
24662            Self {
24663                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24664                usage_watcher: fidl::new_empty!(
24665                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24666                    fidl::encoding::DefaultFuchsiaResourceDialect
24667                ),
24668            }
24669        }
24670
24671        #[inline]
24672        unsafe fn decode(
24673            &mut self,
24674            decoder: &mut fidl::encoding::Decoder<
24675                '_,
24676                fidl::encoding::DefaultFuchsiaResourceDialect,
24677            >,
24678            offset: usize,
24679            _depth: fidl::encoding::Depth,
24680        ) -> fidl::Result<()> {
24681            decoder.debug_check_bounds::<Self>(offset);
24682            // Verify that padding bytes are zero.
24683            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24684            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24685            let mask = 0xffffffff00000000u64;
24686            let maskedval = padval & mask;
24687            if maskedval != 0 {
24688                return Err(fidl::Error::NonZeroPadding {
24689                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24690                });
24691            }
24692            fidl::decode!(
24693                Usage,
24694                fidl::encoding::DefaultFuchsiaResourceDialect,
24695                &mut self.usage,
24696                decoder,
24697                offset + 0,
24698                _depth
24699            )?;
24700            fidl::decode!(
24701                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24702                fidl::encoding::DefaultFuchsiaResourceDialect,
24703                &mut self.usage_watcher,
24704                decoder,
24705                offset + 16,
24706                _depth
24707            )?;
24708            Ok(())
24709        }
24710    }
24711
24712    impl StreamBufferPartialSettings {
24713        #[inline(always)]
24714        fn max_ordinal_present(&self) -> u64 {
24715            if let Some(_) = self.sysmem2_token {
24716                return 7;
24717            }
24718            if let Some(_) = self.sysmem_token {
24719                return 6;
24720            }
24721            if let Some(_) = self.packet_count_for_client {
24722                return 5;
24723            }
24724            if let Some(_) = self.packet_count_for_server {
24725                return 4;
24726            }
24727            if let Some(_) = self.single_buffer_mode {
24728                return 3;
24729            }
24730            if let Some(_) = self.buffer_constraints_version_ordinal {
24731                return 2;
24732            }
24733            if let Some(_) = self.buffer_lifetime_ordinal {
24734                return 1;
24735            }
24736            0
24737        }
24738    }
24739
24740    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
24741        type Borrowed<'a> = &'a mut Self;
24742        fn take_or_borrow<'a>(
24743            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24744        ) -> Self::Borrowed<'a> {
24745            value
24746        }
24747    }
24748
24749    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
24750        type Owned = Self;
24751
24752        #[inline(always)]
24753        fn inline_align(_context: fidl::encoding::Context) -> usize {
24754            8
24755        }
24756
24757        #[inline(always)]
24758        fn inline_size(_context: fidl::encoding::Context) -> usize {
24759            16
24760        }
24761    }
24762
24763    unsafe impl
24764        fidl::encoding::Encode<
24765            StreamBufferPartialSettings,
24766            fidl::encoding::DefaultFuchsiaResourceDialect,
24767        > for &mut StreamBufferPartialSettings
24768    {
24769        unsafe fn encode(
24770            self,
24771            encoder: &mut fidl::encoding::Encoder<
24772                '_,
24773                fidl::encoding::DefaultFuchsiaResourceDialect,
24774            >,
24775            offset: usize,
24776            mut depth: fidl::encoding::Depth,
24777        ) -> fidl::Result<()> {
24778            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
24779            // Vector header
24780            let max_ordinal: u64 = self.max_ordinal_present();
24781            encoder.write_num(max_ordinal, offset);
24782            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24783            // Calling encoder.out_of_line_offset(0) is not allowed.
24784            if max_ordinal == 0 {
24785                return Ok(());
24786            }
24787            depth.increment()?;
24788            let envelope_size = 8;
24789            let bytes_len = max_ordinal as usize * envelope_size;
24790            #[allow(unused_variables)]
24791            let offset = encoder.out_of_line_offset(bytes_len);
24792            let mut _prev_end_offset: usize = 0;
24793            if 1 > max_ordinal {
24794                return Ok(());
24795            }
24796
24797            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24798            // are envelope_size bytes.
24799            let cur_offset: usize = (1 - 1) * envelope_size;
24800
24801            // Zero reserved fields.
24802            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24803
24804            // Safety:
24805            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24806            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24807            //   envelope_size bytes, there is always sufficient room.
24808            fidl::encoding::encode_in_envelope_optional::<
24809                u64,
24810                fidl::encoding::DefaultFuchsiaResourceDialect,
24811            >(
24812                self.buffer_lifetime_ordinal
24813                    .as_ref()
24814                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24815                encoder,
24816                offset + cur_offset,
24817                depth,
24818            )?;
24819
24820            _prev_end_offset = cur_offset + envelope_size;
24821            if 2 > max_ordinal {
24822                return Ok(());
24823            }
24824
24825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24826            // are envelope_size bytes.
24827            let cur_offset: usize = (2 - 1) * envelope_size;
24828
24829            // Zero reserved fields.
24830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24831
24832            // Safety:
24833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24835            //   envelope_size bytes, there is always sufficient room.
24836            fidl::encoding::encode_in_envelope_optional::<
24837                u64,
24838                fidl::encoding::DefaultFuchsiaResourceDialect,
24839            >(
24840                self.buffer_constraints_version_ordinal
24841                    .as_ref()
24842                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24843                encoder,
24844                offset + cur_offset,
24845                depth,
24846            )?;
24847
24848            _prev_end_offset = cur_offset + envelope_size;
24849            if 3 > max_ordinal {
24850                return Ok(());
24851            }
24852
24853            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24854            // are envelope_size bytes.
24855            let cur_offset: usize = (3 - 1) * envelope_size;
24856
24857            // Zero reserved fields.
24858            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24859
24860            // Safety:
24861            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24862            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24863            //   envelope_size bytes, there is always sufficient room.
24864            fidl::encoding::encode_in_envelope_optional::<
24865                bool,
24866                fidl::encoding::DefaultFuchsiaResourceDialect,
24867            >(
24868                self.single_buffer_mode
24869                    .as_ref()
24870                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
24871                encoder,
24872                offset + cur_offset,
24873                depth,
24874            )?;
24875
24876            _prev_end_offset = cur_offset + envelope_size;
24877            if 4 > max_ordinal {
24878                return Ok(());
24879            }
24880
24881            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24882            // are envelope_size bytes.
24883            let cur_offset: usize = (4 - 1) * envelope_size;
24884
24885            // Zero reserved fields.
24886            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24887
24888            // Safety:
24889            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24890            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24891            //   envelope_size bytes, there is always sufficient room.
24892            fidl::encoding::encode_in_envelope_optional::<
24893                u32,
24894                fidl::encoding::DefaultFuchsiaResourceDialect,
24895            >(
24896                self.packet_count_for_server
24897                    .as_ref()
24898                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24899                encoder,
24900                offset + cur_offset,
24901                depth,
24902            )?;
24903
24904            _prev_end_offset = cur_offset + envelope_size;
24905            if 5 > max_ordinal {
24906                return Ok(());
24907            }
24908
24909            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24910            // are envelope_size bytes.
24911            let cur_offset: usize = (5 - 1) * envelope_size;
24912
24913            // Zero reserved fields.
24914            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24915
24916            // Safety:
24917            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24918            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24919            //   envelope_size bytes, there is always sufficient room.
24920            fidl::encoding::encode_in_envelope_optional::<
24921                u32,
24922                fidl::encoding::DefaultFuchsiaResourceDialect,
24923            >(
24924                self.packet_count_for_client
24925                    .as_ref()
24926                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24927                encoder,
24928                offset + cur_offset,
24929                depth,
24930            )?;
24931
24932            _prev_end_offset = cur_offset + envelope_size;
24933            if 6 > max_ordinal {
24934                return Ok(());
24935            }
24936
24937            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24938            // are envelope_size bytes.
24939            let cur_offset: usize = (6 - 1) * envelope_size;
24940
24941            // Zero reserved fields.
24942            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24943
24944            // Safety:
24945            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24946            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24947            //   envelope_size bytes, there is always sufficient room.
24948            fidl::encoding::encode_in_envelope_optional::<
24949                fidl::encoding::Endpoint<
24950                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
24951                >,
24952                fidl::encoding::DefaultFuchsiaResourceDialect,
24953            >(
24954                self.sysmem_token.as_mut().map(
24955                    <fidl::encoding::Endpoint<
24956                        fidl::endpoints::ClientEnd<
24957                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
24958                        >,
24959                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
24960                ),
24961                encoder,
24962                offset + cur_offset,
24963                depth,
24964            )?;
24965
24966            _prev_end_offset = cur_offset + envelope_size;
24967            if 7 > max_ordinal {
24968                return Ok(());
24969            }
24970
24971            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24972            // are envelope_size bytes.
24973            let cur_offset: usize = (7 - 1) * envelope_size;
24974
24975            // Zero reserved fields.
24976            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24977
24978            // Safety:
24979            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24980            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24981            //   envelope_size bytes, there is always sufficient room.
24982            fidl::encoding::encode_in_envelope_optional::<
24983                fidl::encoding::Endpoint<
24984                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
24985                >,
24986                fidl::encoding::DefaultFuchsiaResourceDialect,
24987            >(
24988                self.sysmem2_token.as_mut().map(
24989                    <fidl::encoding::Endpoint<
24990                        fidl::endpoints::ClientEnd<
24991                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
24992                        >,
24993                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
24994                ),
24995                encoder,
24996                offset + cur_offset,
24997                depth,
24998            )?;
24999
25000            _prev_end_offset = cur_offset + envelope_size;
25001
25002            Ok(())
25003        }
25004    }
25005
25006    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25007        for StreamBufferPartialSettings
25008    {
25009        #[inline(always)]
25010        fn new_empty() -> Self {
25011            Self::default()
25012        }
25013
25014        unsafe fn decode(
25015            &mut self,
25016            decoder: &mut fidl::encoding::Decoder<
25017                '_,
25018                fidl::encoding::DefaultFuchsiaResourceDialect,
25019            >,
25020            offset: usize,
25021            mut depth: fidl::encoding::Depth,
25022        ) -> fidl::Result<()> {
25023            decoder.debug_check_bounds::<Self>(offset);
25024            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
25025                None => return Err(fidl::Error::NotNullable),
25026                Some(len) => len,
25027            };
25028            // Calling decoder.out_of_line_offset(0) is not allowed.
25029            if len == 0 {
25030                return Ok(());
25031            };
25032            depth.increment()?;
25033            let envelope_size = 8;
25034            let bytes_len = len * envelope_size;
25035            let offset = decoder.out_of_line_offset(bytes_len)?;
25036            // Decode the envelope for each type.
25037            let mut _next_ordinal_to_read = 0;
25038            let mut next_offset = offset;
25039            let end_offset = offset + bytes_len;
25040            _next_ordinal_to_read += 1;
25041            if next_offset >= end_offset {
25042                return Ok(());
25043            }
25044
25045            // Decode unknown envelopes for gaps in ordinals.
25046            while _next_ordinal_to_read < 1 {
25047                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25048                _next_ordinal_to_read += 1;
25049                next_offset += envelope_size;
25050            }
25051
25052            let next_out_of_line = decoder.next_out_of_line();
25053            let handles_before = decoder.remaining_handles();
25054            if let Some((inlined, num_bytes, num_handles)) =
25055                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25056            {
25057                let member_inline_size =
25058                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25059                if inlined != (member_inline_size <= 4) {
25060                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25061                }
25062                let inner_offset;
25063                let mut inner_depth = depth.clone();
25064                if inlined {
25065                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25066                    inner_offset = next_offset;
25067                } else {
25068                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25069                    inner_depth.increment()?;
25070                }
25071                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
25072                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25073                });
25074                fidl::decode!(
25075                    u64,
25076                    fidl::encoding::DefaultFuchsiaResourceDialect,
25077                    val_ref,
25078                    decoder,
25079                    inner_offset,
25080                    inner_depth
25081                )?;
25082                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25083                {
25084                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25085                }
25086                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25087                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25088                }
25089            }
25090
25091            next_offset += envelope_size;
25092            _next_ordinal_to_read += 1;
25093            if next_offset >= end_offset {
25094                return Ok(());
25095            }
25096
25097            // Decode unknown envelopes for gaps in ordinals.
25098            while _next_ordinal_to_read < 2 {
25099                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25100                _next_ordinal_to_read += 1;
25101                next_offset += envelope_size;
25102            }
25103
25104            let next_out_of_line = decoder.next_out_of_line();
25105            let handles_before = decoder.remaining_handles();
25106            if let Some((inlined, num_bytes, num_handles)) =
25107                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25108            {
25109                let member_inline_size =
25110                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25111                if inlined != (member_inline_size <= 4) {
25112                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25113                }
25114                let inner_offset;
25115                let mut inner_depth = depth.clone();
25116                if inlined {
25117                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25118                    inner_offset = next_offset;
25119                } else {
25120                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25121                    inner_depth.increment()?;
25122                }
25123                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
25124                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25125                });
25126                fidl::decode!(
25127                    u64,
25128                    fidl::encoding::DefaultFuchsiaResourceDialect,
25129                    val_ref,
25130                    decoder,
25131                    inner_offset,
25132                    inner_depth
25133                )?;
25134                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25135                {
25136                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25137                }
25138                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25139                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25140                }
25141            }
25142
25143            next_offset += envelope_size;
25144            _next_ordinal_to_read += 1;
25145            if next_offset >= end_offset {
25146                return Ok(());
25147            }
25148
25149            // Decode unknown envelopes for gaps in ordinals.
25150            while _next_ordinal_to_read < 3 {
25151                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25152                _next_ordinal_to_read += 1;
25153                next_offset += envelope_size;
25154            }
25155
25156            let next_out_of_line = decoder.next_out_of_line();
25157            let handles_before = decoder.remaining_handles();
25158            if let Some((inlined, num_bytes, num_handles)) =
25159                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25160            {
25161                let member_inline_size =
25162                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25163                if inlined != (member_inline_size <= 4) {
25164                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25165                }
25166                let inner_offset;
25167                let mut inner_depth = depth.clone();
25168                if inlined {
25169                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25170                    inner_offset = next_offset;
25171                } else {
25172                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25173                    inner_depth.increment()?;
25174                }
25175                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
25176                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
25177                });
25178                fidl::decode!(
25179                    bool,
25180                    fidl::encoding::DefaultFuchsiaResourceDialect,
25181                    val_ref,
25182                    decoder,
25183                    inner_offset,
25184                    inner_depth
25185                )?;
25186                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25187                {
25188                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25189                }
25190                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25191                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25192                }
25193            }
25194
25195            next_offset += envelope_size;
25196            _next_ordinal_to_read += 1;
25197            if next_offset >= end_offset {
25198                return Ok(());
25199            }
25200
25201            // Decode unknown envelopes for gaps in ordinals.
25202            while _next_ordinal_to_read < 4 {
25203                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25204                _next_ordinal_to_read += 1;
25205                next_offset += envelope_size;
25206            }
25207
25208            let next_out_of_line = decoder.next_out_of_line();
25209            let handles_before = decoder.remaining_handles();
25210            if let Some((inlined, num_bytes, num_handles)) =
25211                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25212            {
25213                let member_inline_size =
25214                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25215                if inlined != (member_inline_size <= 4) {
25216                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25217                }
25218                let inner_offset;
25219                let mut inner_depth = depth.clone();
25220                if inlined {
25221                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25222                    inner_offset = next_offset;
25223                } else {
25224                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25225                    inner_depth.increment()?;
25226                }
25227                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
25228                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25229                });
25230                fidl::decode!(
25231                    u32,
25232                    fidl::encoding::DefaultFuchsiaResourceDialect,
25233                    val_ref,
25234                    decoder,
25235                    inner_offset,
25236                    inner_depth
25237                )?;
25238                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25239                {
25240                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25241                }
25242                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25243                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25244                }
25245            }
25246
25247            next_offset += envelope_size;
25248            _next_ordinal_to_read += 1;
25249            if next_offset >= end_offset {
25250                return Ok(());
25251            }
25252
25253            // Decode unknown envelopes for gaps in ordinals.
25254            while _next_ordinal_to_read < 5 {
25255                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25256                _next_ordinal_to_read += 1;
25257                next_offset += envelope_size;
25258            }
25259
25260            let next_out_of_line = decoder.next_out_of_line();
25261            let handles_before = decoder.remaining_handles();
25262            if let Some((inlined, num_bytes, num_handles)) =
25263                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25264            {
25265                let member_inline_size =
25266                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25267                if inlined != (member_inline_size <= 4) {
25268                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25269                }
25270                let inner_offset;
25271                let mut inner_depth = depth.clone();
25272                if inlined {
25273                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25274                    inner_offset = next_offset;
25275                } else {
25276                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25277                    inner_depth.increment()?;
25278                }
25279                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
25280                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25281                });
25282                fidl::decode!(
25283                    u32,
25284                    fidl::encoding::DefaultFuchsiaResourceDialect,
25285                    val_ref,
25286                    decoder,
25287                    inner_offset,
25288                    inner_depth
25289                )?;
25290                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25291                {
25292                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25293                }
25294                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25295                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25296                }
25297            }
25298
25299            next_offset += envelope_size;
25300            _next_ordinal_to_read += 1;
25301            if next_offset >= end_offset {
25302                return Ok(());
25303            }
25304
25305            // Decode unknown envelopes for gaps in ordinals.
25306            while _next_ordinal_to_read < 6 {
25307                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25308                _next_ordinal_to_read += 1;
25309                next_offset += envelope_size;
25310            }
25311
25312            let next_out_of_line = decoder.next_out_of_line();
25313            let handles_before = decoder.remaining_handles();
25314            if let Some((inlined, num_bytes, num_handles)) =
25315                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25316            {
25317                let member_inline_size = <fidl::encoding::Endpoint<
25318                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25319                > as fidl::encoding::TypeMarker>::inline_size(
25320                    decoder.context
25321                );
25322                if inlined != (member_inline_size <= 4) {
25323                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25324                }
25325                let inner_offset;
25326                let mut inner_depth = depth.clone();
25327                if inlined {
25328                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25329                    inner_offset = next_offset;
25330                } else {
25331                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25332                    inner_depth.increment()?;
25333                }
25334                let val_ref = self.sysmem_token.get_or_insert_with(|| {
25335                    fidl::new_empty!(
25336                        fidl::encoding::Endpoint<
25337                            fidl::endpoints::ClientEnd<
25338                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25339                            >,
25340                        >,
25341                        fidl::encoding::DefaultFuchsiaResourceDialect
25342                    )
25343                });
25344                fidl::decode!(
25345                    fidl::encoding::Endpoint<
25346                        fidl::endpoints::ClientEnd<
25347                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25348                        >,
25349                    >,
25350                    fidl::encoding::DefaultFuchsiaResourceDialect,
25351                    val_ref,
25352                    decoder,
25353                    inner_offset,
25354                    inner_depth
25355                )?;
25356                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25357                {
25358                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25359                }
25360                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25361                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25362                }
25363            }
25364
25365            next_offset += envelope_size;
25366            _next_ordinal_to_read += 1;
25367            if next_offset >= end_offset {
25368                return Ok(());
25369            }
25370
25371            // Decode unknown envelopes for gaps in ordinals.
25372            while _next_ordinal_to_read < 7 {
25373                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25374                _next_ordinal_to_read += 1;
25375                next_offset += envelope_size;
25376            }
25377
25378            let next_out_of_line = decoder.next_out_of_line();
25379            let handles_before = decoder.remaining_handles();
25380            if let Some((inlined, num_bytes, num_handles)) =
25381                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25382            {
25383                let member_inline_size = <fidl::encoding::Endpoint<
25384                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25385                > as fidl::encoding::TypeMarker>::inline_size(
25386                    decoder.context
25387                );
25388                if inlined != (member_inline_size <= 4) {
25389                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25390                }
25391                let inner_offset;
25392                let mut inner_depth = depth.clone();
25393                if inlined {
25394                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25395                    inner_offset = next_offset;
25396                } else {
25397                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25398                    inner_depth.increment()?;
25399                }
25400                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
25401                    fidl::new_empty!(
25402                        fidl::encoding::Endpoint<
25403                            fidl::endpoints::ClientEnd<
25404                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25405                            >,
25406                        >,
25407                        fidl::encoding::DefaultFuchsiaResourceDialect
25408                    )
25409                });
25410                fidl::decode!(
25411                    fidl::encoding::Endpoint<
25412                        fidl::endpoints::ClientEnd<
25413                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25414                        >,
25415                    >,
25416                    fidl::encoding::DefaultFuchsiaResourceDialect,
25417                    val_ref,
25418                    decoder,
25419                    inner_offset,
25420                    inner_depth
25421                )?;
25422                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25423                {
25424                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25425                }
25426                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25427                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25428                }
25429            }
25430
25431            next_offset += envelope_size;
25432
25433            // Decode the remaining unknown envelopes.
25434            while next_offset < end_offset {
25435                _next_ordinal_to_read += 1;
25436                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25437                next_offset += envelope_size;
25438            }
25439
25440            Ok(())
25441        }
25442    }
25443}