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::NullableHandle {
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
1079    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1080        self.inner.shutdown_with_epitaph(status)
1081    }
1082
1083    fn is_closed(&self) -> bool {
1084        self.inner.channel().is_closed()
1085    }
1086    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1087        self.inner.channel().on_closed()
1088    }
1089
1090    #[cfg(target_os = "fuchsia")]
1091    fn signal_peer(
1092        &self,
1093        clear_mask: zx::Signals,
1094        set_mask: zx::Signals,
1095    ) -> Result<(), zx_status::Status> {
1096        use fidl::Peered;
1097        self.inner.channel().signal_peer(clear_mask, set_mask)
1098    }
1099}
1100
1101impl ActivityReporterControlHandle {}
1102
1103#[must_use = "FIDL methods require a response to be sent"]
1104#[derive(Debug)]
1105pub struct ActivityReporterWatchRenderActivityResponder {
1106    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1107    tx_id: u32,
1108}
1109
1110/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1111/// if the responder is dropped without sending a response, so that the client
1112/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1113impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1114    fn drop(&mut self) {
1115        self.control_handle.shutdown();
1116        // Safety: drops once, never accessed again
1117        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1118    }
1119}
1120
1121impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivityResponder {
1122    type ControlHandle = ActivityReporterControlHandle;
1123
1124    fn control_handle(&self) -> &ActivityReporterControlHandle {
1125        &self.control_handle
1126    }
1127
1128    fn drop_without_shutdown(mut self) {
1129        // Safety: drops once, never accessed again due to mem::forget
1130        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1131        // Prevent Drop from running (which would shut down the channel)
1132        std::mem::forget(self);
1133    }
1134}
1135
1136impl ActivityReporterWatchRenderActivityResponder {
1137    /// Sends a response to the FIDL transaction.
1138    ///
1139    /// Sets the channel to shutdown if an error occurs.
1140    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1141        let _result = self.send_raw(active_usages);
1142        if _result.is_err() {
1143            self.control_handle.shutdown();
1144        }
1145        self.drop_without_shutdown();
1146        _result
1147    }
1148
1149    /// Similar to "send" but does not shutdown the channel if an error occurs.
1150    pub fn send_no_shutdown_on_err(
1151        self,
1152        mut active_usages: &[AudioRenderUsage],
1153    ) -> Result<(), fidl::Error> {
1154        let _result = self.send_raw(active_usages);
1155        self.drop_without_shutdown();
1156        _result
1157    }
1158
1159    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1160        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1161            (active_usages,),
1162            self.tx_id,
1163            0x2974e9f5880b2f1f,
1164            fidl::encoding::DynamicFlags::empty(),
1165        )
1166    }
1167}
1168
1169#[must_use = "FIDL methods require a response to be sent"]
1170#[derive(Debug)]
1171pub struct ActivityReporterWatchRenderActivity2Responder {
1172    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1173    tx_id: u32,
1174}
1175
1176/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1177/// if the responder is dropped without sending a response, so that the client
1178/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1179impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1180    fn drop(&mut self) {
1181        self.control_handle.shutdown();
1182        // Safety: drops once, never accessed again
1183        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1184    }
1185}
1186
1187impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivity2Responder {
1188    type ControlHandle = ActivityReporterControlHandle;
1189
1190    fn control_handle(&self) -> &ActivityReporterControlHandle {
1191        &self.control_handle
1192    }
1193
1194    fn drop_without_shutdown(mut self) {
1195        // Safety: drops once, never accessed again due to mem::forget
1196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1197        // Prevent Drop from running (which would shut down the channel)
1198        std::mem::forget(self);
1199    }
1200}
1201
1202impl ActivityReporterWatchRenderActivity2Responder {
1203    /// Sends a response to the FIDL transaction.
1204    ///
1205    /// Sets the channel to shutdown if an error occurs.
1206    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1207        let _result = self.send_raw(active_usages);
1208        if _result.is_err() {
1209            self.control_handle.shutdown();
1210        }
1211        self.drop_without_shutdown();
1212        _result
1213    }
1214
1215    /// Similar to "send" but does not shutdown the channel if an error occurs.
1216    pub fn send_no_shutdown_on_err(
1217        self,
1218        mut active_usages: &[AudioRenderUsage2],
1219    ) -> Result<(), fidl::Error> {
1220        let _result = self.send_raw(active_usages);
1221        self.drop_without_shutdown();
1222        _result
1223    }
1224
1225    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1226        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1227            ActivityReporterWatchRenderActivity2Response,
1228        >>(
1229            fidl::encoding::Flexible::new((active_usages,)),
1230            self.tx_id,
1231            0x484236fc11b363e6,
1232            fidl::encoding::DynamicFlags::FLEXIBLE,
1233        )
1234    }
1235}
1236
1237#[must_use = "FIDL methods require a response to be sent"]
1238#[derive(Debug)]
1239pub struct ActivityReporterWatchCaptureActivityResponder {
1240    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1241    tx_id: u32,
1242}
1243
1244/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1245/// if the responder is dropped without sending a response, so that the client
1246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1247impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1248    fn drop(&mut self) {
1249        self.control_handle.shutdown();
1250        // Safety: drops once, never accessed again
1251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1252    }
1253}
1254
1255impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivityResponder {
1256    type ControlHandle = ActivityReporterControlHandle;
1257
1258    fn control_handle(&self) -> &ActivityReporterControlHandle {
1259        &self.control_handle
1260    }
1261
1262    fn drop_without_shutdown(mut self) {
1263        // Safety: drops once, never accessed again due to mem::forget
1264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1265        // Prevent Drop from running (which would shut down the channel)
1266        std::mem::forget(self);
1267    }
1268}
1269
1270impl ActivityReporterWatchCaptureActivityResponder {
1271    /// Sends a response to the FIDL transaction.
1272    ///
1273    /// Sets the channel to shutdown if an error occurs.
1274    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1275        let _result = self.send_raw(active_usages);
1276        if _result.is_err() {
1277            self.control_handle.shutdown();
1278        }
1279        self.drop_without_shutdown();
1280        _result
1281    }
1282
1283    /// Similar to "send" but does not shutdown the channel if an error occurs.
1284    pub fn send_no_shutdown_on_err(
1285        self,
1286        mut active_usages: &[AudioCaptureUsage],
1287    ) -> Result<(), fidl::Error> {
1288        let _result = self.send_raw(active_usages);
1289        self.drop_without_shutdown();
1290        _result
1291    }
1292
1293    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1294        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1295            (active_usages,),
1296            self.tx_id,
1297            0x70e7038e9658e128,
1298            fidl::encoding::DynamicFlags::empty(),
1299        )
1300    }
1301}
1302
1303#[must_use = "FIDL methods require a response to be sent"]
1304#[derive(Debug)]
1305pub struct ActivityReporterWatchCaptureActivity2Responder {
1306    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1307    tx_id: u32,
1308}
1309
1310/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1311/// if the responder is dropped without sending a response, so that the client
1312/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1313impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1314    fn drop(&mut self) {
1315        self.control_handle.shutdown();
1316        // Safety: drops once, never accessed again
1317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1318    }
1319}
1320
1321impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivity2Responder {
1322    type ControlHandle = ActivityReporterControlHandle;
1323
1324    fn control_handle(&self) -> &ActivityReporterControlHandle {
1325        &self.control_handle
1326    }
1327
1328    fn drop_without_shutdown(mut self) {
1329        // Safety: drops once, never accessed again due to mem::forget
1330        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1331        // Prevent Drop from running (which would shut down the channel)
1332        std::mem::forget(self);
1333    }
1334}
1335
1336impl ActivityReporterWatchCaptureActivity2Responder {
1337    /// Sends a response to the FIDL transaction.
1338    ///
1339    /// Sets the channel to shutdown if an error occurs.
1340    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1341        let _result = self.send_raw(active_usages);
1342        if _result.is_err() {
1343            self.control_handle.shutdown();
1344        }
1345        self.drop_without_shutdown();
1346        _result
1347    }
1348
1349    /// Similar to "send" but does not shutdown the channel if an error occurs.
1350    pub fn send_no_shutdown_on_err(
1351        self,
1352        mut active_usages: &[AudioCaptureUsage2],
1353    ) -> Result<(), fidl::Error> {
1354        let _result = self.send_raw(active_usages);
1355        self.drop_without_shutdown();
1356        _result
1357    }
1358
1359    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1360        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1361            ActivityReporterWatchCaptureActivity2Response,
1362        >>(
1363            fidl::encoding::Flexible::new((active_usages,)),
1364            self.tx_id,
1365            0x3d137e0364f9d550,
1366            fidl::encoding::DynamicFlags::FLEXIBLE,
1367        )
1368    }
1369}
1370
1371#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1372pub struct AudioMarker;
1373
1374impl fidl::endpoints::ProtocolMarker for AudioMarker {
1375    type Proxy = AudioProxy;
1376    type RequestStream = AudioRequestStream;
1377    #[cfg(target_os = "fuchsia")]
1378    type SynchronousProxy = AudioSynchronousProxy;
1379
1380    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1381}
1382impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
1383
1384pub trait AudioProxyInterface: Send + Sync {
1385    fn r#create_audio_renderer(
1386        &self,
1387        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1388    ) -> Result<(), fidl::Error>;
1389    fn r#create_audio_capturer(
1390        &self,
1391        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1392        loopback: bool,
1393    ) -> Result<(), fidl::Error>;
1394}
1395#[derive(Debug)]
1396#[cfg(target_os = "fuchsia")]
1397pub struct AudioSynchronousProxy {
1398    client: fidl::client::sync::Client,
1399}
1400
1401#[cfg(target_os = "fuchsia")]
1402impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
1403    type Proxy = AudioProxy;
1404    type Protocol = AudioMarker;
1405
1406    fn from_channel(inner: fidl::Channel) -> Self {
1407        Self::new(inner)
1408    }
1409
1410    fn into_channel(self) -> fidl::Channel {
1411        self.client.into_channel()
1412    }
1413
1414    fn as_channel(&self) -> &fidl::Channel {
1415        self.client.as_channel()
1416    }
1417}
1418
1419#[cfg(target_os = "fuchsia")]
1420impl AudioSynchronousProxy {
1421    pub fn new(channel: fidl::Channel) -> Self {
1422        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1423        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1424    }
1425
1426    pub fn into_channel(self) -> fidl::Channel {
1427        self.client.into_channel()
1428    }
1429
1430    /// Waits until an event arrives and returns it. It is safe for other
1431    /// threads to make concurrent requests while waiting for an event.
1432    pub fn wait_for_event(
1433        &self,
1434        deadline: zx::MonotonicInstant,
1435    ) -> Result<AudioEvent, fidl::Error> {
1436        AudioEvent::decode(self.client.wait_for_event(deadline)?)
1437    }
1438
1439    pub fn r#create_audio_renderer(
1440        &self,
1441        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1442    ) -> Result<(), fidl::Error> {
1443        self.client.send::<AudioCreateAudioRendererRequest>(
1444            (audio_renderer_request,),
1445            0x572f413566fd58f1,
1446            fidl::encoding::DynamicFlags::empty(),
1447        )
1448    }
1449
1450    /// Creates an AudioCapturer which either captures from the current default
1451    /// audio input device, or loops-back from the current default audio output
1452    /// device based on value passed for the loopback flag.
1453    pub fn r#create_audio_capturer(
1454        &self,
1455        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1456        mut loopback: bool,
1457    ) -> Result<(), fidl::Error> {
1458        self.client.send::<AudioCreateAudioCapturerRequest>(
1459            (audio_capturer_request, loopback),
1460            0x44660fc63a6202f,
1461            fidl::encoding::DynamicFlags::empty(),
1462        )
1463    }
1464}
1465
1466#[cfg(target_os = "fuchsia")]
1467impl From<AudioSynchronousProxy> for zx::NullableHandle {
1468    fn from(value: AudioSynchronousProxy) -> Self {
1469        value.into_channel().into()
1470    }
1471}
1472
1473#[cfg(target_os = "fuchsia")]
1474impl From<fidl::Channel> for AudioSynchronousProxy {
1475    fn from(value: fidl::Channel) -> Self {
1476        Self::new(value)
1477    }
1478}
1479
1480#[cfg(target_os = "fuchsia")]
1481impl fidl::endpoints::FromClient for AudioSynchronousProxy {
1482    type Protocol = AudioMarker;
1483
1484    fn from_client(value: fidl::endpoints::ClientEnd<AudioMarker>) -> Self {
1485        Self::new(value.into_channel())
1486    }
1487}
1488
1489#[derive(Debug, Clone)]
1490pub struct AudioProxy {
1491    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1492}
1493
1494impl fidl::endpoints::Proxy for AudioProxy {
1495    type Protocol = AudioMarker;
1496
1497    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1498        Self::new(inner)
1499    }
1500
1501    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1502        self.client.into_channel().map_err(|client| Self { client })
1503    }
1504
1505    fn as_channel(&self) -> &::fidl::AsyncChannel {
1506        self.client.as_channel()
1507    }
1508}
1509
1510impl AudioProxy {
1511    /// Create a new Proxy for fuchsia.media/Audio.
1512    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1513        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1514        Self { client: fidl::client::Client::new(channel, protocol_name) }
1515    }
1516
1517    /// Get a Stream of events from the remote end of the protocol.
1518    ///
1519    /// # Panics
1520    ///
1521    /// Panics if the event stream was already taken.
1522    pub fn take_event_stream(&self) -> AudioEventStream {
1523        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1524    }
1525
1526    pub fn r#create_audio_renderer(
1527        &self,
1528        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1529    ) -> Result<(), fidl::Error> {
1530        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1531    }
1532
1533    /// Creates an AudioCapturer which either captures from the current default
1534    /// audio input device, or loops-back from the current default audio output
1535    /// device based on value passed for the loopback flag.
1536    pub fn r#create_audio_capturer(
1537        &self,
1538        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1539        mut loopback: bool,
1540    ) -> Result<(), fidl::Error> {
1541        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1542    }
1543}
1544
1545impl AudioProxyInterface for AudioProxy {
1546    fn r#create_audio_renderer(
1547        &self,
1548        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1549    ) -> Result<(), fidl::Error> {
1550        self.client.send::<AudioCreateAudioRendererRequest>(
1551            (audio_renderer_request,),
1552            0x572f413566fd58f1,
1553            fidl::encoding::DynamicFlags::empty(),
1554        )
1555    }
1556
1557    fn r#create_audio_capturer(
1558        &self,
1559        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1560        mut loopback: bool,
1561    ) -> Result<(), fidl::Error> {
1562        self.client.send::<AudioCreateAudioCapturerRequest>(
1563            (audio_capturer_request, loopback),
1564            0x44660fc63a6202f,
1565            fidl::encoding::DynamicFlags::empty(),
1566        )
1567    }
1568}
1569
1570pub struct AudioEventStream {
1571    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1572}
1573
1574impl std::marker::Unpin for AudioEventStream {}
1575
1576impl futures::stream::FusedStream for AudioEventStream {
1577    fn is_terminated(&self) -> bool {
1578        self.event_receiver.is_terminated()
1579    }
1580}
1581
1582impl futures::Stream for AudioEventStream {
1583    type Item = Result<AudioEvent, fidl::Error>;
1584
1585    fn poll_next(
1586        mut self: std::pin::Pin<&mut Self>,
1587        cx: &mut std::task::Context<'_>,
1588    ) -> std::task::Poll<Option<Self::Item>> {
1589        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1590            &mut self.event_receiver,
1591            cx
1592        )?) {
1593            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1594            None => std::task::Poll::Ready(None),
1595        }
1596    }
1597}
1598
1599#[derive(Debug)]
1600pub enum AudioEvent {}
1601
1602impl AudioEvent {
1603    /// Decodes a message buffer as a [`AudioEvent`].
1604    fn decode(
1605        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1606    ) -> Result<AudioEvent, fidl::Error> {
1607        let (bytes, _handles) = buf.split_mut();
1608        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1609        debug_assert_eq!(tx_header.tx_id, 0);
1610        match tx_header.ordinal {
1611            _ => Err(fidl::Error::UnknownOrdinal {
1612                ordinal: tx_header.ordinal,
1613                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1614            }),
1615        }
1616    }
1617}
1618
1619/// A Stream of incoming requests for fuchsia.media/Audio.
1620pub struct AudioRequestStream {
1621    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1622    is_terminated: bool,
1623}
1624
1625impl std::marker::Unpin for AudioRequestStream {}
1626
1627impl futures::stream::FusedStream for AudioRequestStream {
1628    fn is_terminated(&self) -> bool {
1629        self.is_terminated
1630    }
1631}
1632
1633impl fidl::endpoints::RequestStream for AudioRequestStream {
1634    type Protocol = AudioMarker;
1635    type ControlHandle = AudioControlHandle;
1636
1637    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1638        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1639    }
1640
1641    fn control_handle(&self) -> Self::ControlHandle {
1642        AudioControlHandle { inner: self.inner.clone() }
1643    }
1644
1645    fn into_inner(
1646        self,
1647    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1648    {
1649        (self.inner, self.is_terminated)
1650    }
1651
1652    fn from_inner(
1653        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1654        is_terminated: bool,
1655    ) -> Self {
1656        Self { inner, is_terminated }
1657    }
1658}
1659
1660impl futures::Stream for AudioRequestStream {
1661    type Item = Result<AudioRequest, fidl::Error>;
1662
1663    fn poll_next(
1664        mut self: std::pin::Pin<&mut Self>,
1665        cx: &mut std::task::Context<'_>,
1666    ) -> std::task::Poll<Option<Self::Item>> {
1667        let this = &mut *self;
1668        if this.inner.check_shutdown(cx) {
1669            this.is_terminated = true;
1670            return std::task::Poll::Ready(None);
1671        }
1672        if this.is_terminated {
1673            panic!("polled AudioRequestStream after completion");
1674        }
1675        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1676            |bytes, handles| {
1677                match this.inner.channel().read_etc(cx, bytes, handles) {
1678                    std::task::Poll::Ready(Ok(())) => {}
1679                    std::task::Poll::Pending => return std::task::Poll::Pending,
1680                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1681                        this.is_terminated = true;
1682                        return std::task::Poll::Ready(None);
1683                    }
1684                    std::task::Poll::Ready(Err(e)) => {
1685                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1686                            e.into(),
1687                        ))));
1688                    }
1689                }
1690
1691                // A message has been received from the channel
1692                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1693
1694                std::task::Poll::Ready(Some(match header.ordinal {
1695                    0x572f413566fd58f1 => {
1696                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1697                        let mut req = fidl::new_empty!(
1698                            AudioCreateAudioRendererRequest,
1699                            fidl::encoding::DefaultFuchsiaResourceDialect
1700                        );
1701                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1702                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1703                        Ok(AudioRequest::CreateAudioRenderer {
1704                            audio_renderer_request: req.audio_renderer_request,
1705
1706                            control_handle,
1707                        })
1708                    }
1709                    0x44660fc63a6202f => {
1710                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1711                        let mut req = fidl::new_empty!(
1712                            AudioCreateAudioCapturerRequest,
1713                            fidl::encoding::DefaultFuchsiaResourceDialect
1714                        );
1715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1716                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1717                        Ok(AudioRequest::CreateAudioCapturer {
1718                            audio_capturer_request: req.audio_capturer_request,
1719                            loopback: req.loopback,
1720
1721                            control_handle,
1722                        })
1723                    }
1724                    _ => Err(fidl::Error::UnknownOrdinal {
1725                        ordinal: header.ordinal,
1726                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1727                    }),
1728                }))
1729            },
1730        )
1731    }
1732}
1733
1734#[derive(Debug)]
1735pub enum AudioRequest {
1736    CreateAudioRenderer {
1737        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1738        control_handle: AudioControlHandle,
1739    },
1740    /// Creates an AudioCapturer which either captures from the current default
1741    /// audio input device, or loops-back from the current default audio output
1742    /// device based on value passed for the loopback flag.
1743    CreateAudioCapturer {
1744        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1745        loopback: bool,
1746        control_handle: AudioControlHandle,
1747    },
1748}
1749
1750impl AudioRequest {
1751    #[allow(irrefutable_let_patterns)]
1752    pub fn into_create_audio_renderer(
1753        self,
1754    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1755        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1756            Some((audio_renderer_request, control_handle))
1757        } else {
1758            None
1759        }
1760    }
1761
1762    #[allow(irrefutable_let_patterns)]
1763    pub fn into_create_audio_capturer(
1764        self,
1765    ) -> Option<(fidl::endpoints::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)> {
1766        if let AudioRequest::CreateAudioCapturer {
1767            audio_capturer_request,
1768            loopback,
1769            control_handle,
1770        } = self
1771        {
1772            Some((audio_capturer_request, loopback, control_handle))
1773        } else {
1774            None
1775        }
1776    }
1777
1778    /// Name of the method defined in FIDL
1779    pub fn method_name(&self) -> &'static str {
1780        match *self {
1781            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1782            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1783        }
1784    }
1785}
1786
1787#[derive(Debug, Clone)]
1788pub struct AudioControlHandle {
1789    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1790}
1791
1792impl fidl::endpoints::ControlHandle for AudioControlHandle {
1793    fn shutdown(&self) {
1794        self.inner.shutdown()
1795    }
1796
1797    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1798        self.inner.shutdown_with_epitaph(status)
1799    }
1800
1801    fn is_closed(&self) -> bool {
1802        self.inner.channel().is_closed()
1803    }
1804    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1805        self.inner.channel().on_closed()
1806    }
1807
1808    #[cfg(target_os = "fuchsia")]
1809    fn signal_peer(
1810        &self,
1811        clear_mask: zx::Signals,
1812        set_mask: zx::Signals,
1813    ) -> Result<(), zx_status::Status> {
1814        use fidl::Peered;
1815        self.inner.channel().signal_peer(clear_mask, set_mask)
1816    }
1817}
1818
1819impl AudioControlHandle {}
1820
1821#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1822pub struct AudioCapturerMarker;
1823
1824impl fidl::endpoints::ProtocolMarker for AudioCapturerMarker {
1825    type Proxy = AudioCapturerProxy;
1826    type RequestStream = AudioCapturerRequestStream;
1827    #[cfg(target_os = "fuchsia")]
1828    type SynchronousProxy = AudioCapturerSynchronousProxy;
1829
1830    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1831}
1832impl fidl::endpoints::DiscoverableProtocolMarker for AudioCapturerMarker {}
1833
1834pub trait AudioCapturerProxyInterface: Send + Sync {
1835    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
1836    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1837    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1838    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1839    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1840    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1841    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1842    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1843        + Send;
1844    fn r#capture_at(
1845        &self,
1846        payload_buffer_id: u32,
1847        payload_offset: u32,
1848        frames: u32,
1849    ) -> Self::CaptureAtResponseFut;
1850    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1851    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1852    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1853    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1854    fn r#bind_gain_control(
1855        &self,
1856        gain_control_request: fidl::endpoints::ServerEnd<
1857            fidl_fuchsia_media_audio::GainControlMarker,
1858        >,
1859    ) -> Result<(), fidl::Error>;
1860    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
1861        + Send;
1862    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1863    fn r#set_reference_clock(
1864        &self,
1865        reference_clock: Option<fidl::Clock>,
1866    ) -> Result<(), fidl::Error>;
1867    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1868    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1869    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1870        + Send;
1871    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1872}
1873#[derive(Debug)]
1874#[cfg(target_os = "fuchsia")]
1875pub struct AudioCapturerSynchronousProxy {
1876    client: fidl::client::sync::Client,
1877}
1878
1879#[cfg(target_os = "fuchsia")]
1880impl fidl::endpoints::SynchronousProxy for AudioCapturerSynchronousProxy {
1881    type Proxy = AudioCapturerProxy;
1882    type Protocol = AudioCapturerMarker;
1883
1884    fn from_channel(inner: fidl::Channel) -> Self {
1885        Self::new(inner)
1886    }
1887
1888    fn into_channel(self) -> fidl::Channel {
1889        self.client.into_channel()
1890    }
1891
1892    fn as_channel(&self) -> &fidl::Channel {
1893        self.client.as_channel()
1894    }
1895}
1896
1897#[cfg(target_os = "fuchsia")]
1898impl AudioCapturerSynchronousProxy {
1899    pub fn new(channel: fidl::Channel) -> Self {
1900        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1901        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1902    }
1903
1904    pub fn into_channel(self) -> fidl::Channel {
1905        self.client.into_channel()
1906    }
1907
1908    /// Waits until an event arrives and returns it. It is safe for other
1909    /// threads to make concurrent requests while waiting for an event.
1910    pub fn wait_for_event(
1911        &self,
1912        deadline: zx::MonotonicInstant,
1913    ) -> Result<AudioCapturerEvent, fidl::Error> {
1914        AudioCapturerEvent::decode(self.client.wait_for_event(deadline)?)
1915    }
1916
1917    /// Adds a payload buffer to the current buffer set associated with the
1918    /// connection. A `StreamPacket` struct reference a payload buffer in the
1919    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1920    ///
1921    /// A buffer with ID `id` must not be in the current set when this method is
1922    /// invoked, otherwise the service will close the connection.
1923    pub fn r#add_payload_buffer(
1924        &self,
1925        mut id: u32,
1926        mut payload_buffer: fidl::Vmo,
1927    ) -> Result<(), fidl::Error> {
1928        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
1929            (id, payload_buffer),
1930            0x3b3a37fc34fe5b56,
1931            fidl::encoding::DynamicFlags::empty(),
1932        )
1933    }
1934
1935    /// Removes a payload buffer from the current buffer set associated with the
1936    /// connection.
1937    ///
1938    /// A buffer with ID `id` must exist in the current set when this method is
1939    /// invoked, otherwise the service will will close the connection.
1940    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1941        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
1942            (id,),
1943            0x5d1e4f74c3658262,
1944            fidl::encoding::DynamicFlags::empty(),
1945        )
1946    }
1947
1948    /// Releases payload memory associated with a packet previously delivered
1949    /// via `OnPacketProduced`.
1950    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1951        self.client.send::<StreamSourceReleasePacketRequest>(
1952            (packet,),
1953            0x7a7b57f0f7d9e4bb,
1954            fidl::encoding::DynamicFlags::empty(),
1955        )
1956    }
1957
1958    pub fn r#discard_all_packets(
1959        &self,
1960        ___deadline: zx::MonotonicInstant,
1961    ) -> Result<(), fidl::Error> {
1962        let _response =
1963            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1964                (),
1965                0x27afd605e97b09d2,
1966                fidl::encoding::DynamicFlags::empty(),
1967                ___deadline,
1968            )?;
1969        Ok(_response)
1970    }
1971
1972    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1973        self.client.send::<fidl::encoding::EmptyPayload>(
1974            (),
1975            0x35f9d721e905b831,
1976            fidl::encoding::DynamicFlags::empty(),
1977        )
1978    }
1979
1980    /// Sets the stream type of the stream to be delivered. Causes the source
1981    /// material to be reformatted/resampled if needed in order to produce the
1982    /// requested stream type. Must be called before the payload buffer is
1983    /// established.
1984    pub fn r#set_pcm_stream_type(
1985        &self,
1986        mut stream_type: &AudioStreamType,
1987    ) -> Result<(), fidl::Error> {
1988        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
1989            (stream_type,),
1990            0x1531ea9ea2c852cd,
1991            fidl::encoding::DynamicFlags::empty(),
1992        )
1993    }
1994
1995    /// Explicitly specifies a region of the shared payload buffer for the audio
1996    /// input to capture into.
1997    pub fn r#capture_at(
1998        &self,
1999        mut payload_buffer_id: u32,
2000        mut payload_offset: u32,
2001        mut frames: u32,
2002        ___deadline: zx::MonotonicInstant,
2003    ) -> Result<StreamPacket, fidl::Error> {
2004        let _response = self
2005            .client
2006            .send_query::<AudioCapturerCaptureAtRequest, AudioCapturerCaptureAtResponse>(
2007                (payload_buffer_id, payload_offset, frames),
2008                0x784e25df72cea780,
2009                fidl::encoding::DynamicFlags::empty(),
2010                ___deadline,
2011            )?;
2012        Ok(_response.captured_packet)
2013    }
2014
2015    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2016    /// packets of exactly 'frames_per_packet' number of frames each. The
2017    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2018    /// of produced packets.
2019    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2020        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2021            (frames_per_packet,),
2022            0x7768adbb1ccfd7a6,
2023            fidl::encoding::DynamicFlags::empty(),
2024        )
2025    }
2026
2027    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2028    /// that may be used by the client if explicit synchronization is needed.
2029    pub fn r#stop_async_capture(
2030        &self,
2031        ___deadline: zx::MonotonicInstant,
2032    ) -> Result<(), fidl::Error> {
2033        let _response =
2034            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
2035                (),
2036                0x5bfc8790a8cef8cb,
2037                fidl::encoding::DynamicFlags::empty(),
2038                ___deadline,
2039            )?;
2040        Ok(_response)
2041    }
2042
2043    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2044        self.client.send::<fidl::encoding::EmptyPayload>(
2045            (),
2046            0x33223cb2962c95e3,
2047            fidl::encoding::DynamicFlags::empty(),
2048        )
2049    }
2050
2051    /// Binds to the gain control for this AudioCapturer.
2052    pub fn r#bind_gain_control(
2053        &self,
2054        mut gain_control_request: fidl::endpoints::ServerEnd<
2055            fidl_fuchsia_media_audio::GainControlMarker,
2056        >,
2057    ) -> Result<(), fidl::Error> {
2058        self.client.send::<AudioCapturerBindGainControlRequest>(
2059            (gain_control_request,),
2060            0x658a6a17ddb3a8e0,
2061            fidl::encoding::DynamicFlags::empty(),
2062        )
2063    }
2064
2065    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2066    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2067    pub fn r#get_reference_clock(
2068        &self,
2069        ___deadline: zx::MonotonicInstant,
2070    ) -> Result<fidl::Clock, fidl::Error> {
2071        let _response = self
2072            .client
2073            .send_query::<fidl::encoding::EmptyPayload, AudioCapturerGetReferenceClockResponse>(
2074                (),
2075                0x50d037aa5a4b4d71,
2076                fidl::encoding::DynamicFlags::empty(),
2077                ___deadline,
2078            )?;
2079        Ok(_response.reference_clock)
2080    }
2081
2082    /// Sets the reference clock that controls this capturer's playback rate. If the input
2083    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2084    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2085    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2086    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2087    ///
2088    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2089    /// added. It also cannot be called a second time (even before capture).
2090    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2091    /// diverge at some later time, they should create a clone of the monotonic clock, set
2092    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2093    pub fn r#set_reference_clock(
2094        &self,
2095        mut reference_clock: Option<fidl::Clock>,
2096    ) -> Result<(), fidl::Error> {
2097        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2098            (reference_clock,),
2099            0x732b2c496d521bcf,
2100            fidl::encoding::DynamicFlags::empty(),
2101        )
2102    }
2103
2104    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2105    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2106    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2107        self.client.send::<AudioCapturerSetUsageRequest>(
2108            (usage,),
2109            0x42a16f392bd21b25,
2110            fidl::encoding::DynamicFlags::empty(),
2111        )
2112    }
2113
2114    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2115    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2116    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2117        self.client.send::<AudioCapturerSetUsage2Request>(
2118            (usage,),
2119            0x7a73e251b8d2382b,
2120            fidl::encoding::DynamicFlags::FLEXIBLE,
2121        )
2122    }
2123
2124    /// Gets the currently configured stream type. Note: for an AudioCapturer
2125    /// which was just created and has not yet had its stream type explicitly
2126    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2127    /// was created -- of the source (input or looped-back output) to which the
2128    /// AudioCapturer is bound. Even if this matches the client's desired format,
2129    /// `SetPcmStreamType` must still be called.
2130    pub fn r#get_stream_type(
2131        &self,
2132        ___deadline: zx::MonotonicInstant,
2133    ) -> Result<StreamType, fidl::Error> {
2134        let _response = self
2135            .client
2136            .send_query::<fidl::encoding::EmptyPayload, AudioCapturerGetStreamTypeResponse>(
2137                (),
2138                0x5dcaaa670b433088,
2139                fidl::encoding::DynamicFlags::empty(),
2140                ___deadline,
2141            )?;
2142        Ok(_response.stream_type)
2143    }
2144}
2145
2146#[cfg(target_os = "fuchsia")]
2147impl From<AudioCapturerSynchronousProxy> for zx::NullableHandle {
2148    fn from(value: AudioCapturerSynchronousProxy) -> Self {
2149        value.into_channel().into()
2150    }
2151}
2152
2153#[cfg(target_os = "fuchsia")]
2154impl From<fidl::Channel> for AudioCapturerSynchronousProxy {
2155    fn from(value: fidl::Channel) -> Self {
2156        Self::new(value)
2157    }
2158}
2159
2160#[cfg(target_os = "fuchsia")]
2161impl fidl::endpoints::FromClient for AudioCapturerSynchronousProxy {
2162    type Protocol = AudioCapturerMarker;
2163
2164    fn from_client(value: fidl::endpoints::ClientEnd<AudioCapturerMarker>) -> Self {
2165        Self::new(value.into_channel())
2166    }
2167}
2168
2169#[derive(Debug, Clone)]
2170pub struct AudioCapturerProxy {
2171    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2172}
2173
2174impl fidl::endpoints::Proxy for AudioCapturerProxy {
2175    type Protocol = AudioCapturerMarker;
2176
2177    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2178        Self::new(inner)
2179    }
2180
2181    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2182        self.client.into_channel().map_err(|client| Self { client })
2183    }
2184
2185    fn as_channel(&self) -> &::fidl::AsyncChannel {
2186        self.client.as_channel()
2187    }
2188}
2189
2190impl AudioCapturerProxy {
2191    /// Create a new Proxy for fuchsia.media/AudioCapturer.
2192    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2193        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2194        Self { client: fidl::client::Client::new(channel, protocol_name) }
2195    }
2196
2197    /// Get a Stream of events from the remote end of the protocol.
2198    ///
2199    /// # Panics
2200    ///
2201    /// Panics if the event stream was already taken.
2202    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
2203        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
2204    }
2205
2206    /// Adds a payload buffer to the current buffer set associated with the
2207    /// connection. A `StreamPacket` struct reference a payload buffer in the
2208    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2209    ///
2210    /// A buffer with ID `id` must not be in the current set when this method is
2211    /// invoked, otherwise the service will close the connection.
2212    pub fn r#add_payload_buffer(
2213        &self,
2214        mut id: u32,
2215        mut payload_buffer: fidl::Vmo,
2216    ) -> Result<(), fidl::Error> {
2217        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
2218    }
2219
2220    /// Removes a payload buffer from the current buffer set associated with the
2221    /// connection.
2222    ///
2223    /// A buffer with ID `id` must exist in the current set when this method is
2224    /// invoked, otherwise the service will will close the connection.
2225    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2226        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
2227    }
2228
2229    /// Releases payload memory associated with a packet previously delivered
2230    /// via `OnPacketProduced`.
2231    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2232        AudioCapturerProxyInterface::r#release_packet(self, packet)
2233    }
2234
2235    pub fn r#discard_all_packets(
2236        &self,
2237    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2238        AudioCapturerProxyInterface::r#discard_all_packets(self)
2239    }
2240
2241    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2242        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
2243    }
2244
2245    /// Sets the stream type of the stream to be delivered. Causes the source
2246    /// material to be reformatted/resampled if needed in order to produce the
2247    /// requested stream type. Must be called before the payload buffer is
2248    /// established.
2249    pub fn r#set_pcm_stream_type(
2250        &self,
2251        mut stream_type: &AudioStreamType,
2252    ) -> Result<(), fidl::Error> {
2253        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
2254    }
2255
2256    /// Explicitly specifies a region of the shared payload buffer for the audio
2257    /// input to capture into.
2258    pub fn r#capture_at(
2259        &self,
2260        mut payload_buffer_id: u32,
2261        mut payload_offset: u32,
2262        mut frames: u32,
2263    ) -> fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>
2264    {
2265        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
2266    }
2267
2268    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2269    /// packets of exactly 'frames_per_packet' number of frames each. The
2270    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2271    /// of produced packets.
2272    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2273        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2274    }
2275
2276    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2277    /// that may be used by the client if explicit synchronization is needed.
2278    pub fn r#stop_async_capture(
2279        &self,
2280    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2281        AudioCapturerProxyInterface::r#stop_async_capture(self)
2282    }
2283
2284    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2285        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2286    }
2287
2288    /// Binds to the gain control for this AudioCapturer.
2289    pub fn r#bind_gain_control(
2290        &self,
2291        mut gain_control_request: fidl::endpoints::ServerEnd<
2292            fidl_fuchsia_media_audio::GainControlMarker,
2293        >,
2294    ) -> Result<(), fidl::Error> {
2295        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2296    }
2297
2298    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2299    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2300    pub fn r#get_reference_clock(
2301        &self,
2302    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
2303    {
2304        AudioCapturerProxyInterface::r#get_reference_clock(self)
2305    }
2306
2307    /// Sets the reference clock that controls this capturer's playback rate. If the input
2308    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2309    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2310    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2311    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2312    ///
2313    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2314    /// added. It also cannot be called a second time (even before capture).
2315    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2316    /// diverge at some later time, they should create a clone of the monotonic clock, set
2317    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2318    pub fn r#set_reference_clock(
2319        &self,
2320        mut reference_clock: Option<fidl::Clock>,
2321    ) -> Result<(), fidl::Error> {
2322        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2323    }
2324
2325    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2326    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2327    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2328        AudioCapturerProxyInterface::r#set_usage(self, usage)
2329    }
2330
2331    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2332    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2333    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2334        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2335    }
2336
2337    /// Gets the currently configured stream type. Note: for an AudioCapturer
2338    /// which was just created and has not yet had its stream type explicitly
2339    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2340    /// was created -- of the source (input or looped-back output) to which the
2341    /// AudioCapturer is bound. Even if this matches the client's desired format,
2342    /// `SetPcmStreamType` must still be called.
2343    pub fn r#get_stream_type(
2344        &self,
2345    ) -> fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>
2346    {
2347        AudioCapturerProxyInterface::r#get_stream_type(self)
2348    }
2349}
2350
2351impl AudioCapturerProxyInterface for AudioCapturerProxy {
2352    fn r#add_payload_buffer(
2353        &self,
2354        mut id: u32,
2355        mut payload_buffer: fidl::Vmo,
2356    ) -> Result<(), fidl::Error> {
2357        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2358            (id, payload_buffer),
2359            0x3b3a37fc34fe5b56,
2360            fidl::encoding::DynamicFlags::empty(),
2361        )
2362    }
2363
2364    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2365        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2366            (id,),
2367            0x5d1e4f74c3658262,
2368            fidl::encoding::DynamicFlags::empty(),
2369        )
2370    }
2371
2372    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2373        self.client.send::<StreamSourceReleasePacketRequest>(
2374            (packet,),
2375            0x7a7b57f0f7d9e4bb,
2376            fidl::encoding::DynamicFlags::empty(),
2377        )
2378    }
2379
2380    type DiscardAllPacketsResponseFut =
2381        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2382    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2383        fn _decode(
2384            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2385        ) -> Result<(), fidl::Error> {
2386            let _response = fidl::client::decode_transaction_body::<
2387                fidl::encoding::EmptyPayload,
2388                fidl::encoding::DefaultFuchsiaResourceDialect,
2389                0x27afd605e97b09d2,
2390            >(_buf?)?;
2391            Ok(_response)
2392        }
2393        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2394            (),
2395            0x27afd605e97b09d2,
2396            fidl::encoding::DynamicFlags::empty(),
2397            _decode,
2398        )
2399    }
2400
2401    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2402        self.client.send::<fidl::encoding::EmptyPayload>(
2403            (),
2404            0x35f9d721e905b831,
2405            fidl::encoding::DynamicFlags::empty(),
2406        )
2407    }
2408
2409    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2410        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2411            (stream_type,),
2412            0x1531ea9ea2c852cd,
2413            fidl::encoding::DynamicFlags::empty(),
2414        )
2415    }
2416
2417    type CaptureAtResponseFut =
2418        fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2419    fn r#capture_at(
2420        &self,
2421        mut payload_buffer_id: u32,
2422        mut payload_offset: u32,
2423        mut frames: u32,
2424    ) -> Self::CaptureAtResponseFut {
2425        fn _decode(
2426            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2427        ) -> Result<StreamPacket, fidl::Error> {
2428            let _response = fidl::client::decode_transaction_body::<
2429                AudioCapturerCaptureAtResponse,
2430                fidl::encoding::DefaultFuchsiaResourceDialect,
2431                0x784e25df72cea780,
2432            >(_buf?)?;
2433            Ok(_response.captured_packet)
2434        }
2435        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2436            (payload_buffer_id, payload_offset, frames),
2437            0x784e25df72cea780,
2438            fidl::encoding::DynamicFlags::empty(),
2439            _decode,
2440        )
2441    }
2442
2443    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2444        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2445            (frames_per_packet,),
2446            0x7768adbb1ccfd7a6,
2447            fidl::encoding::DynamicFlags::empty(),
2448        )
2449    }
2450
2451    type StopAsyncCaptureResponseFut =
2452        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2453    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2454        fn _decode(
2455            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2456        ) -> Result<(), fidl::Error> {
2457            let _response = fidl::client::decode_transaction_body::<
2458                fidl::encoding::EmptyPayload,
2459                fidl::encoding::DefaultFuchsiaResourceDialect,
2460                0x5bfc8790a8cef8cb,
2461            >(_buf?)?;
2462            Ok(_response)
2463        }
2464        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2465            (),
2466            0x5bfc8790a8cef8cb,
2467            fidl::encoding::DynamicFlags::empty(),
2468            _decode,
2469        )
2470    }
2471
2472    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2473        self.client.send::<fidl::encoding::EmptyPayload>(
2474            (),
2475            0x33223cb2962c95e3,
2476            fidl::encoding::DynamicFlags::empty(),
2477        )
2478    }
2479
2480    fn r#bind_gain_control(
2481        &self,
2482        mut gain_control_request: fidl::endpoints::ServerEnd<
2483            fidl_fuchsia_media_audio::GainControlMarker,
2484        >,
2485    ) -> Result<(), fidl::Error> {
2486        self.client.send::<AudioCapturerBindGainControlRequest>(
2487            (gain_control_request,),
2488            0x658a6a17ddb3a8e0,
2489            fidl::encoding::DynamicFlags::empty(),
2490        )
2491    }
2492
2493    type GetReferenceClockResponseFut =
2494        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
2495    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2496        fn _decode(
2497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2498        ) -> Result<fidl::Clock, fidl::Error> {
2499            let _response = fidl::client::decode_transaction_body::<
2500                AudioCapturerGetReferenceClockResponse,
2501                fidl::encoding::DefaultFuchsiaResourceDialect,
2502                0x50d037aa5a4b4d71,
2503            >(_buf?)?;
2504            Ok(_response.reference_clock)
2505        }
2506        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
2507            (),
2508            0x50d037aa5a4b4d71,
2509            fidl::encoding::DynamicFlags::empty(),
2510            _decode,
2511        )
2512    }
2513
2514    fn r#set_reference_clock(
2515        &self,
2516        mut reference_clock: Option<fidl::Clock>,
2517    ) -> Result<(), fidl::Error> {
2518        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2519            (reference_clock,),
2520            0x732b2c496d521bcf,
2521            fidl::encoding::DynamicFlags::empty(),
2522        )
2523    }
2524
2525    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2526        self.client.send::<AudioCapturerSetUsageRequest>(
2527            (usage,),
2528            0x42a16f392bd21b25,
2529            fidl::encoding::DynamicFlags::empty(),
2530        )
2531    }
2532
2533    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2534        self.client.send::<AudioCapturerSetUsage2Request>(
2535            (usage,),
2536            0x7a73e251b8d2382b,
2537            fidl::encoding::DynamicFlags::FLEXIBLE,
2538        )
2539    }
2540
2541    type GetStreamTypeResponseFut =
2542        fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>;
2543    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2544        fn _decode(
2545            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2546        ) -> Result<StreamType, fidl::Error> {
2547            let _response = fidl::client::decode_transaction_body::<
2548                AudioCapturerGetStreamTypeResponse,
2549                fidl::encoding::DefaultFuchsiaResourceDialect,
2550                0x5dcaaa670b433088,
2551            >(_buf?)?;
2552            Ok(_response.stream_type)
2553        }
2554        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2555            (),
2556            0x5dcaaa670b433088,
2557            fidl::encoding::DynamicFlags::empty(),
2558            _decode,
2559        )
2560    }
2561}
2562
2563pub struct AudioCapturerEventStream {
2564    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2565}
2566
2567impl std::marker::Unpin for AudioCapturerEventStream {}
2568
2569impl futures::stream::FusedStream for AudioCapturerEventStream {
2570    fn is_terminated(&self) -> bool {
2571        self.event_receiver.is_terminated()
2572    }
2573}
2574
2575impl futures::Stream for AudioCapturerEventStream {
2576    type Item = Result<AudioCapturerEvent, fidl::Error>;
2577
2578    fn poll_next(
2579        mut self: std::pin::Pin<&mut Self>,
2580        cx: &mut std::task::Context<'_>,
2581    ) -> std::task::Poll<Option<Self::Item>> {
2582        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2583            &mut self.event_receiver,
2584            cx
2585        )?) {
2586            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2587            None => std::task::Poll::Ready(None),
2588        }
2589    }
2590}
2591
2592#[derive(Debug)]
2593pub enum AudioCapturerEvent {
2594    OnPacketProduced {
2595        packet: StreamPacket,
2596    },
2597    OnEndOfStream {},
2598    #[non_exhaustive]
2599    _UnknownEvent {
2600        /// Ordinal of the event that was sent.
2601        ordinal: u64,
2602    },
2603}
2604
2605impl AudioCapturerEvent {
2606    #[allow(irrefutable_let_patterns)]
2607    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2608        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2609            Some((packet))
2610        } else {
2611            None
2612        }
2613    }
2614    #[allow(irrefutable_let_patterns)]
2615    pub fn into_on_end_of_stream(self) -> Option<()> {
2616        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2617    }
2618
2619    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2620    fn decode(
2621        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2622    ) -> Result<AudioCapturerEvent, fidl::Error> {
2623        let (bytes, _handles) = buf.split_mut();
2624        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2625        debug_assert_eq!(tx_header.tx_id, 0);
2626        match tx_header.ordinal {
2627            0x6bbe69746a3c8bd9 => {
2628                let mut out = fidl::new_empty!(
2629                    StreamSourceOnPacketProducedRequest,
2630                    fidl::encoding::DefaultFuchsiaResourceDialect
2631                );
2632                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2633                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2634            }
2635            0x550e69b41d03e2c2 => {
2636                let mut out = fidl::new_empty!(
2637                    fidl::encoding::EmptyPayload,
2638                    fidl::encoding::DefaultFuchsiaResourceDialect
2639                );
2640                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2641                Ok((AudioCapturerEvent::OnEndOfStream {}))
2642            }
2643            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2644                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2645            }
2646            _ => Err(fidl::Error::UnknownOrdinal {
2647                ordinal: tx_header.ordinal,
2648                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2649            }),
2650        }
2651    }
2652}
2653
2654/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2655pub struct AudioCapturerRequestStream {
2656    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2657    is_terminated: bool,
2658}
2659
2660impl std::marker::Unpin for AudioCapturerRequestStream {}
2661
2662impl futures::stream::FusedStream for AudioCapturerRequestStream {
2663    fn is_terminated(&self) -> bool {
2664        self.is_terminated
2665    }
2666}
2667
2668impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2669    type Protocol = AudioCapturerMarker;
2670    type ControlHandle = AudioCapturerControlHandle;
2671
2672    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2673        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2674    }
2675
2676    fn control_handle(&self) -> Self::ControlHandle {
2677        AudioCapturerControlHandle { inner: self.inner.clone() }
2678    }
2679
2680    fn into_inner(
2681        self,
2682    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2683    {
2684        (self.inner, self.is_terminated)
2685    }
2686
2687    fn from_inner(
2688        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2689        is_terminated: bool,
2690    ) -> Self {
2691        Self { inner, is_terminated }
2692    }
2693}
2694
2695impl futures::Stream for AudioCapturerRequestStream {
2696    type Item = Result<AudioCapturerRequest, fidl::Error>;
2697
2698    fn poll_next(
2699        mut self: std::pin::Pin<&mut Self>,
2700        cx: &mut std::task::Context<'_>,
2701    ) -> std::task::Poll<Option<Self::Item>> {
2702        let this = &mut *self;
2703        if this.inner.check_shutdown(cx) {
2704            this.is_terminated = true;
2705            return std::task::Poll::Ready(None);
2706        }
2707        if this.is_terminated {
2708            panic!("polled AudioCapturerRequestStream after completion");
2709        }
2710        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2711            |bytes, handles| {
2712                match this.inner.channel().read_etc(cx, bytes, handles) {
2713                    std::task::Poll::Ready(Ok(())) => {}
2714                    std::task::Poll::Pending => return std::task::Poll::Pending,
2715                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2716                        this.is_terminated = true;
2717                        return std::task::Poll::Ready(None);
2718                    }
2719                    std::task::Poll::Ready(Err(e)) => {
2720                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2721                            e.into(),
2722                        ))));
2723                    }
2724                }
2725
2726                // A message has been received from the channel
2727                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2728
2729                std::task::Poll::Ready(Some(match header.ordinal {
2730                    0x3b3a37fc34fe5b56 => {
2731                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2732                        let mut req = fidl::new_empty!(
2733                            StreamBufferSetAddPayloadBufferRequest,
2734                            fidl::encoding::DefaultFuchsiaResourceDialect
2735                        );
2736                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2737                        let control_handle =
2738                            AudioCapturerControlHandle { inner: this.inner.clone() };
2739                        Ok(AudioCapturerRequest::AddPayloadBuffer {
2740                            id: req.id,
2741                            payload_buffer: req.payload_buffer,
2742
2743                            control_handle,
2744                        })
2745                    }
2746                    0x5d1e4f74c3658262 => {
2747                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2748                        let mut req = fidl::new_empty!(
2749                            StreamBufferSetRemovePayloadBufferRequest,
2750                            fidl::encoding::DefaultFuchsiaResourceDialect
2751                        );
2752                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2753                        let control_handle =
2754                            AudioCapturerControlHandle { inner: this.inner.clone() };
2755                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
2756                    }
2757                    0x7a7b57f0f7d9e4bb => {
2758                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2759                        let mut req = fidl::new_empty!(
2760                            StreamSourceReleasePacketRequest,
2761                            fidl::encoding::DefaultFuchsiaResourceDialect
2762                        );
2763                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2764                        let control_handle =
2765                            AudioCapturerControlHandle { inner: this.inner.clone() };
2766                        Ok(AudioCapturerRequest::ReleasePacket {
2767                            packet: req.packet,
2768
2769                            control_handle,
2770                        })
2771                    }
2772                    0x27afd605e97b09d2 => {
2773                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2774                        let mut req = fidl::new_empty!(
2775                            fidl::encoding::EmptyPayload,
2776                            fidl::encoding::DefaultFuchsiaResourceDialect
2777                        );
2778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2779                        let control_handle =
2780                            AudioCapturerControlHandle { inner: this.inner.clone() };
2781                        Ok(AudioCapturerRequest::DiscardAllPackets {
2782                            responder: AudioCapturerDiscardAllPacketsResponder {
2783                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2784                                tx_id: header.tx_id,
2785                            },
2786                        })
2787                    }
2788                    0x35f9d721e905b831 => {
2789                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2790                        let mut req = fidl::new_empty!(
2791                            fidl::encoding::EmptyPayload,
2792                            fidl::encoding::DefaultFuchsiaResourceDialect
2793                        );
2794                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2795                        let control_handle =
2796                            AudioCapturerControlHandle { inner: this.inner.clone() };
2797                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
2798                    }
2799                    0x1531ea9ea2c852cd => {
2800                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2801                        let mut req = fidl::new_empty!(
2802                            AudioCapturerSetPcmStreamTypeRequest,
2803                            fidl::encoding::DefaultFuchsiaResourceDialect
2804                        );
2805                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2806                        let control_handle =
2807                            AudioCapturerControlHandle { inner: this.inner.clone() };
2808                        Ok(AudioCapturerRequest::SetPcmStreamType {
2809                            stream_type: req.stream_type,
2810
2811                            control_handle,
2812                        })
2813                    }
2814                    0x784e25df72cea780 => {
2815                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2816                        let mut req = fidl::new_empty!(
2817                            AudioCapturerCaptureAtRequest,
2818                            fidl::encoding::DefaultFuchsiaResourceDialect
2819                        );
2820                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2821                        let control_handle =
2822                            AudioCapturerControlHandle { inner: this.inner.clone() };
2823                        Ok(AudioCapturerRequest::CaptureAt {
2824                            payload_buffer_id: req.payload_buffer_id,
2825                            payload_offset: req.payload_offset,
2826                            frames: req.frames,
2827
2828                            responder: AudioCapturerCaptureAtResponder {
2829                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2830                                tx_id: header.tx_id,
2831                            },
2832                        })
2833                    }
2834                    0x7768adbb1ccfd7a6 => {
2835                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2836                        let mut req = fidl::new_empty!(
2837                            AudioCapturerStartAsyncCaptureRequest,
2838                            fidl::encoding::DefaultFuchsiaResourceDialect
2839                        );
2840                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2841                        let control_handle =
2842                            AudioCapturerControlHandle { inner: this.inner.clone() };
2843                        Ok(AudioCapturerRequest::StartAsyncCapture {
2844                            frames_per_packet: req.frames_per_packet,
2845
2846                            control_handle,
2847                        })
2848                    }
2849                    0x5bfc8790a8cef8cb => {
2850                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2851                        let mut req = fidl::new_empty!(
2852                            fidl::encoding::EmptyPayload,
2853                            fidl::encoding::DefaultFuchsiaResourceDialect
2854                        );
2855                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2856                        let control_handle =
2857                            AudioCapturerControlHandle { inner: this.inner.clone() };
2858                        Ok(AudioCapturerRequest::StopAsyncCapture {
2859                            responder: AudioCapturerStopAsyncCaptureResponder {
2860                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2861                                tx_id: header.tx_id,
2862                            },
2863                        })
2864                    }
2865                    0x33223cb2962c95e3 => {
2866                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2867                        let mut req = fidl::new_empty!(
2868                            fidl::encoding::EmptyPayload,
2869                            fidl::encoding::DefaultFuchsiaResourceDialect
2870                        );
2871                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2872                        let control_handle =
2873                            AudioCapturerControlHandle { inner: this.inner.clone() };
2874                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
2875                    }
2876                    0x658a6a17ddb3a8e0 => {
2877                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2878                        let mut req = fidl::new_empty!(
2879                            AudioCapturerBindGainControlRequest,
2880                            fidl::encoding::DefaultFuchsiaResourceDialect
2881                        );
2882                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2883                        let control_handle =
2884                            AudioCapturerControlHandle { inner: this.inner.clone() };
2885                        Ok(AudioCapturerRequest::BindGainControl {
2886                            gain_control_request: req.gain_control_request,
2887
2888                            control_handle,
2889                        })
2890                    }
2891                    0x50d037aa5a4b4d71 => {
2892                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2893                        let mut req = fidl::new_empty!(
2894                            fidl::encoding::EmptyPayload,
2895                            fidl::encoding::DefaultFuchsiaResourceDialect
2896                        );
2897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2898                        let control_handle =
2899                            AudioCapturerControlHandle { inner: this.inner.clone() };
2900                        Ok(AudioCapturerRequest::GetReferenceClock {
2901                            responder: AudioCapturerGetReferenceClockResponder {
2902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2903                                tx_id: header.tx_id,
2904                            },
2905                        })
2906                    }
2907                    0x732b2c496d521bcf => {
2908                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2909                        let mut req = fidl::new_empty!(
2910                            AudioCapturerSetReferenceClockRequest,
2911                            fidl::encoding::DefaultFuchsiaResourceDialect
2912                        );
2913                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2914                        let control_handle =
2915                            AudioCapturerControlHandle { inner: this.inner.clone() };
2916                        Ok(AudioCapturerRequest::SetReferenceClock {
2917                            reference_clock: req.reference_clock,
2918
2919                            control_handle,
2920                        })
2921                    }
2922                    0x42a16f392bd21b25 => {
2923                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2924                        let mut req = fidl::new_empty!(
2925                            AudioCapturerSetUsageRequest,
2926                            fidl::encoding::DefaultFuchsiaResourceDialect
2927                        );
2928                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2929                        let control_handle =
2930                            AudioCapturerControlHandle { inner: this.inner.clone() };
2931                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
2932                    }
2933                    0x7a73e251b8d2382b => {
2934                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2935                        let mut req = fidl::new_empty!(
2936                            AudioCapturerSetUsage2Request,
2937                            fidl::encoding::DefaultFuchsiaResourceDialect
2938                        );
2939                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2940                        let control_handle =
2941                            AudioCapturerControlHandle { inner: this.inner.clone() };
2942                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
2943                    }
2944                    0x5dcaaa670b433088 => {
2945                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2946                        let mut req = fidl::new_empty!(
2947                            fidl::encoding::EmptyPayload,
2948                            fidl::encoding::DefaultFuchsiaResourceDialect
2949                        );
2950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2951                        let control_handle =
2952                            AudioCapturerControlHandle { inner: this.inner.clone() };
2953                        Ok(AudioCapturerRequest::GetStreamType {
2954                            responder: AudioCapturerGetStreamTypeResponder {
2955                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2956                                tx_id: header.tx_id,
2957                            },
2958                        })
2959                    }
2960                    _ if header.tx_id == 0
2961                        && header
2962                            .dynamic_flags()
2963                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2964                    {
2965                        Ok(AudioCapturerRequest::_UnknownMethod {
2966                            ordinal: header.ordinal,
2967                            control_handle: AudioCapturerControlHandle {
2968                                inner: this.inner.clone(),
2969                            },
2970                            method_type: fidl::MethodType::OneWay,
2971                        })
2972                    }
2973                    _ if header
2974                        .dynamic_flags()
2975                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2976                    {
2977                        this.inner.send_framework_err(
2978                            fidl::encoding::FrameworkErr::UnknownMethod,
2979                            header.tx_id,
2980                            header.ordinal,
2981                            header.dynamic_flags(),
2982                            (bytes, handles),
2983                        )?;
2984                        Ok(AudioCapturerRequest::_UnknownMethod {
2985                            ordinal: header.ordinal,
2986                            control_handle: AudioCapturerControlHandle {
2987                                inner: this.inner.clone(),
2988                            },
2989                            method_type: fidl::MethodType::TwoWay,
2990                        })
2991                    }
2992                    _ => Err(fidl::Error::UnknownOrdinal {
2993                        ordinal: header.ordinal,
2994                        protocol_name:
2995                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2996                    }),
2997                }))
2998            },
2999        )
3000    }
3001}
3002
3003/// AudioCapturer
3004///
3005/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3006/// CreateAudioCapturer method, which may be used by clients to capture audio
3007/// from either the current default audio input device, or the current default
3008/// audio output device depending on the flags passed during creation.
3009///
3010/// **Format support**
3011///
3012/// See (Get|Set)StreamType below. By default, the captured stream type will be
3013/// initially determined by the currently configured stream type of the source
3014/// that the AudioCapturer was bound to at creation time. Users may either fetch
3015/// this type using GetStreamType, or they may choose to have the media
3016/// resampled or converted to a type of their choosing by calling SetStreamType.
3017/// Note: the stream type may only be set while the system is not running,
3018/// meaning that there are no pending capture regions (specified using CaptureAt)
3019/// and that the system is not currently running in 'async' capture mode.
3020///
3021/// **Buffers and memory management**
3022///
3023/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3024/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3025/// following requirements related to the management of the payload buffer.
3026///
3027/// + The payload buffer must be supplied before any capture operation may
3028///   start. Any attempt to start capture (via either CaptureAt or
3029///   StartAsyncCapture) before a payload buffer has been established is an
3030///   error.
3031/// + The payload buffer may not be changed while there are any capture
3032///   operations pending.
3033/// + The stream type may not be changed after the payload buffer has been set.
3034/// + The payload buffer must be an integral number of audio frame sizes (in
3035///   bytes)
3036/// + When running in 'async' mode (see below), the payload buffer must be at
3037///   least as large as twice the frames_per_packet size specified during
3038///   StartAsyncCapture.
3039/// + The handle to the payload buffer supplied by the user must be readable,
3040///   writable, mappable and transferable.
3041/// + Users should always treat the payload buffer as read-only.
3042///
3043/// **Synchronous vs. Asynchronous capture mode**
3044///
3045/// The AudioCapturer interface can be used in one of two mutually exclusive
3046/// modes: Synchronous and Asynchronous. A description of each mode and their
3047/// tradeoffs is given below.
3048///
3049/// **Synchronous mode**
3050///
3051/// By default, AudioCapturer instances are running in 'sync' mode. They will
3052/// only capture data when a user supplies at least one region to capture into
3053/// using the CaptureAt method. Regions supplied in this way will be filled in
3054/// the order that they are received and returned to the client as StreamPackets
3055/// via the return value of the CaptureAt method. If an AudioCapturer instance
3056/// has data to capture, but no place to put it (because there are no more
3057/// pending regions to fill), the next payload generated will indicate that their
3058/// has been an overflow by setting the Discontinuity flag on the next produced
3059/// StreamPacket. Synchronous mode may not be used in conjunction with
3060/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3061/// the system still regions supplied by CaptureAt waiting to be filled.
3062///
3063/// If a user has supplied regions to be filled by the AudioCapturer instance in
3064/// the past, but wishes to reclaim those regions, they may do so using the
3065/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3066/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3067/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3068/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3069/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3070/// overwrite any region of the payload buffer after a completed region is
3071/// returned, it may overwrite the unfilled portions of a partially filled
3072/// buffer which has been returned as a result of a DiscardAllPackets operation.
3073///
3074/// **Asynchronous mode**
3075///
3076/// While running in 'async' mode, clients do not need to explicitly supply
3077/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3078/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3079/// callback interface and the number of frames to capture per-callback. Once
3080/// running in async mode, the AudioCapturer instance will identify which
3081/// payload buffer regions to capture into, capture the specified number of
3082/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3083/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3084/// 'sync' mode using the StopAsyncCapture method.
3085///
3086/// It is considered an error to attempt any of the following operations.
3087///
3088/// + To attempt to enter 'async' capture mode when no payload buffer has been
3089///   established.
3090/// + To specify a number of frames to capture per payload which does not permit
3091///   at least two contiguous capture payloads to exist in the established
3092///   shared payload buffer simultaneously.
3093/// + To send a region to capture into using the CaptureAt method while the
3094///   AudioCapturer instance is running in 'async' mode.
3095/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3096///   running in 'async' mode.
3097/// + To attempt to re-start 'async' mode capturing without having first
3098///   stopped.
3099/// + To attempt any operation except for SetGain while in the process of
3100///   stopping.
3101///
3102/// **Synchronizing with a StopAsyncCapture operation**
3103///
3104/// Stopping asynchronous capture mode and returning to synchronous capture mode
3105/// is an operation which takes time. Aside from SetGain, users may not call any
3106/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3107/// (including calling StopAsyncCapture again) until after the stop operation has
3108/// completed. Because of this, it is important for users to be able to
3109/// synchronize with the stop operation. Two mechanisms are provided for doing
3110/// so.
3111///
3112/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3113/// callback has been called, they can be certain that stop operation is complete
3114/// and that the AudioCapturer instance has returned to synchronous operation
3115/// mode.
3116///
3117/// The second way to determine that a stop operation has completed is to use the
3118/// flags on the packets which get delivered via the user-supplied
3119/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3120/// asked to stop, any partially filled packet will be returned to the user, and
3121/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3122/// set on it to indicate that this is the final frame in the sequence. If
3123/// there is no partially filled packet to return, the AudioCapturer will
3124/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3125/// in order to deliver a packet with the end-of-stream flag set on it. Once
3126/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3127/// has finished the stop operation and returned to synchronous operating mode.
3128///
3129/// **Timing and Overflows**
3130///
3131/// All media packets produced by an AudioCapturer instance will have their PTS
3132/// field filled out with the capture time of the audio expressed as a timestamp
3133/// given by the reference clock timeline. Note: this timestamp is actually a
3134/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3135/// PTS) and is meant to represent the underlying system's best estimate of the
3136/// capture time of the first frame of audio, including all outboard and hardware
3137/// introduced buffering delay. As a result, all timestamps produced by an
3138/// AudioCapturer should be expected to be in the past relative to 'now' on the
3139/// stream's reference clock timeline.
3140///
3141/// The one exception to the "everything has an explicit timestamp" rule is when
3142/// discarding submitted regions while operating in synchronous mode. Discarded
3143/// packets have no data in them, but FIDL demands that all pending
3144/// method-return-value callbacks be executed. Because of this, the regions will
3145/// be returned to the user, but their timestamps will be set to
3146/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3147/// partially filled payload will have a valid timestamp, but a payload size
3148/// smaller than originally requested. The final discarded payload (if there
3149/// were any to discard) will be followed by an OnEndOfStream event.
3150///
3151/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3152/// the first frame of audio contained in the second packet was captured exactly
3153/// one nominal frame time after the final frame of audio in the first packet.
3154/// If this relationship does not hold, the second StreamPacket will have the
3155/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3156///
3157/// Even though explicit timestamps are provided on every StreamPacket produced,
3158/// users who have very precise timing requirements are encouraged to always
3159/// reason about time by counting frames delivered since the last discontinuity,
3160/// rather than simply using the raw capture timestamps. This is because the
3161/// explicit timestamps written on continuous packets may have a small amount of
3162/// rounding error based on whether or not the units of the capture timeline
3163/// reference clock are divisible by the chosen audio frame rate.
3164///
3165/// Users should always expect the first StreamPacket produced by an
3166/// AudioCapturer to have the discontinuous flag set on it (as there is no
3167/// previous packet to be continuous with). Similarly, the first StreamPacket
3168/// after a DiscardAllPackets or a Stop/Start cycle will always be
3169/// discontinuous. After that, there are only two reasons that a StreamPacket
3170/// will ever be discontinuous:
3171///
3172/// 1. The user is operating in synchronous mode and does not supply regions to
3173///    be filled quickly enough. If the next continuous frame of data has not
3174///    been captured by the time it needs to be purged from the source buffers,
3175///    an overflow has occurred and the AudioCapturer will flag the next captured
3176///    region as discontinuous.
3177/// 2. The user is operating in asynchronous mode and some internal error
3178///    prevents the AudioCapturer instance from capturing the next frame of audio
3179///    in a continuous fashion. This might be high system load or a hardware
3180///    error, but in general it is something which should never normally happen.
3181///    In practice, however, if it does, the next produced packet will be flagged
3182///    as being discontinuous.
3183///
3184/// **Synchronous vs. Asynchronous Trade-offs**
3185///
3186/// The choice of operating in synchronous vs. asynchronous mode is up to the
3187/// user, and depending on the user's requirements, there are some advantages and
3188/// disadvantages to each choice.
3189///
3190/// Synchronous mode requires only a single Zircon channel under the hood and can
3191/// achieve some small savings because of this. In addition, the user has
3192/// complete control over the buffer management. Users specify exactly where
3193/// audio will be captured to and in what order. Because of this, if users do
3194/// not need to always be capturing, it is simple to stop and restart the capture
3195/// later (just by ceasing to supply packets, then resuming later on). Payloads
3196/// do not need to be uniform in size either, clients may specify payloads of
3197/// whatever granularity is appropriate.
3198///
3199/// The primary downside of operating in synchronous mode is that two messages
3200/// will need to be sent for every packet to be captured. One to inform the
3201/// AudioCapturer of the instance to capture into, and one to inform the user
3202/// that the packet has been captured. This may end up increasing overhead and
3203/// potentially complicating client designs.
3204///
3205/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3206/// however, when operating in 'async' mode, AudioCapturer instances have no way
3207/// of knowing if a user is processing the StreamPackets being sent in a timely
3208/// fashion, and no way of automatically detecting an overflow condition. Users
3209/// of 'async' mode should be careful to use a buffer large enough to ensure that
3210/// they will be able to process their data before an AudioCapturer will be
3211/// forced to overwrite it.
3212#[derive(Debug)]
3213pub enum AudioCapturerRequest {
3214    /// Adds a payload buffer to the current buffer set associated with the
3215    /// connection. A `StreamPacket` struct reference a payload buffer in the
3216    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3217    ///
3218    /// A buffer with ID `id` must not be in the current set when this method is
3219    /// invoked, otherwise the service will close the connection.
3220    AddPayloadBuffer {
3221        id: u32,
3222        payload_buffer: fidl::Vmo,
3223        control_handle: AudioCapturerControlHandle,
3224    },
3225    /// Removes a payload buffer from the current buffer set associated with the
3226    /// connection.
3227    ///
3228    /// A buffer with ID `id` must exist in the current set when this method is
3229    /// invoked, otherwise the service will will close the connection.
3230    RemovePayloadBuffer {
3231        id: u32,
3232        control_handle: AudioCapturerControlHandle,
3233    },
3234    /// Releases payload memory associated with a packet previously delivered
3235    /// via `OnPacketProduced`.
3236    ReleasePacket {
3237        packet: StreamPacket,
3238        control_handle: AudioCapturerControlHandle,
3239    },
3240    DiscardAllPackets {
3241        responder: AudioCapturerDiscardAllPacketsResponder,
3242    },
3243    DiscardAllPacketsNoReply {
3244        control_handle: AudioCapturerControlHandle,
3245    },
3246    /// Sets the stream type of the stream to be delivered. Causes the source
3247    /// material to be reformatted/resampled if needed in order to produce the
3248    /// requested stream type. Must be called before the payload buffer is
3249    /// established.
3250    SetPcmStreamType {
3251        stream_type: AudioStreamType,
3252        control_handle: AudioCapturerControlHandle,
3253    },
3254    /// Explicitly specifies a region of the shared payload buffer for the audio
3255    /// input to capture into.
3256    CaptureAt {
3257        payload_buffer_id: u32,
3258        payload_offset: u32,
3259        frames: u32,
3260        responder: AudioCapturerCaptureAtResponder,
3261    },
3262    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3263    /// packets of exactly 'frames_per_packet' number of frames each. The
3264    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3265    /// of produced packets.
3266    StartAsyncCapture {
3267        frames_per_packet: u32,
3268        control_handle: AudioCapturerControlHandle,
3269    },
3270    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3271    /// that may be used by the client if explicit synchronization is needed.
3272    StopAsyncCapture {
3273        responder: AudioCapturerStopAsyncCaptureResponder,
3274    },
3275    StopAsyncCaptureNoReply {
3276        control_handle: AudioCapturerControlHandle,
3277    },
3278    /// Binds to the gain control for this AudioCapturer.
3279    BindGainControl {
3280        gain_control_request:
3281            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3282        control_handle: AudioCapturerControlHandle,
3283    },
3284    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3285    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3286    GetReferenceClock {
3287        responder: AudioCapturerGetReferenceClockResponder,
3288    },
3289    /// Sets the reference clock that controls this capturer's playback rate. If the input
3290    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3291    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3292    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3293    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3294    ///
3295    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3296    /// added. It also cannot be called a second time (even before capture).
3297    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3298    /// diverge at some later time, they should create a clone of the monotonic clock, set
3299    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3300    SetReferenceClock {
3301        reference_clock: Option<fidl::Clock>,
3302        control_handle: AudioCapturerControlHandle,
3303    },
3304    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3305    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3306    SetUsage {
3307        usage: AudioCaptureUsage,
3308        control_handle: AudioCapturerControlHandle,
3309    },
3310    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3311    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3312    SetUsage2 {
3313        usage: AudioCaptureUsage2,
3314        control_handle: AudioCapturerControlHandle,
3315    },
3316    /// Gets the currently configured stream type. Note: for an AudioCapturer
3317    /// which was just created and has not yet had its stream type explicitly
3318    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3319    /// was created -- of the source (input or looped-back output) to which the
3320    /// AudioCapturer is bound. Even if this matches the client's desired format,
3321    /// `SetPcmStreamType` must still be called.
3322    GetStreamType {
3323        responder: AudioCapturerGetStreamTypeResponder,
3324    },
3325    /// An interaction was received which does not match any known method.
3326    #[non_exhaustive]
3327    _UnknownMethod {
3328        /// Ordinal of the method that was called.
3329        ordinal: u64,
3330        control_handle: AudioCapturerControlHandle,
3331        method_type: fidl::MethodType,
3332    },
3333}
3334
3335impl AudioCapturerRequest {
3336    #[allow(irrefutable_let_patterns)]
3337    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3338        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3339        {
3340            Some((id, payload_buffer, control_handle))
3341        } else {
3342            None
3343        }
3344    }
3345
3346    #[allow(irrefutable_let_patterns)]
3347    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3348        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3349            Some((id, control_handle))
3350        } else {
3351            None
3352        }
3353    }
3354
3355    #[allow(irrefutable_let_patterns)]
3356    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3357        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3358            Some((packet, control_handle))
3359        } else {
3360            None
3361        }
3362    }
3363
3364    #[allow(irrefutable_let_patterns)]
3365    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3366        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3367            Some((responder))
3368        } else {
3369            None
3370        }
3371    }
3372
3373    #[allow(irrefutable_let_patterns)]
3374    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3375        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3376            Some((control_handle))
3377        } else {
3378            None
3379        }
3380    }
3381
3382    #[allow(irrefutable_let_patterns)]
3383    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3384        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3385            Some((stream_type, control_handle))
3386        } else {
3387            None
3388        }
3389    }
3390
3391    #[allow(irrefutable_let_patterns)]
3392    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3393        if let AudioCapturerRequest::CaptureAt {
3394            payload_buffer_id,
3395            payload_offset,
3396            frames,
3397            responder,
3398        } = self
3399        {
3400            Some((payload_buffer_id, payload_offset, frames, responder))
3401        } else {
3402            None
3403        }
3404    }
3405
3406    #[allow(irrefutable_let_patterns)]
3407    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3408        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3409        {
3410            Some((frames_per_packet, control_handle))
3411        } else {
3412            None
3413        }
3414    }
3415
3416    #[allow(irrefutable_let_patterns)]
3417    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3418        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3419            Some((responder))
3420        } else {
3421            None
3422        }
3423    }
3424
3425    #[allow(irrefutable_let_patterns)]
3426    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3427        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3428            Some((control_handle))
3429        } else {
3430            None
3431        }
3432    }
3433
3434    #[allow(irrefutable_let_patterns)]
3435    pub fn into_bind_gain_control(
3436        self,
3437    ) -> Option<(
3438        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3439        AudioCapturerControlHandle,
3440    )> {
3441        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3442        {
3443            Some((gain_control_request, control_handle))
3444        } else {
3445            None
3446        }
3447    }
3448
3449    #[allow(irrefutable_let_patterns)]
3450    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3451        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3452            Some((responder))
3453        } else {
3454            None
3455        }
3456    }
3457
3458    #[allow(irrefutable_let_patterns)]
3459    pub fn into_set_reference_clock(
3460        self,
3461    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3462        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3463            Some((reference_clock, control_handle))
3464        } else {
3465            None
3466        }
3467    }
3468
3469    #[allow(irrefutable_let_patterns)]
3470    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3471        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3472            Some((usage, control_handle))
3473        } else {
3474            None
3475        }
3476    }
3477
3478    #[allow(irrefutable_let_patterns)]
3479    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3480        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3481            Some((usage, control_handle))
3482        } else {
3483            None
3484        }
3485    }
3486
3487    #[allow(irrefutable_let_patterns)]
3488    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3489        if let AudioCapturerRequest::GetStreamType { responder } = self {
3490            Some((responder))
3491        } else {
3492            None
3493        }
3494    }
3495
3496    /// Name of the method defined in FIDL
3497    pub fn method_name(&self) -> &'static str {
3498        match *self {
3499            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3500            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3501            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3502            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3503            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3504            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3505            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3506            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3507            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3508            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3509            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3510            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3511            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3512            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3513            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3514            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3515            AudioCapturerRequest::_UnknownMethod {
3516                method_type: fidl::MethodType::OneWay, ..
3517            } => "unknown one-way method",
3518            AudioCapturerRequest::_UnknownMethod {
3519                method_type: fidl::MethodType::TwoWay, ..
3520            } => "unknown two-way method",
3521        }
3522    }
3523}
3524
3525#[derive(Debug, Clone)]
3526pub struct AudioCapturerControlHandle {
3527    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3528}
3529
3530impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3531    fn shutdown(&self) {
3532        self.inner.shutdown()
3533    }
3534
3535    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3536        self.inner.shutdown_with_epitaph(status)
3537    }
3538
3539    fn is_closed(&self) -> bool {
3540        self.inner.channel().is_closed()
3541    }
3542    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3543        self.inner.channel().on_closed()
3544    }
3545
3546    #[cfg(target_os = "fuchsia")]
3547    fn signal_peer(
3548        &self,
3549        clear_mask: zx::Signals,
3550        set_mask: zx::Signals,
3551    ) -> Result<(), zx_status::Status> {
3552        use fidl::Peered;
3553        self.inner.channel().signal_peer(clear_mask, set_mask)
3554    }
3555}
3556
3557impl AudioCapturerControlHandle {
3558    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3559        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3560            (packet,),
3561            0,
3562            0x6bbe69746a3c8bd9,
3563            fidl::encoding::DynamicFlags::empty(),
3564        )
3565    }
3566
3567    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3568        self.inner.send::<fidl::encoding::EmptyPayload>(
3569            (),
3570            0,
3571            0x550e69b41d03e2c2,
3572            fidl::encoding::DynamicFlags::empty(),
3573        )
3574    }
3575}
3576
3577#[must_use = "FIDL methods require a response to be sent"]
3578#[derive(Debug)]
3579pub struct AudioCapturerDiscardAllPacketsResponder {
3580    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3581    tx_id: u32,
3582}
3583
3584/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3585/// if the responder is dropped without sending a response, so that the client
3586/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3587impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3588    fn drop(&mut self) {
3589        self.control_handle.shutdown();
3590        // Safety: drops once, never accessed again
3591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3592    }
3593}
3594
3595impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3596    type ControlHandle = AudioCapturerControlHandle;
3597
3598    fn control_handle(&self) -> &AudioCapturerControlHandle {
3599        &self.control_handle
3600    }
3601
3602    fn drop_without_shutdown(mut self) {
3603        // Safety: drops once, never accessed again due to mem::forget
3604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3605        // Prevent Drop from running (which would shut down the channel)
3606        std::mem::forget(self);
3607    }
3608}
3609
3610impl AudioCapturerDiscardAllPacketsResponder {
3611    /// Sends a response to the FIDL transaction.
3612    ///
3613    /// Sets the channel to shutdown if an error occurs.
3614    pub fn send(self) -> Result<(), fidl::Error> {
3615        let _result = self.send_raw();
3616        if _result.is_err() {
3617            self.control_handle.shutdown();
3618        }
3619        self.drop_without_shutdown();
3620        _result
3621    }
3622
3623    /// Similar to "send" but does not shutdown the channel if an error occurs.
3624    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3625        let _result = self.send_raw();
3626        self.drop_without_shutdown();
3627        _result
3628    }
3629
3630    fn send_raw(&self) -> Result<(), fidl::Error> {
3631        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3632            (),
3633            self.tx_id,
3634            0x27afd605e97b09d2,
3635            fidl::encoding::DynamicFlags::empty(),
3636        )
3637    }
3638}
3639
3640#[must_use = "FIDL methods require a response to be sent"]
3641#[derive(Debug)]
3642pub struct AudioCapturerCaptureAtResponder {
3643    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3644    tx_id: u32,
3645}
3646
3647/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3648/// if the responder is dropped without sending a response, so that the client
3649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3650impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3651    fn drop(&mut self) {
3652        self.control_handle.shutdown();
3653        // Safety: drops once, never accessed again
3654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3655    }
3656}
3657
3658impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3659    type ControlHandle = AudioCapturerControlHandle;
3660
3661    fn control_handle(&self) -> &AudioCapturerControlHandle {
3662        &self.control_handle
3663    }
3664
3665    fn drop_without_shutdown(mut self) {
3666        // Safety: drops once, never accessed again due to mem::forget
3667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3668        // Prevent Drop from running (which would shut down the channel)
3669        std::mem::forget(self);
3670    }
3671}
3672
3673impl AudioCapturerCaptureAtResponder {
3674    /// Sends a response to the FIDL transaction.
3675    ///
3676    /// Sets the channel to shutdown if an error occurs.
3677    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3678        let _result = self.send_raw(captured_packet);
3679        if _result.is_err() {
3680            self.control_handle.shutdown();
3681        }
3682        self.drop_without_shutdown();
3683        _result
3684    }
3685
3686    /// Similar to "send" but does not shutdown the channel if an error occurs.
3687    pub fn send_no_shutdown_on_err(
3688        self,
3689        mut captured_packet: &StreamPacket,
3690    ) -> Result<(), fidl::Error> {
3691        let _result = self.send_raw(captured_packet);
3692        self.drop_without_shutdown();
3693        _result
3694    }
3695
3696    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3697        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3698            (captured_packet,),
3699            self.tx_id,
3700            0x784e25df72cea780,
3701            fidl::encoding::DynamicFlags::empty(),
3702        )
3703    }
3704}
3705
3706#[must_use = "FIDL methods require a response to be sent"]
3707#[derive(Debug)]
3708pub struct AudioCapturerStopAsyncCaptureResponder {
3709    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3710    tx_id: u32,
3711}
3712
3713/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3714/// if the responder is dropped without sending a response, so that the client
3715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3716impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3717    fn drop(&mut self) {
3718        self.control_handle.shutdown();
3719        // Safety: drops once, never accessed again
3720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3721    }
3722}
3723
3724impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
3725    type ControlHandle = AudioCapturerControlHandle;
3726
3727    fn control_handle(&self) -> &AudioCapturerControlHandle {
3728        &self.control_handle
3729    }
3730
3731    fn drop_without_shutdown(mut self) {
3732        // Safety: drops once, never accessed again due to mem::forget
3733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3734        // Prevent Drop from running (which would shut down the channel)
3735        std::mem::forget(self);
3736    }
3737}
3738
3739impl AudioCapturerStopAsyncCaptureResponder {
3740    /// Sends a response to the FIDL transaction.
3741    ///
3742    /// Sets the channel to shutdown if an error occurs.
3743    pub fn send(self) -> Result<(), fidl::Error> {
3744        let _result = self.send_raw();
3745        if _result.is_err() {
3746            self.control_handle.shutdown();
3747        }
3748        self.drop_without_shutdown();
3749        _result
3750    }
3751
3752    /// Similar to "send" but does not shutdown the channel if an error occurs.
3753    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3754        let _result = self.send_raw();
3755        self.drop_without_shutdown();
3756        _result
3757    }
3758
3759    fn send_raw(&self) -> Result<(), fidl::Error> {
3760        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3761            (),
3762            self.tx_id,
3763            0x5bfc8790a8cef8cb,
3764            fidl::encoding::DynamicFlags::empty(),
3765        )
3766    }
3767}
3768
3769#[must_use = "FIDL methods require a response to be sent"]
3770#[derive(Debug)]
3771pub struct AudioCapturerGetReferenceClockResponder {
3772    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3773    tx_id: u32,
3774}
3775
3776/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3777/// if the responder is dropped without sending a response, so that the client
3778/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3779impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3780    fn drop(&mut self) {
3781        self.control_handle.shutdown();
3782        // Safety: drops once, never accessed again
3783        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3784    }
3785}
3786
3787impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
3788    type ControlHandle = AudioCapturerControlHandle;
3789
3790    fn control_handle(&self) -> &AudioCapturerControlHandle {
3791        &self.control_handle
3792    }
3793
3794    fn drop_without_shutdown(mut self) {
3795        // Safety: drops once, never accessed again due to mem::forget
3796        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3797        // Prevent Drop from running (which would shut down the channel)
3798        std::mem::forget(self);
3799    }
3800}
3801
3802impl AudioCapturerGetReferenceClockResponder {
3803    /// Sends a response to the FIDL transaction.
3804    ///
3805    /// Sets the channel to shutdown if an error occurs.
3806    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3807        let _result = self.send_raw(reference_clock);
3808        if _result.is_err() {
3809            self.control_handle.shutdown();
3810        }
3811        self.drop_without_shutdown();
3812        _result
3813    }
3814
3815    /// Similar to "send" but does not shutdown the channel if an error occurs.
3816    pub fn send_no_shutdown_on_err(
3817        self,
3818        mut reference_clock: fidl::Clock,
3819    ) -> Result<(), fidl::Error> {
3820        let _result = self.send_raw(reference_clock);
3821        self.drop_without_shutdown();
3822        _result
3823    }
3824
3825    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
3826        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3827            (reference_clock,),
3828            self.tx_id,
3829            0x50d037aa5a4b4d71,
3830            fidl::encoding::DynamicFlags::empty(),
3831        )
3832    }
3833}
3834
3835#[must_use = "FIDL methods require a response to be sent"]
3836#[derive(Debug)]
3837pub struct AudioCapturerGetStreamTypeResponder {
3838    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3839    tx_id: u32,
3840}
3841
3842/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3843/// if the responder is dropped without sending a response, so that the client
3844/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3845impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3846    fn drop(&mut self) {
3847        self.control_handle.shutdown();
3848        // Safety: drops once, never accessed again
3849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3850    }
3851}
3852
3853impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
3854    type ControlHandle = AudioCapturerControlHandle;
3855
3856    fn control_handle(&self) -> &AudioCapturerControlHandle {
3857        &self.control_handle
3858    }
3859
3860    fn drop_without_shutdown(mut self) {
3861        // Safety: drops once, never accessed again due to mem::forget
3862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3863        // Prevent Drop from running (which would shut down the channel)
3864        std::mem::forget(self);
3865    }
3866}
3867
3868impl AudioCapturerGetStreamTypeResponder {
3869    /// Sends a response to the FIDL transaction.
3870    ///
3871    /// Sets the channel to shutdown if an error occurs.
3872    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3873        let _result = self.send_raw(stream_type);
3874        if _result.is_err() {
3875            self.control_handle.shutdown();
3876        }
3877        self.drop_without_shutdown();
3878        _result
3879    }
3880
3881    /// Similar to "send" but does not shutdown the channel if an error occurs.
3882    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3883        let _result = self.send_raw(stream_type);
3884        self.drop_without_shutdown();
3885        _result
3886    }
3887
3888    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3889        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3890            (stream_type,),
3891            self.tx_id,
3892            0x5dcaaa670b433088,
3893            fidl::encoding::DynamicFlags::empty(),
3894        )
3895    }
3896}
3897
3898#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3899pub struct AudioConsumerMarker;
3900
3901impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
3902    type Proxy = AudioConsumerProxy;
3903    type RequestStream = AudioConsumerRequestStream;
3904    #[cfg(target_os = "fuchsia")]
3905    type SynchronousProxy = AudioConsumerSynchronousProxy;
3906
3907    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3908}
3909
3910pub trait AudioConsumerProxyInterface: Send + Sync {
3911    fn r#create_stream_sink(
3912        &self,
3913        buffers: Vec<fidl::Vmo>,
3914        stream_type: &AudioStreamType,
3915        compression: Option<&Compression>,
3916        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3917    ) -> Result<(), fidl::Error>;
3918    fn r#start(
3919        &self,
3920        flags: AudioConsumerStartFlags,
3921        reference_time: i64,
3922        media_time: i64,
3923    ) -> Result<(), fidl::Error>;
3924    fn r#stop(&self) -> Result<(), fidl::Error>;
3925    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3926    fn r#bind_volume_control(
3927        &self,
3928        volume_control_request: fidl::endpoints::ServerEnd<
3929            fidl_fuchsia_media_audio::VolumeControlMarker,
3930        >,
3931    ) -> Result<(), fidl::Error>;
3932    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3933        + Send;
3934    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3935}
3936#[derive(Debug)]
3937#[cfg(target_os = "fuchsia")]
3938pub struct AudioConsumerSynchronousProxy {
3939    client: fidl::client::sync::Client,
3940}
3941
3942#[cfg(target_os = "fuchsia")]
3943impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
3944    type Proxy = AudioConsumerProxy;
3945    type Protocol = AudioConsumerMarker;
3946
3947    fn from_channel(inner: fidl::Channel) -> Self {
3948        Self::new(inner)
3949    }
3950
3951    fn into_channel(self) -> fidl::Channel {
3952        self.client.into_channel()
3953    }
3954
3955    fn as_channel(&self) -> &fidl::Channel {
3956        self.client.as_channel()
3957    }
3958}
3959
3960#[cfg(target_os = "fuchsia")]
3961impl AudioConsumerSynchronousProxy {
3962    pub fn new(channel: fidl::Channel) -> Self {
3963        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3964        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3965    }
3966
3967    pub fn into_channel(self) -> fidl::Channel {
3968        self.client.into_channel()
3969    }
3970
3971    /// Waits until an event arrives and returns it. It is safe for other
3972    /// threads to make concurrent requests while waiting for an event.
3973    pub fn wait_for_event(
3974        &self,
3975        deadline: zx::MonotonicInstant,
3976    ) -> Result<AudioConsumerEvent, fidl::Error> {
3977        AudioConsumerEvent::decode(self.client.wait_for_event(deadline)?)
3978    }
3979
3980    /// Creates a `StreamSink` for the consumer with the indicated properties.
3981    ///
3982    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3983    /// sequentially rather than concurrently. The first stream sink that's created using this
3984    /// method is used as the sole source of packets incoming to the logical consumer until that
3985    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3986    /// the second stream sink is used, and so on.
3987    ///
3988    /// If an unsupported compression type is supplied, the
3989    /// `stream_sink_request` request will be closed with an epitaph value of
3990    /// `ZX_ERR_INVALID_ARGS`.
3991    pub fn r#create_stream_sink(
3992        &self,
3993        mut buffers: Vec<fidl::Vmo>,
3994        mut stream_type: &AudioStreamType,
3995        mut compression: Option<&Compression>,
3996        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
3997    ) -> Result<(), fidl::Error> {
3998        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
3999            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4000            0x525b3b97fdf7d884,
4001            fidl::encoding::DynamicFlags::empty(),
4002        )
4003    }
4004
4005    /// Starts rendering as indicated by `flags`.
4006    ///
4007    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4008    /// Typically, this is the timestamp of the first packet that will be
4009    /// rendered. If packets will be supplied with no timestamps, this value
4010    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4011    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4012    ///     1. When starting for the first time, the default media time is the
4013    ///        timestamp on the first packet sent to the stream sink.
4014    ///     2. When resuming after stop, the default media time is the media
4015    ///        time at which the stream stopped.
4016    ///
4017    /// `reference_time` is the monotonic system time at which rendering should
4018    /// be started. For supply-driven sources, this must be the time at which
4019    /// the first packet was (or will be) sent plus a lead time, which must be
4020    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4021    /// sources, the client must ensure that the lead time requirement is met at
4022    /// the start time.  Passing the default value of 0 for `reference_time`
4023    /// causes the consumer to choose a start time based on the availability of
4024    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4025    /// specified.
4026    ///
4027    /// The actual start time will be reflected in the updated status.
4028    pub fn r#start(
4029        &self,
4030        mut flags: AudioConsumerStartFlags,
4031        mut reference_time: i64,
4032        mut media_time: i64,
4033    ) -> Result<(), fidl::Error> {
4034        self.client.send::<AudioConsumerStartRequest>(
4035            (flags, reference_time, media_time),
4036            0x4fdbd44b3f2a3a3c,
4037            fidl::encoding::DynamicFlags::empty(),
4038        )
4039    }
4040
4041    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4042    /// be reflected in the updated status.
4043    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4044        self.client.send::<fidl::encoding::EmptyPayload>(
4045            (),
4046            0x3d46c3741686c40d,
4047            fidl::encoding::DynamicFlags::empty(),
4048        )
4049    }
4050
4051    /// Requests to change the playback rate of the renderer. 1.0 means normal
4052    /// playback. Negative rates are not supported. The new rate will be
4053    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4054    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4055        self.client.send::<AudioConsumerSetRateRequest>(
4056            (rate,),
4057            0x45342b73968bfafe,
4058            fidl::encoding::DynamicFlags::empty(),
4059        )
4060    }
4061
4062    /// Binds to this `AudioConsumer` volume control for control and notifications.
4063    pub fn r#bind_volume_control(
4064        &self,
4065        mut volume_control_request: fidl::endpoints::ServerEnd<
4066            fidl_fuchsia_media_audio::VolumeControlMarker,
4067        >,
4068    ) -> Result<(), fidl::Error> {
4069        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4070            (volume_control_request,),
4071            0x6f1b01fd887f5748,
4072            fidl::encoding::DynamicFlags::empty(),
4073        )
4074    }
4075
4076    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4077    /// to this method when the status changes - initially with respect to the initial status value
4078    /// and thereafter with respect to the previously-reported status value.
4079    pub fn r#watch_status(
4080        &self,
4081        ___deadline: zx::MonotonicInstant,
4082    ) -> Result<AudioConsumerStatus, fidl::Error> {
4083        let _response = self
4084            .client
4085            .send_query::<fidl::encoding::EmptyPayload, AudioConsumerWatchStatusResponse>(
4086                (),
4087                0x35cf702c721e2cc6,
4088                fidl::encoding::DynamicFlags::empty(),
4089                ___deadline,
4090            )?;
4091        Ok(_response.status)
4092    }
4093}
4094
4095#[cfg(target_os = "fuchsia")]
4096impl From<AudioConsumerSynchronousProxy> for zx::NullableHandle {
4097    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4098        value.into_channel().into()
4099    }
4100}
4101
4102#[cfg(target_os = "fuchsia")]
4103impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4104    fn from(value: fidl::Channel) -> Self {
4105        Self::new(value)
4106    }
4107}
4108
4109#[cfg(target_os = "fuchsia")]
4110impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4111    type Protocol = AudioConsumerMarker;
4112
4113    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4114        Self::new(value.into_channel())
4115    }
4116}
4117
4118#[derive(Debug, Clone)]
4119pub struct AudioConsumerProxy {
4120    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4121}
4122
4123impl fidl::endpoints::Proxy for AudioConsumerProxy {
4124    type Protocol = AudioConsumerMarker;
4125
4126    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4127        Self::new(inner)
4128    }
4129
4130    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4131        self.client.into_channel().map_err(|client| Self { client })
4132    }
4133
4134    fn as_channel(&self) -> &::fidl::AsyncChannel {
4135        self.client.as_channel()
4136    }
4137}
4138
4139impl AudioConsumerProxy {
4140    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4141    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4142        let protocol_name = <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4143        Self { client: fidl::client::Client::new(channel, protocol_name) }
4144    }
4145
4146    /// Get a Stream of events from the remote end of the protocol.
4147    ///
4148    /// # Panics
4149    ///
4150    /// Panics if the event stream was already taken.
4151    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
4152        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4153    }
4154
4155    /// Creates a `StreamSink` for the consumer with the indicated properties.
4156    ///
4157    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4158    /// sequentially rather than concurrently. The first stream sink that's created using this
4159    /// method is used as the sole source of packets incoming to the logical consumer until that
4160    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4161    /// the second stream sink is used, and so on.
4162    ///
4163    /// If an unsupported compression type is supplied, the
4164    /// `stream_sink_request` request will be closed with an epitaph value of
4165    /// `ZX_ERR_INVALID_ARGS`.
4166    pub fn r#create_stream_sink(
4167        &self,
4168        mut buffers: Vec<fidl::Vmo>,
4169        mut stream_type: &AudioStreamType,
4170        mut compression: Option<&Compression>,
4171        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4172    ) -> Result<(), fidl::Error> {
4173        AudioConsumerProxyInterface::r#create_stream_sink(
4174            self,
4175            buffers,
4176            stream_type,
4177            compression,
4178            stream_sink_request,
4179        )
4180    }
4181
4182    /// Starts rendering as indicated by `flags`.
4183    ///
4184    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4185    /// Typically, this is the timestamp of the first packet that will be
4186    /// rendered. If packets will be supplied with no timestamps, this value
4187    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4188    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4189    ///     1. When starting for the first time, the default media time is the
4190    ///        timestamp on the first packet sent to the stream sink.
4191    ///     2. When resuming after stop, the default media time is the media
4192    ///        time at which the stream stopped.
4193    ///
4194    /// `reference_time` is the monotonic system time at which rendering should
4195    /// be started. For supply-driven sources, this must be the time at which
4196    /// the first packet was (or will be) sent plus a lead time, which must be
4197    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4198    /// sources, the client must ensure that the lead time requirement is met at
4199    /// the start time.  Passing the default value of 0 for `reference_time`
4200    /// causes the consumer to choose a start time based on the availability of
4201    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4202    /// specified.
4203    ///
4204    /// The actual start time will be reflected in the updated status.
4205    pub fn r#start(
4206        &self,
4207        mut flags: AudioConsumerStartFlags,
4208        mut reference_time: i64,
4209        mut media_time: i64,
4210    ) -> Result<(), fidl::Error> {
4211        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4212    }
4213
4214    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4215    /// be reflected in the updated status.
4216    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4217        AudioConsumerProxyInterface::r#stop(self)
4218    }
4219
4220    /// Requests to change the playback rate of the renderer. 1.0 means normal
4221    /// playback. Negative rates are not supported. The new rate will be
4222    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4223    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4224        AudioConsumerProxyInterface::r#set_rate(self, rate)
4225    }
4226
4227    /// Binds to this `AudioConsumer` volume control for control and notifications.
4228    pub fn r#bind_volume_control(
4229        &self,
4230        mut volume_control_request: fidl::endpoints::ServerEnd<
4231            fidl_fuchsia_media_audio::VolumeControlMarker,
4232        >,
4233    ) -> Result<(), fidl::Error> {
4234        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4235    }
4236
4237    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4238    /// to this method when the status changes - initially with respect to the initial status value
4239    /// and thereafter with respect to the previously-reported status value.
4240    pub fn r#watch_status(
4241        &self,
4242    ) -> fidl::client::QueryResponseFut<
4243        AudioConsumerStatus,
4244        fidl::encoding::DefaultFuchsiaResourceDialect,
4245    > {
4246        AudioConsumerProxyInterface::r#watch_status(self)
4247    }
4248}
4249
4250impl AudioConsumerProxyInterface for AudioConsumerProxy {
4251    fn r#create_stream_sink(
4252        &self,
4253        mut buffers: Vec<fidl::Vmo>,
4254        mut stream_type: &AudioStreamType,
4255        mut compression: Option<&Compression>,
4256        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4257    ) -> Result<(), fidl::Error> {
4258        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4259            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4260            0x525b3b97fdf7d884,
4261            fidl::encoding::DynamicFlags::empty(),
4262        )
4263    }
4264
4265    fn r#start(
4266        &self,
4267        mut flags: AudioConsumerStartFlags,
4268        mut reference_time: i64,
4269        mut media_time: i64,
4270    ) -> Result<(), fidl::Error> {
4271        self.client.send::<AudioConsumerStartRequest>(
4272            (flags, reference_time, media_time),
4273            0x4fdbd44b3f2a3a3c,
4274            fidl::encoding::DynamicFlags::empty(),
4275        )
4276    }
4277
4278    fn r#stop(&self) -> Result<(), fidl::Error> {
4279        self.client.send::<fidl::encoding::EmptyPayload>(
4280            (),
4281            0x3d46c3741686c40d,
4282            fidl::encoding::DynamicFlags::empty(),
4283        )
4284    }
4285
4286    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4287        self.client.send::<AudioConsumerSetRateRequest>(
4288            (rate,),
4289            0x45342b73968bfafe,
4290            fidl::encoding::DynamicFlags::empty(),
4291        )
4292    }
4293
4294    fn r#bind_volume_control(
4295        &self,
4296        mut volume_control_request: fidl::endpoints::ServerEnd<
4297            fidl_fuchsia_media_audio::VolumeControlMarker,
4298        >,
4299    ) -> Result<(), fidl::Error> {
4300        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4301            (volume_control_request,),
4302            0x6f1b01fd887f5748,
4303            fidl::encoding::DynamicFlags::empty(),
4304        )
4305    }
4306
4307    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4308        AudioConsumerStatus,
4309        fidl::encoding::DefaultFuchsiaResourceDialect,
4310    >;
4311    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4312        fn _decode(
4313            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4314        ) -> Result<AudioConsumerStatus, fidl::Error> {
4315            let _response = fidl::client::decode_transaction_body::<
4316                AudioConsumerWatchStatusResponse,
4317                fidl::encoding::DefaultFuchsiaResourceDialect,
4318                0x35cf702c721e2cc6,
4319            >(_buf?)?;
4320            Ok(_response.status)
4321        }
4322        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4323            (),
4324            0x35cf702c721e2cc6,
4325            fidl::encoding::DynamicFlags::empty(),
4326            _decode,
4327        )
4328    }
4329}
4330
4331pub struct AudioConsumerEventStream {
4332    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4333}
4334
4335impl std::marker::Unpin for AudioConsumerEventStream {}
4336
4337impl futures::stream::FusedStream for AudioConsumerEventStream {
4338    fn is_terminated(&self) -> bool {
4339        self.event_receiver.is_terminated()
4340    }
4341}
4342
4343impl futures::Stream for AudioConsumerEventStream {
4344    type Item = Result<AudioConsumerEvent, fidl::Error>;
4345
4346    fn poll_next(
4347        mut self: std::pin::Pin<&mut Self>,
4348        cx: &mut std::task::Context<'_>,
4349    ) -> std::task::Poll<Option<Self::Item>> {
4350        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4351            &mut self.event_receiver,
4352            cx
4353        )?) {
4354            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4355            None => std::task::Poll::Ready(None),
4356        }
4357    }
4358}
4359
4360#[derive(Debug)]
4361pub enum AudioConsumerEvent {
4362    OnEndOfStream {},
4363}
4364
4365impl AudioConsumerEvent {
4366    #[allow(irrefutable_let_patterns)]
4367    pub fn into_on_end_of_stream(self) -> Option<()> {
4368        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
4369    }
4370
4371    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4372    fn decode(
4373        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4374    ) -> Result<AudioConsumerEvent, fidl::Error> {
4375        let (bytes, _handles) = buf.split_mut();
4376        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4377        debug_assert_eq!(tx_header.tx_id, 0);
4378        match tx_header.ordinal {
4379            0x53a64e6d0e8f8a20 => {
4380                let mut out = fidl::new_empty!(
4381                    fidl::encoding::EmptyPayload,
4382                    fidl::encoding::DefaultFuchsiaResourceDialect
4383                );
4384                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4385                Ok((AudioConsumerEvent::OnEndOfStream {}))
4386            }
4387            _ => Err(fidl::Error::UnknownOrdinal {
4388                ordinal: tx_header.ordinal,
4389                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4390            }),
4391        }
4392    }
4393}
4394
4395/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4396pub struct AudioConsumerRequestStream {
4397    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4398    is_terminated: bool,
4399}
4400
4401impl std::marker::Unpin for AudioConsumerRequestStream {}
4402
4403impl futures::stream::FusedStream for AudioConsumerRequestStream {
4404    fn is_terminated(&self) -> bool {
4405        self.is_terminated
4406    }
4407}
4408
4409impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4410    type Protocol = AudioConsumerMarker;
4411    type ControlHandle = AudioConsumerControlHandle;
4412
4413    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4414        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4415    }
4416
4417    fn control_handle(&self) -> Self::ControlHandle {
4418        AudioConsumerControlHandle { inner: self.inner.clone() }
4419    }
4420
4421    fn into_inner(
4422        self,
4423    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4424    {
4425        (self.inner, self.is_terminated)
4426    }
4427
4428    fn from_inner(
4429        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4430        is_terminated: bool,
4431    ) -> Self {
4432        Self { inner, is_terminated }
4433    }
4434}
4435
4436impl futures::Stream for AudioConsumerRequestStream {
4437    type Item = Result<AudioConsumerRequest, fidl::Error>;
4438
4439    fn poll_next(
4440        mut self: std::pin::Pin<&mut Self>,
4441        cx: &mut std::task::Context<'_>,
4442    ) -> std::task::Poll<Option<Self::Item>> {
4443        let this = &mut *self;
4444        if this.inner.check_shutdown(cx) {
4445            this.is_terminated = true;
4446            return std::task::Poll::Ready(None);
4447        }
4448        if this.is_terminated {
4449            panic!("polled AudioConsumerRequestStream after completion");
4450        }
4451        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4452            |bytes, handles| {
4453                match this.inner.channel().read_etc(cx, bytes, handles) {
4454                    std::task::Poll::Ready(Ok(())) => {}
4455                    std::task::Poll::Pending => return std::task::Poll::Pending,
4456                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4457                        this.is_terminated = true;
4458                        return std::task::Poll::Ready(None);
4459                    }
4460                    std::task::Poll::Ready(Err(e)) => {
4461                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4462                            e.into(),
4463                        ))));
4464                    }
4465                }
4466
4467                // A message has been received from the channel
4468                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4469
4470                std::task::Poll::Ready(Some(match header.ordinal {
4471                    0x525b3b97fdf7d884 => {
4472                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4473                        let mut req = fidl::new_empty!(
4474                            AudioConsumerCreateStreamSinkRequest,
4475                            fidl::encoding::DefaultFuchsiaResourceDialect
4476                        );
4477                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4478                        let control_handle =
4479                            AudioConsumerControlHandle { inner: this.inner.clone() };
4480                        Ok(AudioConsumerRequest::CreateStreamSink {
4481                            buffers: req.buffers,
4482                            stream_type: req.stream_type,
4483                            compression: req.compression,
4484                            stream_sink_request: req.stream_sink_request,
4485
4486                            control_handle,
4487                        })
4488                    }
4489                    0x4fdbd44b3f2a3a3c => {
4490                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4491                        let mut req = fidl::new_empty!(
4492                            AudioConsumerStartRequest,
4493                            fidl::encoding::DefaultFuchsiaResourceDialect
4494                        );
4495                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4496                        let control_handle =
4497                            AudioConsumerControlHandle { inner: this.inner.clone() };
4498                        Ok(AudioConsumerRequest::Start {
4499                            flags: req.flags,
4500                            reference_time: req.reference_time,
4501                            media_time: req.media_time,
4502
4503                            control_handle,
4504                        })
4505                    }
4506                    0x3d46c3741686c40d => {
4507                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4508                        let mut req = fidl::new_empty!(
4509                            fidl::encoding::EmptyPayload,
4510                            fidl::encoding::DefaultFuchsiaResourceDialect
4511                        );
4512                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4513                        let control_handle =
4514                            AudioConsumerControlHandle { inner: this.inner.clone() };
4515                        Ok(AudioConsumerRequest::Stop { control_handle })
4516                    }
4517                    0x45342b73968bfafe => {
4518                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4519                        let mut req = fidl::new_empty!(
4520                            AudioConsumerSetRateRequest,
4521                            fidl::encoding::DefaultFuchsiaResourceDialect
4522                        );
4523                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4524                        let control_handle =
4525                            AudioConsumerControlHandle { inner: this.inner.clone() };
4526                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4527                    }
4528                    0x6f1b01fd887f5748 => {
4529                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4530                        let mut req = fidl::new_empty!(
4531                            AudioConsumerBindVolumeControlRequest,
4532                            fidl::encoding::DefaultFuchsiaResourceDialect
4533                        );
4534                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4535                        let control_handle =
4536                            AudioConsumerControlHandle { inner: this.inner.clone() };
4537                        Ok(AudioConsumerRequest::BindVolumeControl {
4538                            volume_control_request: req.volume_control_request,
4539
4540                            control_handle,
4541                        })
4542                    }
4543                    0x35cf702c721e2cc6 => {
4544                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4545                        let mut req = fidl::new_empty!(
4546                            fidl::encoding::EmptyPayload,
4547                            fidl::encoding::DefaultFuchsiaResourceDialect
4548                        );
4549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4550                        let control_handle =
4551                            AudioConsumerControlHandle { inner: this.inner.clone() };
4552                        Ok(AudioConsumerRequest::WatchStatus {
4553                            responder: AudioConsumerWatchStatusResponder {
4554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4555                                tx_id: header.tx_id,
4556                            },
4557                        })
4558                    }
4559                    _ => Err(fidl::Error::UnknownOrdinal {
4560                        ordinal: header.ordinal,
4561                        protocol_name:
4562                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4563                    }),
4564                }))
4565            },
4566        )
4567    }
4568}
4569
4570/// Interface for playing and controlling audio.
4571#[derive(Debug)]
4572pub enum AudioConsumerRequest {
4573    /// Creates a `StreamSink` for the consumer with the indicated properties.
4574    ///
4575    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4576    /// sequentially rather than concurrently. The first stream sink that's created using this
4577    /// method is used as the sole source of packets incoming to the logical consumer until that
4578    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4579    /// the second stream sink is used, and so on.
4580    ///
4581    /// If an unsupported compression type is supplied, the
4582    /// `stream_sink_request` request will be closed with an epitaph value of
4583    /// `ZX_ERR_INVALID_ARGS`.
4584    CreateStreamSink {
4585        buffers: Vec<fidl::Vmo>,
4586        stream_type: AudioStreamType,
4587        compression: Option<Box<Compression>>,
4588        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4589        control_handle: AudioConsumerControlHandle,
4590    },
4591    /// Starts rendering as indicated by `flags`.
4592    ///
4593    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4594    /// Typically, this is the timestamp of the first packet that will be
4595    /// rendered. If packets will be supplied with no timestamps, this value
4596    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4597    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4598    ///     1. When starting for the first time, the default media time is the
4599    ///        timestamp on the first packet sent to the stream sink.
4600    ///     2. When resuming after stop, the default media time is the media
4601    ///        time at which the stream stopped.
4602    ///
4603    /// `reference_time` is the monotonic system time at which rendering should
4604    /// be started. For supply-driven sources, this must be the time at which
4605    /// the first packet was (or will be) sent plus a lead time, which must be
4606    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4607    /// sources, the client must ensure that the lead time requirement is met at
4608    /// the start time.  Passing the default value of 0 for `reference_time`
4609    /// causes the consumer to choose a start time based on the availability of
4610    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4611    /// specified.
4612    ///
4613    /// The actual start time will be reflected in the updated status.
4614    Start {
4615        flags: AudioConsumerStartFlags,
4616        reference_time: i64,
4617        media_time: i64,
4618        control_handle: AudioConsumerControlHandle,
4619    },
4620    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4621    /// be reflected in the updated status.
4622    Stop { control_handle: AudioConsumerControlHandle },
4623    /// Requests to change the playback rate of the renderer. 1.0 means normal
4624    /// playback. Negative rates are not supported. The new rate will be
4625    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4626    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4627    /// Binds to this `AudioConsumer` volume control for control and notifications.
4628    BindVolumeControl {
4629        volume_control_request:
4630            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4631        control_handle: AudioConsumerControlHandle,
4632    },
4633    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4634    /// to this method when the status changes - initially with respect to the initial status value
4635    /// and thereafter with respect to the previously-reported status value.
4636    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4637}
4638
4639impl AudioConsumerRequest {
4640    #[allow(irrefutable_let_patterns)]
4641    pub fn into_create_stream_sink(
4642        self,
4643    ) -> Option<(
4644        Vec<fidl::Vmo>,
4645        AudioStreamType,
4646        Option<Box<Compression>>,
4647        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4648        AudioConsumerControlHandle,
4649    )> {
4650        if let AudioConsumerRequest::CreateStreamSink {
4651            buffers,
4652            stream_type,
4653            compression,
4654            stream_sink_request,
4655            control_handle,
4656        } = self
4657        {
4658            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4659        } else {
4660            None
4661        }
4662    }
4663
4664    #[allow(irrefutable_let_patterns)]
4665    pub fn into_start(
4666        self,
4667    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4668        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4669            self
4670        {
4671            Some((flags, reference_time, media_time, control_handle))
4672        } else {
4673            None
4674        }
4675    }
4676
4677    #[allow(irrefutable_let_patterns)]
4678    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4679        if let AudioConsumerRequest::Stop { control_handle } = self {
4680            Some((control_handle))
4681        } else {
4682            None
4683        }
4684    }
4685
4686    #[allow(irrefutable_let_patterns)]
4687    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4688        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4689            Some((rate, control_handle))
4690        } else {
4691            None
4692        }
4693    }
4694
4695    #[allow(irrefutable_let_patterns)]
4696    pub fn into_bind_volume_control(
4697        self,
4698    ) -> Option<(
4699        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4700        AudioConsumerControlHandle,
4701    )> {
4702        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4703            self
4704        {
4705            Some((volume_control_request, control_handle))
4706        } else {
4707            None
4708        }
4709    }
4710
4711    #[allow(irrefutable_let_patterns)]
4712    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4713        if let AudioConsumerRequest::WatchStatus { responder } = self {
4714            Some((responder))
4715        } else {
4716            None
4717        }
4718    }
4719
4720    /// Name of the method defined in FIDL
4721    pub fn method_name(&self) -> &'static str {
4722        match *self {
4723            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4724            AudioConsumerRequest::Start { .. } => "start",
4725            AudioConsumerRequest::Stop { .. } => "stop",
4726            AudioConsumerRequest::SetRate { .. } => "set_rate",
4727            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4728            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4729        }
4730    }
4731}
4732
4733#[derive(Debug, Clone)]
4734pub struct AudioConsumerControlHandle {
4735    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4736}
4737
4738impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
4739    fn shutdown(&self) {
4740        self.inner.shutdown()
4741    }
4742
4743    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4744        self.inner.shutdown_with_epitaph(status)
4745    }
4746
4747    fn is_closed(&self) -> bool {
4748        self.inner.channel().is_closed()
4749    }
4750    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4751        self.inner.channel().on_closed()
4752    }
4753
4754    #[cfg(target_os = "fuchsia")]
4755    fn signal_peer(
4756        &self,
4757        clear_mask: zx::Signals,
4758        set_mask: zx::Signals,
4759    ) -> Result<(), zx_status::Status> {
4760        use fidl::Peered;
4761        self.inner.channel().signal_peer(clear_mask, set_mask)
4762    }
4763}
4764
4765impl AudioConsumerControlHandle {
4766    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4767        self.inner.send::<fidl::encoding::EmptyPayload>(
4768            (),
4769            0,
4770            0x53a64e6d0e8f8a20,
4771            fidl::encoding::DynamicFlags::empty(),
4772        )
4773    }
4774}
4775
4776#[must_use = "FIDL methods require a response to be sent"]
4777#[derive(Debug)]
4778pub struct AudioConsumerWatchStatusResponder {
4779    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4780    tx_id: u32,
4781}
4782
4783/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4784/// if the responder is dropped without sending a response, so that the client
4785/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4786impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4787    fn drop(&mut self) {
4788        self.control_handle.shutdown();
4789        // Safety: drops once, never accessed again
4790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4791    }
4792}
4793
4794impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
4795    type ControlHandle = AudioConsumerControlHandle;
4796
4797    fn control_handle(&self) -> &AudioConsumerControlHandle {
4798        &self.control_handle
4799    }
4800
4801    fn drop_without_shutdown(mut self) {
4802        // Safety: drops once, never accessed again due to mem::forget
4803        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4804        // Prevent Drop from running (which would shut down the channel)
4805        std::mem::forget(self);
4806    }
4807}
4808
4809impl AudioConsumerWatchStatusResponder {
4810    /// Sends a response to the FIDL transaction.
4811    ///
4812    /// Sets the channel to shutdown if an error occurs.
4813    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4814        let _result = self.send_raw(status);
4815        if _result.is_err() {
4816            self.control_handle.shutdown();
4817        }
4818        self.drop_without_shutdown();
4819        _result
4820    }
4821
4822    /// Similar to "send" but does not shutdown the channel if an error occurs.
4823    pub fn send_no_shutdown_on_err(
4824        self,
4825        mut status: &AudioConsumerStatus,
4826    ) -> Result<(), fidl::Error> {
4827        let _result = self.send_raw(status);
4828        self.drop_without_shutdown();
4829        _result
4830    }
4831
4832    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4833        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4834            (status,),
4835            self.tx_id,
4836            0x35cf702c721e2cc6,
4837            fidl::encoding::DynamicFlags::empty(),
4838        )
4839    }
4840}
4841
4842#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4843pub struct AudioCoreMarker;
4844
4845impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
4846    type Proxy = AudioCoreProxy;
4847    type RequestStream = AudioCoreRequestStream;
4848    #[cfg(target_os = "fuchsia")]
4849    type SynchronousProxy = AudioCoreSynchronousProxy;
4850
4851    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4852}
4853impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
4854
4855pub trait AudioCoreProxyInterface: Send + Sync {
4856    fn r#create_audio_renderer(
4857        &self,
4858        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4859    ) -> Result<(), fidl::Error>;
4860    fn r#create_audio_capturer_with_configuration(
4861        &self,
4862        stream_type: &AudioStreamType,
4863        configuration: &AudioCapturerConfiguration,
4864        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4865    ) -> Result<(), fidl::Error>;
4866    fn r#create_audio_capturer(
4867        &self,
4868        loopback: bool,
4869        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
4870    ) -> Result<(), fidl::Error>;
4871    fn r#set_render_usage_gain(
4872        &self,
4873        usage: AudioRenderUsage,
4874        gain_db: f32,
4875    ) -> Result<(), fidl::Error>;
4876    fn r#set_render_usage_gain2(
4877        &self,
4878        usage: AudioRenderUsage2,
4879        gain_db: f32,
4880    ) -> Result<(), fidl::Error>;
4881    fn r#set_capture_usage_gain(
4882        &self,
4883        usage: AudioCaptureUsage,
4884        gain_db: f32,
4885    ) -> Result<(), fidl::Error>;
4886    fn r#set_capture_usage_gain2(
4887        &self,
4888        usage: AudioCaptureUsage2,
4889        gain_db: f32,
4890    ) -> Result<(), fidl::Error>;
4891    fn r#bind_usage_volume_control(
4892        &self,
4893        usage: &Usage,
4894        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4895    ) -> Result<(), fidl::Error>;
4896    fn r#bind_usage_volume_control2(
4897        &self,
4898        usage: &Usage2,
4899        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4900    ) -> Result<(), fidl::Error>;
4901    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4902    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4903    -> Self::GetVolumeFromDbResponseFut;
4904    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4905    fn r#get_volume_from_db2(
4906        &self,
4907        usage: &Usage2,
4908        gain_db: f32,
4909    ) -> Self::GetVolumeFromDb2ResponseFut;
4910    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4911    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4912    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4913    fn r#get_db_from_volume2(
4914        &self,
4915        usage: &Usage2,
4916        volume: f32,
4917    ) -> Self::GetDbFromVolume2ResponseFut;
4918    fn r#set_interaction(
4919        &self,
4920        active: &Usage,
4921        affected: &Usage,
4922        behavior: Behavior,
4923    ) -> Result<(), fidl::Error>;
4924    fn r#set_interaction2(
4925        &self,
4926        active: &Usage2,
4927        affected: &Usage2,
4928        behavior: Behavior,
4929    ) -> Result<(), fidl::Error>;
4930    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4931    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4932}
4933#[derive(Debug)]
4934#[cfg(target_os = "fuchsia")]
4935pub struct AudioCoreSynchronousProxy {
4936    client: fidl::client::sync::Client,
4937}
4938
4939#[cfg(target_os = "fuchsia")]
4940impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
4941    type Proxy = AudioCoreProxy;
4942    type Protocol = AudioCoreMarker;
4943
4944    fn from_channel(inner: fidl::Channel) -> Self {
4945        Self::new(inner)
4946    }
4947
4948    fn into_channel(self) -> fidl::Channel {
4949        self.client.into_channel()
4950    }
4951
4952    fn as_channel(&self) -> &fidl::Channel {
4953        self.client.as_channel()
4954    }
4955}
4956
4957#[cfg(target_os = "fuchsia")]
4958impl AudioCoreSynchronousProxy {
4959    pub fn new(channel: fidl::Channel) -> Self {
4960        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4961        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4962    }
4963
4964    pub fn into_channel(self) -> fidl::Channel {
4965        self.client.into_channel()
4966    }
4967
4968    /// Waits until an event arrives and returns it. It is safe for other
4969    /// threads to make concurrent requests while waiting for an event.
4970    pub fn wait_for_event(
4971        &self,
4972        deadline: zx::MonotonicInstant,
4973    ) -> Result<AudioCoreEvent, fidl::Error> {
4974        AudioCoreEvent::decode(self.client.wait_for_event(deadline)?)
4975    }
4976
4977    /// Creates an AudioRenderer which outputs audio to the default device.
4978    pub fn r#create_audio_renderer(
4979        &self,
4980        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
4981    ) -> Result<(), fidl::Error> {
4982        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4983            (audio_out_request,),
4984            0x2ac9beba47f83435,
4985            fidl::encoding::DynamicFlags::empty(),
4986        )
4987    }
4988
4989    /// Creates an AudioCapturer according to the given requirements.
4990    ///
4991    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4992    /// It causes the source material to be reformatted/resampled if needed
4993    /// in order to produce the requested stream type.
4994    ///
4995    /// `usage` is used by Fuchsia to make decisions about user experience.
4996    /// See `AudioCaptureUsage` for more details.
4997    ///
4998    /// `configuration` must be initialized to a variant, or no capturer
4999    /// can be created.
5000    pub fn r#create_audio_capturer_with_configuration(
5001        &self,
5002        mut stream_type: &AudioStreamType,
5003        mut configuration: &AudioCapturerConfiguration,
5004        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5005    ) -> Result<(), fidl::Error> {
5006        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5007            (stream_type, configuration, audio_capturer_request),
5008            0x459de383b0d76d97,
5009            fidl::encoding::DynamicFlags::empty(),
5010        )
5011    }
5012
5013    /// Creates an AudioCapturer which either captures from the current default
5014    /// audio input device, or loops-back from the current default audio output
5015    /// device based on value passed for the loopback flag.
5016    pub fn r#create_audio_capturer(
5017        &self,
5018        mut loopback: bool,
5019        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5020    ) -> Result<(), fidl::Error> {
5021        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5022            (loopback, audio_in_request),
5023            0x787db169df99aed0,
5024            fidl::encoding::DynamicFlags::empty(),
5025        )
5026    }
5027
5028    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5029    pub fn r#set_render_usage_gain(
5030        &self,
5031        mut usage: AudioRenderUsage,
5032        mut gain_db: f32,
5033    ) -> Result<(), fidl::Error> {
5034        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5035            (usage, gain_db),
5036            0x48097f45f6e2b8e7,
5037            fidl::encoding::DynamicFlags::empty(),
5038        )
5039    }
5040
5041    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5042    pub fn r#set_render_usage_gain2(
5043        &self,
5044        mut usage: AudioRenderUsage2,
5045        mut gain_db: f32,
5046    ) -> Result<(), fidl::Error> {
5047        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5048            (usage, gain_db),
5049            0x779b1531dc9e64f4,
5050            fidl::encoding::DynamicFlags::FLEXIBLE,
5051        )
5052    }
5053
5054    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5055    pub fn r#set_capture_usage_gain(
5056        &self,
5057        mut usage: AudioCaptureUsage,
5058        mut gain_db: f32,
5059    ) -> Result<(), fidl::Error> {
5060        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5061            (usage, gain_db),
5062            0x457d29217d4ea248,
5063            fidl::encoding::DynamicFlags::empty(),
5064        )
5065    }
5066
5067    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5068    pub fn r#set_capture_usage_gain2(
5069        &self,
5070        mut usage: AudioCaptureUsage2,
5071        mut gain_db: f32,
5072    ) -> Result<(), fidl::Error> {
5073        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5074            (usage, gain_db),
5075            0x15065ee308f44af0,
5076            fidl::encoding::DynamicFlags::FLEXIBLE,
5077        )
5078    }
5079
5080    /// Binds to a volume control protocol for the given usage.
5081    pub fn r#bind_usage_volume_control(
5082        &self,
5083        mut usage: &Usage,
5084        mut volume_control: fidl::endpoints::ServerEnd<
5085            fidl_fuchsia_media_audio::VolumeControlMarker,
5086        >,
5087    ) -> Result<(), fidl::Error> {
5088        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5089            (usage, volume_control),
5090            0x7225be116aadc137,
5091            fidl::encoding::DynamicFlags::empty(),
5092        )
5093    }
5094
5095    /// Binds to a volume control protocol for the given usage.
5096    pub fn r#bind_usage_volume_control2(
5097        &self,
5098        mut usage: &Usage2,
5099        mut volume_control: fidl::endpoints::ServerEnd<
5100            fidl_fuchsia_media_audio::VolumeControlMarker,
5101        >,
5102    ) -> Result<(), fidl::Error> {
5103        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5104            (usage, volume_control),
5105            0x729dff93019d055,
5106            fidl::encoding::DynamicFlags::FLEXIBLE,
5107        )
5108    }
5109
5110    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5111    /// `usage`. This is the same mapping as used by the VolumeControl from
5112    /// `BindUsageVolumeControl`.
5113    pub fn r#get_volume_from_db(
5114        &self,
5115        mut usage: &Usage,
5116        mut gain_db: f32,
5117        ___deadline: zx::MonotonicInstant,
5118    ) -> Result<f32, fidl::Error> {
5119        let _response = self
5120            .client
5121            .send_query::<AudioCoreGetVolumeFromDbRequest, AudioCoreGetVolumeFromDbResponse>(
5122                (usage, gain_db),
5123                0x50e3ca45509770bf,
5124                fidl::encoding::DynamicFlags::empty(),
5125                ___deadline,
5126            )?;
5127        Ok(_response.volume)
5128    }
5129
5130    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5131    /// `usage`. This is the same mapping as used by the VolumeControl from
5132    /// `BindUsageVolumeControl`.
5133    pub fn r#get_volume_from_db2(
5134        &self,
5135        mut usage: &Usage2,
5136        mut gain_db: f32,
5137        ___deadline: zx::MonotonicInstant,
5138    ) -> Result<f32, fidl::Error> {
5139        let _response = self.client.send_query::<
5140            AudioCoreGetVolumeFromDb2Request,
5141            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5142        >(
5143            (usage, gain_db,),
5144            0x165c811091ef99da,
5145            fidl::encoding::DynamicFlags::FLEXIBLE,
5146            ___deadline,
5147        )?
5148        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5149        Ok(_response.volume)
5150    }
5151
5152    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5153    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5154    pub fn r#get_db_from_volume(
5155        &self,
5156        mut usage: &Usage,
5157        mut volume: f32,
5158        ___deadline: zx::MonotonicInstant,
5159    ) -> Result<f32, fidl::Error> {
5160        let _response = self
5161            .client
5162            .send_query::<AudioCoreGetDbFromVolumeRequest, AudioCoreGetDbFromVolumeResponse>(
5163                (usage, volume),
5164                0x3e8eec27dd5a8bda,
5165                fidl::encoding::DynamicFlags::empty(),
5166                ___deadline,
5167            )?;
5168        Ok(_response.gain_db)
5169    }
5170
5171    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5172    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5173    pub fn r#get_db_from_volume2(
5174        &self,
5175        mut usage: &Usage2,
5176        mut volume: f32,
5177        ___deadline: zx::MonotonicInstant,
5178    ) -> Result<f32, fidl::Error> {
5179        let _response = self.client.send_query::<
5180            AudioCoreGetDbFromVolume2Request,
5181            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5182        >(
5183            (usage, volume,),
5184            0x5f421a8ebf265bf3,
5185            fidl::encoding::DynamicFlags::FLEXIBLE,
5186            ___deadline,
5187        )?
5188        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5189        Ok(_response.gain_db)
5190    }
5191
5192    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5193    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5194    /// the Behavior specified will be applied to the streams of Usage `affected`.
5195    pub fn r#set_interaction(
5196        &self,
5197        mut active: &Usage,
5198        mut affected: &Usage,
5199        mut behavior: Behavior,
5200    ) -> Result<(), fidl::Error> {
5201        self.client.send::<AudioCoreSetInteractionRequest>(
5202            (active, affected, behavior),
5203            0x7bfed14345ece7b7,
5204            fidl::encoding::DynamicFlags::empty(),
5205        )
5206    }
5207
5208    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5209    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5210    /// the Behavior specified will be applied to the streams of Usage `affected`.
5211    pub fn r#set_interaction2(
5212        &self,
5213        mut active: &Usage2,
5214        mut affected: &Usage2,
5215        mut behavior: Behavior,
5216    ) -> Result<(), fidl::Error> {
5217        self.client.send::<AudioCoreSetInteraction2Request>(
5218            (active, affected, behavior),
5219            0x7226c7c6e6edc62f,
5220            fidl::encoding::DynamicFlags::FLEXIBLE,
5221        )
5222    }
5223
5224    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5225    /// audio_core. The default behavior is 'NONE'.
5226    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5227        self.client.send::<fidl::encoding::EmptyPayload>(
5228            (),
5229            0x65bd94d9d0a28b5e,
5230            fidl::encoding::DynamicFlags::empty(),
5231        )
5232    }
5233
5234    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5235    /// does not provide a config.
5236    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5237        self.client.send::<fidl::encoding::EmptyPayload>(
5238            (),
5239            0x54a0bebca85f6b31,
5240            fidl::encoding::DynamicFlags::empty(),
5241        )
5242    }
5243}
5244
5245#[cfg(target_os = "fuchsia")]
5246impl From<AudioCoreSynchronousProxy> for zx::NullableHandle {
5247    fn from(value: AudioCoreSynchronousProxy) -> Self {
5248        value.into_channel().into()
5249    }
5250}
5251
5252#[cfg(target_os = "fuchsia")]
5253impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5254    fn from(value: fidl::Channel) -> Self {
5255        Self::new(value)
5256    }
5257}
5258
5259#[cfg(target_os = "fuchsia")]
5260impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5261    type Protocol = AudioCoreMarker;
5262
5263    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5264        Self::new(value.into_channel())
5265    }
5266}
5267
5268#[derive(Debug, Clone)]
5269pub struct AudioCoreProxy {
5270    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5271}
5272
5273impl fidl::endpoints::Proxy for AudioCoreProxy {
5274    type Protocol = AudioCoreMarker;
5275
5276    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5277        Self::new(inner)
5278    }
5279
5280    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5281        self.client.into_channel().map_err(|client| Self { client })
5282    }
5283
5284    fn as_channel(&self) -> &::fidl::AsyncChannel {
5285        self.client.as_channel()
5286    }
5287}
5288
5289impl AudioCoreProxy {
5290    /// Create a new Proxy for fuchsia.media/AudioCore.
5291    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5292        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5293        Self { client: fidl::client::Client::new(channel, protocol_name) }
5294    }
5295
5296    /// Get a Stream of events from the remote end of the protocol.
5297    ///
5298    /// # Panics
5299    ///
5300    /// Panics if the event stream was already taken.
5301    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5302        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5303    }
5304
5305    /// Creates an AudioRenderer which outputs audio to the default device.
5306    pub fn r#create_audio_renderer(
5307        &self,
5308        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5309    ) -> Result<(), fidl::Error> {
5310        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5311    }
5312
5313    /// Creates an AudioCapturer according to the given requirements.
5314    ///
5315    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5316    /// It causes the source material to be reformatted/resampled if needed
5317    /// in order to produce the requested stream type.
5318    ///
5319    /// `usage` is used by Fuchsia to make decisions about user experience.
5320    /// See `AudioCaptureUsage` for more details.
5321    ///
5322    /// `configuration` must be initialized to a variant, or no capturer
5323    /// can be created.
5324    pub fn r#create_audio_capturer_with_configuration(
5325        &self,
5326        mut stream_type: &AudioStreamType,
5327        mut configuration: &AudioCapturerConfiguration,
5328        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5329    ) -> Result<(), fidl::Error> {
5330        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5331            self,
5332            stream_type,
5333            configuration,
5334            audio_capturer_request,
5335        )
5336    }
5337
5338    /// Creates an AudioCapturer which either captures from the current default
5339    /// audio input device, or loops-back from the current default audio output
5340    /// device based on value passed for the loopback flag.
5341    pub fn r#create_audio_capturer(
5342        &self,
5343        mut loopback: bool,
5344        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5345    ) -> Result<(), fidl::Error> {
5346        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5347    }
5348
5349    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5350    pub fn r#set_render_usage_gain(
5351        &self,
5352        mut usage: AudioRenderUsage,
5353        mut gain_db: f32,
5354    ) -> Result<(), fidl::Error> {
5355        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5356    }
5357
5358    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5359    pub fn r#set_render_usage_gain2(
5360        &self,
5361        mut usage: AudioRenderUsage2,
5362        mut gain_db: f32,
5363    ) -> Result<(), fidl::Error> {
5364        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5365    }
5366
5367    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5368    pub fn r#set_capture_usage_gain(
5369        &self,
5370        mut usage: AudioCaptureUsage,
5371        mut gain_db: f32,
5372    ) -> Result<(), fidl::Error> {
5373        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5374    }
5375
5376    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5377    pub fn r#set_capture_usage_gain2(
5378        &self,
5379        mut usage: AudioCaptureUsage2,
5380        mut gain_db: f32,
5381    ) -> Result<(), fidl::Error> {
5382        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5383    }
5384
5385    /// Binds to a volume control protocol for the given usage.
5386    pub fn r#bind_usage_volume_control(
5387        &self,
5388        mut usage: &Usage,
5389        mut volume_control: fidl::endpoints::ServerEnd<
5390            fidl_fuchsia_media_audio::VolumeControlMarker,
5391        >,
5392    ) -> Result<(), fidl::Error> {
5393        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5394    }
5395
5396    /// Binds to a volume control protocol for the given usage.
5397    pub fn r#bind_usage_volume_control2(
5398        &self,
5399        mut usage: &Usage2,
5400        mut volume_control: fidl::endpoints::ServerEnd<
5401            fidl_fuchsia_media_audio::VolumeControlMarker,
5402        >,
5403    ) -> Result<(), fidl::Error> {
5404        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5405    }
5406
5407    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5408    /// `usage`. This is the same mapping as used by the VolumeControl from
5409    /// `BindUsageVolumeControl`.
5410    pub fn r#get_volume_from_db(
5411        &self,
5412        mut usage: &Usage,
5413        mut gain_db: f32,
5414    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5415        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5416    }
5417
5418    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5419    /// `usage`. This is the same mapping as used by the VolumeControl from
5420    /// `BindUsageVolumeControl`.
5421    pub fn r#get_volume_from_db2(
5422        &self,
5423        mut usage: &Usage2,
5424        mut gain_db: f32,
5425    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5426        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5427    }
5428
5429    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5430    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5431    pub fn r#get_db_from_volume(
5432        &self,
5433        mut usage: &Usage,
5434        mut volume: f32,
5435    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5436        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5437    }
5438
5439    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5440    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5441    pub fn r#get_db_from_volume2(
5442        &self,
5443        mut usage: &Usage2,
5444        mut volume: f32,
5445    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5446        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5447    }
5448
5449    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5450    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5451    /// the Behavior specified will be applied to the streams of Usage `affected`.
5452    pub fn r#set_interaction(
5453        &self,
5454        mut active: &Usage,
5455        mut affected: &Usage,
5456        mut behavior: Behavior,
5457    ) -> Result<(), fidl::Error> {
5458        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5459    }
5460
5461    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5462    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5463    /// the Behavior specified will be applied to the streams of Usage `affected`.
5464    pub fn r#set_interaction2(
5465        &self,
5466        mut active: &Usage2,
5467        mut affected: &Usage2,
5468        mut behavior: Behavior,
5469    ) -> Result<(), fidl::Error> {
5470        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5471    }
5472
5473    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5474    /// audio_core. The default behavior is 'NONE'.
5475    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5476        AudioCoreProxyInterface::r#reset_interactions(self)
5477    }
5478
5479    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5480    /// does not provide a config.
5481    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5482        AudioCoreProxyInterface::r#load_defaults(self)
5483    }
5484}
5485
5486impl AudioCoreProxyInterface for AudioCoreProxy {
5487    fn r#create_audio_renderer(
5488        &self,
5489        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5490    ) -> Result<(), fidl::Error> {
5491        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5492            (audio_out_request,),
5493            0x2ac9beba47f83435,
5494            fidl::encoding::DynamicFlags::empty(),
5495        )
5496    }
5497
5498    fn r#create_audio_capturer_with_configuration(
5499        &self,
5500        mut stream_type: &AudioStreamType,
5501        mut configuration: &AudioCapturerConfiguration,
5502        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5503    ) -> Result<(), fidl::Error> {
5504        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5505            (stream_type, configuration, audio_capturer_request),
5506            0x459de383b0d76d97,
5507            fidl::encoding::DynamicFlags::empty(),
5508        )
5509    }
5510
5511    fn r#create_audio_capturer(
5512        &self,
5513        mut loopback: bool,
5514        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5515    ) -> Result<(), fidl::Error> {
5516        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5517            (loopback, audio_in_request),
5518            0x787db169df99aed0,
5519            fidl::encoding::DynamicFlags::empty(),
5520        )
5521    }
5522
5523    fn r#set_render_usage_gain(
5524        &self,
5525        mut usage: AudioRenderUsage,
5526        mut gain_db: f32,
5527    ) -> Result<(), fidl::Error> {
5528        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5529            (usage, gain_db),
5530            0x48097f45f6e2b8e7,
5531            fidl::encoding::DynamicFlags::empty(),
5532        )
5533    }
5534
5535    fn r#set_render_usage_gain2(
5536        &self,
5537        mut usage: AudioRenderUsage2,
5538        mut gain_db: f32,
5539    ) -> Result<(), fidl::Error> {
5540        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5541            (usage, gain_db),
5542            0x779b1531dc9e64f4,
5543            fidl::encoding::DynamicFlags::FLEXIBLE,
5544        )
5545    }
5546
5547    fn r#set_capture_usage_gain(
5548        &self,
5549        mut usage: AudioCaptureUsage,
5550        mut gain_db: f32,
5551    ) -> Result<(), fidl::Error> {
5552        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5553            (usage, gain_db),
5554            0x457d29217d4ea248,
5555            fidl::encoding::DynamicFlags::empty(),
5556        )
5557    }
5558
5559    fn r#set_capture_usage_gain2(
5560        &self,
5561        mut usage: AudioCaptureUsage2,
5562        mut gain_db: f32,
5563    ) -> Result<(), fidl::Error> {
5564        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5565            (usage, gain_db),
5566            0x15065ee308f44af0,
5567            fidl::encoding::DynamicFlags::FLEXIBLE,
5568        )
5569    }
5570
5571    fn r#bind_usage_volume_control(
5572        &self,
5573        mut usage: &Usage,
5574        mut volume_control: fidl::endpoints::ServerEnd<
5575            fidl_fuchsia_media_audio::VolumeControlMarker,
5576        >,
5577    ) -> Result<(), fidl::Error> {
5578        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5579            (usage, volume_control),
5580            0x7225be116aadc137,
5581            fidl::encoding::DynamicFlags::empty(),
5582        )
5583    }
5584
5585    fn r#bind_usage_volume_control2(
5586        &self,
5587        mut usage: &Usage2,
5588        mut volume_control: fidl::endpoints::ServerEnd<
5589            fidl_fuchsia_media_audio::VolumeControlMarker,
5590        >,
5591    ) -> Result<(), fidl::Error> {
5592        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5593            (usage, volume_control),
5594            0x729dff93019d055,
5595            fidl::encoding::DynamicFlags::FLEXIBLE,
5596        )
5597    }
5598
5599    type GetVolumeFromDbResponseFut =
5600        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5601    fn r#get_volume_from_db(
5602        &self,
5603        mut usage: &Usage,
5604        mut gain_db: f32,
5605    ) -> Self::GetVolumeFromDbResponseFut {
5606        fn _decode(
5607            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5608        ) -> Result<f32, fidl::Error> {
5609            let _response = fidl::client::decode_transaction_body::<
5610                AudioCoreGetVolumeFromDbResponse,
5611                fidl::encoding::DefaultFuchsiaResourceDialect,
5612                0x50e3ca45509770bf,
5613            >(_buf?)?;
5614            Ok(_response.volume)
5615        }
5616        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5617            (usage, gain_db),
5618            0x50e3ca45509770bf,
5619            fidl::encoding::DynamicFlags::empty(),
5620            _decode,
5621        )
5622    }
5623
5624    type GetVolumeFromDb2ResponseFut =
5625        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5626    fn r#get_volume_from_db2(
5627        &self,
5628        mut usage: &Usage2,
5629        mut gain_db: f32,
5630    ) -> Self::GetVolumeFromDb2ResponseFut {
5631        fn _decode(
5632            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5633        ) -> Result<f32, fidl::Error> {
5634            let _response = fidl::client::decode_transaction_body::<
5635                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5636                fidl::encoding::DefaultFuchsiaResourceDialect,
5637                0x165c811091ef99da,
5638            >(_buf?)?
5639            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5640            Ok(_response.volume)
5641        }
5642        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5643            (usage, gain_db),
5644            0x165c811091ef99da,
5645            fidl::encoding::DynamicFlags::FLEXIBLE,
5646            _decode,
5647        )
5648    }
5649
5650    type GetDbFromVolumeResponseFut =
5651        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5652    fn r#get_db_from_volume(
5653        &self,
5654        mut usage: &Usage,
5655        mut volume: f32,
5656    ) -> Self::GetDbFromVolumeResponseFut {
5657        fn _decode(
5658            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5659        ) -> Result<f32, fidl::Error> {
5660            let _response = fidl::client::decode_transaction_body::<
5661                AudioCoreGetDbFromVolumeResponse,
5662                fidl::encoding::DefaultFuchsiaResourceDialect,
5663                0x3e8eec27dd5a8bda,
5664            >(_buf?)?;
5665            Ok(_response.gain_db)
5666        }
5667        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5668            (usage, volume),
5669            0x3e8eec27dd5a8bda,
5670            fidl::encoding::DynamicFlags::empty(),
5671            _decode,
5672        )
5673    }
5674
5675    type GetDbFromVolume2ResponseFut =
5676        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5677    fn r#get_db_from_volume2(
5678        &self,
5679        mut usage: &Usage2,
5680        mut volume: f32,
5681    ) -> Self::GetDbFromVolume2ResponseFut {
5682        fn _decode(
5683            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5684        ) -> Result<f32, fidl::Error> {
5685            let _response = fidl::client::decode_transaction_body::<
5686                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5687                fidl::encoding::DefaultFuchsiaResourceDialect,
5688                0x5f421a8ebf265bf3,
5689            >(_buf?)?
5690            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5691            Ok(_response.gain_db)
5692        }
5693        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
5694            (usage, volume),
5695            0x5f421a8ebf265bf3,
5696            fidl::encoding::DynamicFlags::FLEXIBLE,
5697            _decode,
5698        )
5699    }
5700
5701    fn r#set_interaction(
5702        &self,
5703        mut active: &Usage,
5704        mut affected: &Usage,
5705        mut behavior: Behavior,
5706    ) -> Result<(), fidl::Error> {
5707        self.client.send::<AudioCoreSetInteractionRequest>(
5708            (active, affected, behavior),
5709            0x7bfed14345ece7b7,
5710            fidl::encoding::DynamicFlags::empty(),
5711        )
5712    }
5713
5714    fn r#set_interaction2(
5715        &self,
5716        mut active: &Usage2,
5717        mut affected: &Usage2,
5718        mut behavior: Behavior,
5719    ) -> Result<(), fidl::Error> {
5720        self.client.send::<AudioCoreSetInteraction2Request>(
5721            (active, affected, behavior),
5722            0x7226c7c6e6edc62f,
5723            fidl::encoding::DynamicFlags::FLEXIBLE,
5724        )
5725    }
5726
5727    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5728        self.client.send::<fidl::encoding::EmptyPayload>(
5729            (),
5730            0x65bd94d9d0a28b5e,
5731            fidl::encoding::DynamicFlags::empty(),
5732        )
5733    }
5734
5735    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5736        self.client.send::<fidl::encoding::EmptyPayload>(
5737            (),
5738            0x54a0bebca85f6b31,
5739            fidl::encoding::DynamicFlags::empty(),
5740        )
5741    }
5742}
5743
5744pub struct AudioCoreEventStream {
5745    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5746}
5747
5748impl std::marker::Unpin for AudioCoreEventStream {}
5749
5750impl futures::stream::FusedStream for AudioCoreEventStream {
5751    fn is_terminated(&self) -> bool {
5752        self.event_receiver.is_terminated()
5753    }
5754}
5755
5756impl futures::Stream for AudioCoreEventStream {
5757    type Item = Result<AudioCoreEvent, fidl::Error>;
5758
5759    fn poll_next(
5760        mut self: std::pin::Pin<&mut Self>,
5761        cx: &mut std::task::Context<'_>,
5762    ) -> std::task::Poll<Option<Self::Item>> {
5763        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5764            &mut self.event_receiver,
5765            cx
5766        )?) {
5767            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
5768            None => std::task::Poll::Ready(None),
5769        }
5770    }
5771}
5772
5773#[derive(Debug)]
5774pub enum AudioCoreEvent {
5775    #[non_exhaustive]
5776    _UnknownEvent {
5777        /// Ordinal of the event that was sent.
5778        ordinal: u64,
5779    },
5780}
5781
5782impl AudioCoreEvent {
5783    /// Decodes a message buffer as a [`AudioCoreEvent`].
5784    fn decode(
5785        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5786    ) -> Result<AudioCoreEvent, fidl::Error> {
5787        let (bytes, _handles) = buf.split_mut();
5788        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5789        debug_assert_eq!(tx_header.tx_id, 0);
5790        match tx_header.ordinal {
5791            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5792                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5793            }
5794            _ => Err(fidl::Error::UnknownOrdinal {
5795                ordinal: tx_header.ordinal,
5796                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5797            }),
5798        }
5799    }
5800}
5801
5802/// A Stream of incoming requests for fuchsia.media/AudioCore.
5803pub struct AudioCoreRequestStream {
5804    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5805    is_terminated: bool,
5806}
5807
5808impl std::marker::Unpin for AudioCoreRequestStream {}
5809
5810impl futures::stream::FusedStream for AudioCoreRequestStream {
5811    fn is_terminated(&self) -> bool {
5812        self.is_terminated
5813    }
5814}
5815
5816impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
5817    type Protocol = AudioCoreMarker;
5818    type ControlHandle = AudioCoreControlHandle;
5819
5820    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5821        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5822    }
5823
5824    fn control_handle(&self) -> Self::ControlHandle {
5825        AudioCoreControlHandle { inner: self.inner.clone() }
5826    }
5827
5828    fn into_inner(
5829        self,
5830    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5831    {
5832        (self.inner, self.is_terminated)
5833    }
5834
5835    fn from_inner(
5836        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5837        is_terminated: bool,
5838    ) -> Self {
5839        Self { inner, is_terminated }
5840    }
5841}
5842
5843impl futures::Stream for AudioCoreRequestStream {
5844    type Item = Result<AudioCoreRequest, fidl::Error>;
5845
5846    fn poll_next(
5847        mut self: std::pin::Pin<&mut Self>,
5848        cx: &mut std::task::Context<'_>,
5849    ) -> std::task::Poll<Option<Self::Item>> {
5850        let this = &mut *self;
5851        if this.inner.check_shutdown(cx) {
5852            this.is_terminated = true;
5853            return std::task::Poll::Ready(None);
5854        }
5855        if this.is_terminated {
5856            panic!("polled AudioCoreRequestStream after completion");
5857        }
5858        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5859            |bytes, handles| {
5860                match this.inner.channel().read_etc(cx, bytes, handles) {
5861                    std::task::Poll::Ready(Ok(())) => {}
5862                    std::task::Poll::Pending => return std::task::Poll::Pending,
5863                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5864                        this.is_terminated = true;
5865                        return std::task::Poll::Ready(None);
5866                    }
5867                    std::task::Poll::Ready(Err(e)) => {
5868                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5869                            e.into(),
5870                        ))));
5871                    }
5872                }
5873
5874                // A message has been received from the channel
5875                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5876
5877                std::task::Poll::Ready(Some(match header.ordinal {
5878                    0x2ac9beba47f83435 => {
5879                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5880                        let mut req = fidl::new_empty!(
5881                            AudioCoreCreateAudioRendererRequest,
5882                            fidl::encoding::DefaultFuchsiaResourceDialect
5883                        );
5884                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5885                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5886                        Ok(AudioCoreRequest::CreateAudioRenderer {
5887                            audio_out_request: req.audio_out_request,
5888
5889                            control_handle,
5890                        })
5891                    }
5892                    0x459de383b0d76d97 => {
5893                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5894                        let mut req = fidl::new_empty!(
5895                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5896                            fidl::encoding::DefaultFuchsiaResourceDialect
5897                        );
5898                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5899                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5900                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5901                            stream_type: req.stream_type,
5902                            configuration: req.configuration,
5903                            audio_capturer_request: req.audio_capturer_request,
5904
5905                            control_handle,
5906                        })
5907                    }
5908                    0x787db169df99aed0 => {
5909                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5910                        let mut req = fidl::new_empty!(
5911                            AudioCoreCreateAudioCapturerRequest,
5912                            fidl::encoding::DefaultFuchsiaResourceDialect
5913                        );
5914                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5915                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5916                        Ok(AudioCoreRequest::CreateAudioCapturer {
5917                            loopback: req.loopback,
5918                            audio_in_request: req.audio_in_request,
5919
5920                            control_handle,
5921                        })
5922                    }
5923                    0x48097f45f6e2b8e7 => {
5924                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5925                        let mut req = fidl::new_empty!(
5926                            AudioCoreSetRenderUsageGainRequest,
5927                            fidl::encoding::DefaultFuchsiaResourceDialect
5928                        );
5929                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5930                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5931                        Ok(AudioCoreRequest::SetRenderUsageGain {
5932                            usage: req.usage,
5933                            gain_db: req.gain_db,
5934
5935                            control_handle,
5936                        })
5937                    }
5938                    0x779b1531dc9e64f4 => {
5939                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5940                        let mut req = fidl::new_empty!(
5941                            AudioCoreSetRenderUsageGain2Request,
5942                            fidl::encoding::DefaultFuchsiaResourceDialect
5943                        );
5944                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5945                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5946                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5947                            usage: req.usage,
5948                            gain_db: req.gain_db,
5949
5950                            control_handle,
5951                        })
5952                    }
5953                    0x457d29217d4ea248 => {
5954                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5955                        let mut req = fidl::new_empty!(
5956                            AudioCoreSetCaptureUsageGainRequest,
5957                            fidl::encoding::DefaultFuchsiaResourceDialect
5958                        );
5959                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5960                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5961                        Ok(AudioCoreRequest::SetCaptureUsageGain {
5962                            usage: req.usage,
5963                            gain_db: req.gain_db,
5964
5965                            control_handle,
5966                        })
5967                    }
5968                    0x15065ee308f44af0 => {
5969                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5970                        let mut req = fidl::new_empty!(
5971                            AudioCoreSetCaptureUsageGain2Request,
5972                            fidl::encoding::DefaultFuchsiaResourceDialect
5973                        );
5974                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5975                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5976                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
5977                            usage: req.usage,
5978                            gain_db: req.gain_db,
5979
5980                            control_handle,
5981                        })
5982                    }
5983                    0x7225be116aadc137 => {
5984                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5985                        let mut req = fidl::new_empty!(
5986                            AudioCoreBindUsageVolumeControlRequest,
5987                            fidl::encoding::DefaultFuchsiaResourceDialect
5988                        );
5989                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
5990                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5991                        Ok(AudioCoreRequest::BindUsageVolumeControl {
5992                            usage: req.usage,
5993                            volume_control: req.volume_control,
5994
5995                            control_handle,
5996                        })
5997                    }
5998                    0x729dff93019d055 => {
5999                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6000                        let mut req = fidl::new_empty!(
6001                            AudioCoreBindUsageVolumeControl2Request,
6002                            fidl::encoding::DefaultFuchsiaResourceDialect
6003                        );
6004                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6005                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6006                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6007                            usage: req.usage,
6008                            volume_control: req.volume_control,
6009
6010                            control_handle,
6011                        })
6012                    }
6013                    0x50e3ca45509770bf => {
6014                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6015                        let mut req = fidl::new_empty!(
6016                            AudioCoreGetVolumeFromDbRequest,
6017                            fidl::encoding::DefaultFuchsiaResourceDialect
6018                        );
6019                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6020                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6021                        Ok(AudioCoreRequest::GetVolumeFromDb {
6022                            usage: req.usage,
6023                            gain_db: req.gain_db,
6024
6025                            responder: AudioCoreGetVolumeFromDbResponder {
6026                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6027                                tx_id: header.tx_id,
6028                            },
6029                        })
6030                    }
6031                    0x165c811091ef99da => {
6032                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6033                        let mut req = fidl::new_empty!(
6034                            AudioCoreGetVolumeFromDb2Request,
6035                            fidl::encoding::DefaultFuchsiaResourceDialect
6036                        );
6037                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6038                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6039                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6040                            usage: req.usage,
6041                            gain_db: req.gain_db,
6042
6043                            responder: AudioCoreGetVolumeFromDb2Responder {
6044                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6045                                tx_id: header.tx_id,
6046                            },
6047                        })
6048                    }
6049                    0x3e8eec27dd5a8bda => {
6050                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6051                        let mut req = fidl::new_empty!(
6052                            AudioCoreGetDbFromVolumeRequest,
6053                            fidl::encoding::DefaultFuchsiaResourceDialect
6054                        );
6055                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6056                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6057                        Ok(AudioCoreRequest::GetDbFromVolume {
6058                            usage: req.usage,
6059                            volume: req.volume,
6060
6061                            responder: AudioCoreGetDbFromVolumeResponder {
6062                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6063                                tx_id: header.tx_id,
6064                            },
6065                        })
6066                    }
6067                    0x5f421a8ebf265bf3 => {
6068                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6069                        let mut req = fidl::new_empty!(
6070                            AudioCoreGetDbFromVolume2Request,
6071                            fidl::encoding::DefaultFuchsiaResourceDialect
6072                        );
6073                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6074                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6075                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6076                            usage: req.usage,
6077                            volume: req.volume,
6078
6079                            responder: AudioCoreGetDbFromVolume2Responder {
6080                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6081                                tx_id: header.tx_id,
6082                            },
6083                        })
6084                    }
6085                    0x7bfed14345ece7b7 => {
6086                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6087                        let mut req = fidl::new_empty!(
6088                            AudioCoreSetInteractionRequest,
6089                            fidl::encoding::DefaultFuchsiaResourceDialect
6090                        );
6091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6092                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6093                        Ok(AudioCoreRequest::SetInteraction {
6094                            active: req.active,
6095                            affected: req.affected,
6096                            behavior: req.behavior,
6097
6098                            control_handle,
6099                        })
6100                    }
6101                    0x7226c7c6e6edc62f => {
6102                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6103                        let mut req = fidl::new_empty!(
6104                            AudioCoreSetInteraction2Request,
6105                            fidl::encoding::DefaultFuchsiaResourceDialect
6106                        );
6107                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6108                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6109                        Ok(AudioCoreRequest::SetInteraction2 {
6110                            active: req.active,
6111                            affected: req.affected,
6112                            behavior: req.behavior,
6113
6114                            control_handle,
6115                        })
6116                    }
6117                    0x65bd94d9d0a28b5e => {
6118                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6119                        let mut req = fidl::new_empty!(
6120                            fidl::encoding::EmptyPayload,
6121                            fidl::encoding::DefaultFuchsiaResourceDialect
6122                        );
6123                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6124                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6125                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6126                    }
6127                    0x54a0bebca85f6b31 => {
6128                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6129                        let mut req = fidl::new_empty!(
6130                            fidl::encoding::EmptyPayload,
6131                            fidl::encoding::DefaultFuchsiaResourceDialect
6132                        );
6133                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6134                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6135                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6136                    }
6137                    _ if header.tx_id == 0
6138                        && header
6139                            .dynamic_flags()
6140                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6141                    {
6142                        Ok(AudioCoreRequest::_UnknownMethod {
6143                            ordinal: header.ordinal,
6144                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6145                            method_type: fidl::MethodType::OneWay,
6146                        })
6147                    }
6148                    _ if header
6149                        .dynamic_flags()
6150                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6151                    {
6152                        this.inner.send_framework_err(
6153                            fidl::encoding::FrameworkErr::UnknownMethod,
6154                            header.tx_id,
6155                            header.ordinal,
6156                            header.dynamic_flags(),
6157                            (bytes, handles),
6158                        )?;
6159                        Ok(AudioCoreRequest::_UnknownMethod {
6160                            ordinal: header.ordinal,
6161                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6162                            method_type: fidl::MethodType::TwoWay,
6163                        })
6164                    }
6165                    _ => Err(fidl::Error::UnknownOrdinal {
6166                        ordinal: header.ordinal,
6167                        protocol_name:
6168                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6169                    }),
6170                }))
6171            },
6172        )
6173    }
6174}
6175
6176#[derive(Debug)]
6177pub enum AudioCoreRequest {
6178    /// Creates an AudioRenderer which outputs audio to the default device.
6179    CreateAudioRenderer {
6180        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6181        control_handle: AudioCoreControlHandle,
6182    },
6183    /// Creates an AudioCapturer according to the given requirements.
6184    ///
6185    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6186    /// It causes the source material to be reformatted/resampled if needed
6187    /// in order to produce the requested stream type.
6188    ///
6189    /// `usage` is used by Fuchsia to make decisions about user experience.
6190    /// See `AudioCaptureUsage` for more details.
6191    ///
6192    /// `configuration` must be initialized to a variant, or no capturer
6193    /// can be created.
6194    CreateAudioCapturerWithConfiguration {
6195        stream_type: AudioStreamType,
6196        configuration: AudioCapturerConfiguration,
6197        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6198        control_handle: AudioCoreControlHandle,
6199    },
6200    /// Creates an AudioCapturer which either captures from the current default
6201    /// audio input device, or loops-back from the current default audio output
6202    /// device based on value passed for the loopback flag.
6203    CreateAudioCapturer {
6204        loopback: bool,
6205        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6206        control_handle: AudioCoreControlHandle,
6207    },
6208    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6209    SetRenderUsageGain {
6210        usage: AudioRenderUsage,
6211        gain_db: f32,
6212        control_handle: AudioCoreControlHandle,
6213    },
6214    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6215    SetRenderUsageGain2 {
6216        usage: AudioRenderUsage2,
6217        gain_db: f32,
6218        control_handle: AudioCoreControlHandle,
6219    },
6220    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6221    SetCaptureUsageGain {
6222        usage: AudioCaptureUsage,
6223        gain_db: f32,
6224        control_handle: AudioCoreControlHandle,
6225    },
6226    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6227    SetCaptureUsageGain2 {
6228        usage: AudioCaptureUsage2,
6229        gain_db: f32,
6230        control_handle: AudioCoreControlHandle,
6231    },
6232    /// Binds to a volume control protocol for the given usage.
6233    BindUsageVolumeControl {
6234        usage: Usage,
6235        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6236        control_handle: AudioCoreControlHandle,
6237    },
6238    /// Binds to a volume control protocol for the given usage.
6239    BindUsageVolumeControl2 {
6240        usage: Usage2,
6241        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6242        control_handle: AudioCoreControlHandle,
6243    },
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    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
6248    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6249    /// `usage`. This is the same mapping as used by the VolumeControl from
6250    /// `BindUsageVolumeControl`.
6251    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
6252    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6253    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6254    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
6255    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6256    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6257    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
6258    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6259    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6260    /// the Behavior specified will be applied to the streams of Usage `affected`.
6261    SetInteraction {
6262        active: Usage,
6263        affected: Usage,
6264        behavior: Behavior,
6265        control_handle: AudioCoreControlHandle,
6266    },
6267    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6268    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6269    /// the Behavior specified will be applied to the streams of Usage `affected`.
6270    SetInteraction2 {
6271        active: Usage2,
6272        affected: Usage2,
6273        behavior: Behavior,
6274        control_handle: AudioCoreControlHandle,
6275    },
6276    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6277    /// audio_core. The default behavior is 'NONE'.
6278    ResetInteractions { control_handle: AudioCoreControlHandle },
6279    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6280    /// does not provide a config.
6281    LoadDefaults { control_handle: AudioCoreControlHandle },
6282    /// An interaction was received which does not match any known method.
6283    #[non_exhaustive]
6284    _UnknownMethod {
6285        /// Ordinal of the method that was called.
6286        ordinal: u64,
6287        control_handle: AudioCoreControlHandle,
6288        method_type: fidl::MethodType,
6289    },
6290}
6291
6292impl AudioCoreRequest {
6293    #[allow(irrefutable_let_patterns)]
6294    pub fn into_create_audio_renderer(
6295        self,
6296    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6297        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6298            Some((audio_out_request, control_handle))
6299        } else {
6300            None
6301        }
6302    }
6303
6304    #[allow(irrefutable_let_patterns)]
6305    pub fn into_create_audio_capturer_with_configuration(
6306        self,
6307    ) -> Option<(
6308        AudioStreamType,
6309        AudioCapturerConfiguration,
6310        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6311        AudioCoreControlHandle,
6312    )> {
6313        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6314            stream_type,
6315            configuration,
6316            audio_capturer_request,
6317            control_handle,
6318        } = self
6319        {
6320            Some((stream_type, configuration, audio_capturer_request, control_handle))
6321        } else {
6322            None
6323        }
6324    }
6325
6326    #[allow(irrefutable_let_patterns)]
6327    pub fn into_create_audio_capturer(
6328        self,
6329    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6330    {
6331        if let AudioCoreRequest::CreateAudioCapturer {
6332            loopback,
6333            audio_in_request,
6334            control_handle,
6335        } = self
6336        {
6337            Some((loopback, audio_in_request, control_handle))
6338        } else {
6339            None
6340        }
6341    }
6342
6343    #[allow(irrefutable_let_patterns)]
6344    pub fn into_set_render_usage_gain(
6345        self,
6346    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6347        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6348            Some((usage, gain_db, control_handle))
6349        } else {
6350            None
6351        }
6352    }
6353
6354    #[allow(irrefutable_let_patterns)]
6355    pub fn into_set_render_usage_gain2(
6356        self,
6357    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6358        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6359            Some((usage, gain_db, control_handle))
6360        } else {
6361            None
6362        }
6363    }
6364
6365    #[allow(irrefutable_let_patterns)]
6366    pub fn into_set_capture_usage_gain(
6367        self,
6368    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6369        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6370            Some((usage, gain_db, control_handle))
6371        } else {
6372            None
6373        }
6374    }
6375
6376    #[allow(irrefutable_let_patterns)]
6377    pub fn into_set_capture_usage_gain2(
6378        self,
6379    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6380        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6381            Some((usage, gain_db, control_handle))
6382        } else {
6383            None
6384        }
6385    }
6386
6387    #[allow(irrefutable_let_patterns)]
6388    pub fn into_bind_usage_volume_control(
6389        self,
6390    ) -> Option<(
6391        Usage,
6392        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6393        AudioCoreControlHandle,
6394    )> {
6395        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6396            self
6397        {
6398            Some((usage, volume_control, control_handle))
6399        } else {
6400            None
6401        }
6402    }
6403
6404    #[allow(irrefutable_let_patterns)]
6405    pub fn into_bind_usage_volume_control2(
6406        self,
6407    ) -> Option<(
6408        Usage2,
6409        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6410        AudioCoreControlHandle,
6411    )> {
6412        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6413            self
6414        {
6415            Some((usage, volume_control, control_handle))
6416        } else {
6417            None
6418        }
6419    }
6420
6421    #[allow(irrefutable_let_patterns)]
6422    pub fn into_get_volume_from_db(
6423        self,
6424    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6425        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6426            Some((usage, gain_db, responder))
6427        } else {
6428            None
6429        }
6430    }
6431
6432    #[allow(irrefutable_let_patterns)]
6433    pub fn into_get_volume_from_db2(
6434        self,
6435    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6436        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6437            Some((usage, gain_db, responder))
6438        } else {
6439            None
6440        }
6441    }
6442
6443    #[allow(irrefutable_let_patterns)]
6444    pub fn into_get_db_from_volume(
6445        self,
6446    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6447        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6448            Some((usage, volume, responder))
6449        } else {
6450            None
6451        }
6452    }
6453
6454    #[allow(irrefutable_let_patterns)]
6455    pub fn into_get_db_from_volume2(
6456        self,
6457    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6458        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6459            Some((usage, volume, responder))
6460        } else {
6461            None
6462        }
6463    }
6464
6465    #[allow(irrefutable_let_patterns)]
6466    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6467        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6468            self
6469        {
6470            Some((active, affected, behavior, control_handle))
6471        } else {
6472            None
6473        }
6474    }
6475
6476    #[allow(irrefutable_let_patterns)]
6477    pub fn into_set_interaction2(
6478        self,
6479    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6480        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6481            self
6482        {
6483            Some((active, affected, behavior, control_handle))
6484        } else {
6485            None
6486        }
6487    }
6488
6489    #[allow(irrefutable_let_patterns)]
6490    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6491        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6492            Some((control_handle))
6493        } else {
6494            None
6495        }
6496    }
6497
6498    #[allow(irrefutable_let_patterns)]
6499    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6500        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6501            Some((control_handle))
6502        } else {
6503            None
6504        }
6505    }
6506
6507    /// Name of the method defined in FIDL
6508    pub fn method_name(&self) -> &'static str {
6509        match *self {
6510            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6511            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6512                "create_audio_capturer_with_configuration"
6513            }
6514            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6515            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6516            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6517            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6518            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6519            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6520            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6521            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6522            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6523            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6524            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6525            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6526            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6527            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6528            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6529            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6530                "unknown one-way method"
6531            }
6532            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6533                "unknown two-way method"
6534            }
6535        }
6536    }
6537}
6538
6539#[derive(Debug, Clone)]
6540pub struct AudioCoreControlHandle {
6541    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6542}
6543
6544impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6545    fn shutdown(&self) {
6546        self.inner.shutdown()
6547    }
6548
6549    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6550        self.inner.shutdown_with_epitaph(status)
6551    }
6552
6553    fn is_closed(&self) -> bool {
6554        self.inner.channel().is_closed()
6555    }
6556    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6557        self.inner.channel().on_closed()
6558    }
6559
6560    #[cfg(target_os = "fuchsia")]
6561    fn signal_peer(
6562        &self,
6563        clear_mask: zx::Signals,
6564        set_mask: zx::Signals,
6565    ) -> Result<(), zx_status::Status> {
6566        use fidl::Peered;
6567        self.inner.channel().signal_peer(clear_mask, set_mask)
6568    }
6569}
6570
6571impl AudioCoreControlHandle {}
6572
6573#[must_use = "FIDL methods require a response to be sent"]
6574#[derive(Debug)]
6575pub struct AudioCoreGetVolumeFromDbResponder {
6576    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6577    tx_id: u32,
6578}
6579
6580/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6581/// if the responder is dropped without sending a response, so that the client
6582/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6583impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6584    fn drop(&mut self) {
6585        self.control_handle.shutdown();
6586        // Safety: drops once, never accessed again
6587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6588    }
6589}
6590
6591impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6592    type ControlHandle = AudioCoreControlHandle;
6593
6594    fn control_handle(&self) -> &AudioCoreControlHandle {
6595        &self.control_handle
6596    }
6597
6598    fn drop_without_shutdown(mut self) {
6599        // Safety: drops once, never accessed again due to mem::forget
6600        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6601        // Prevent Drop from running (which would shut down the channel)
6602        std::mem::forget(self);
6603    }
6604}
6605
6606impl AudioCoreGetVolumeFromDbResponder {
6607    /// Sends a response to the FIDL transaction.
6608    ///
6609    /// Sets the channel to shutdown if an error occurs.
6610    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6611        let _result = self.send_raw(volume);
6612        if _result.is_err() {
6613            self.control_handle.shutdown();
6614        }
6615        self.drop_without_shutdown();
6616        _result
6617    }
6618
6619    /// Similar to "send" but does not shutdown the channel if an error occurs.
6620    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6621        let _result = self.send_raw(volume);
6622        self.drop_without_shutdown();
6623        _result
6624    }
6625
6626    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6627        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6628            (volume,),
6629            self.tx_id,
6630            0x50e3ca45509770bf,
6631            fidl::encoding::DynamicFlags::empty(),
6632        )
6633    }
6634}
6635
6636#[must_use = "FIDL methods require a response to be sent"]
6637#[derive(Debug)]
6638pub struct AudioCoreGetVolumeFromDb2Responder {
6639    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6640    tx_id: u32,
6641}
6642
6643/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6644/// if the responder is dropped without sending a response, so that the client
6645/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6646impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6647    fn drop(&mut self) {
6648        self.control_handle.shutdown();
6649        // Safety: drops once, never accessed again
6650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6651    }
6652}
6653
6654impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6655    type ControlHandle = AudioCoreControlHandle;
6656
6657    fn control_handle(&self) -> &AudioCoreControlHandle {
6658        &self.control_handle
6659    }
6660
6661    fn drop_without_shutdown(mut self) {
6662        // Safety: drops once, never accessed again due to mem::forget
6663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6664        // Prevent Drop from running (which would shut down the channel)
6665        std::mem::forget(self);
6666    }
6667}
6668
6669impl AudioCoreGetVolumeFromDb2Responder {
6670    /// Sends a response to the FIDL transaction.
6671    ///
6672    /// Sets the channel to shutdown if an error occurs.
6673    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6674        let _result = self.send_raw(volume);
6675        if _result.is_err() {
6676            self.control_handle.shutdown();
6677        }
6678        self.drop_without_shutdown();
6679        _result
6680    }
6681
6682    /// Similar to "send" but does not shutdown the channel if an error occurs.
6683    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6684        let _result = self.send_raw(volume);
6685        self.drop_without_shutdown();
6686        _result
6687    }
6688
6689    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6690        self.control_handle
6691            .inner
6692            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
6693                fidl::encoding::Flexible::new((volume,)),
6694                self.tx_id,
6695                0x165c811091ef99da,
6696                fidl::encoding::DynamicFlags::FLEXIBLE,
6697            )
6698    }
6699}
6700
6701#[must_use = "FIDL methods require a response to be sent"]
6702#[derive(Debug)]
6703pub struct AudioCoreGetDbFromVolumeResponder {
6704    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6705    tx_id: u32,
6706}
6707
6708/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6709/// if the responder is dropped without sending a response, so that the client
6710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6711impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
6712    fn drop(&mut self) {
6713        self.control_handle.shutdown();
6714        // Safety: drops once, never accessed again
6715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6716    }
6717}
6718
6719impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
6720    type ControlHandle = AudioCoreControlHandle;
6721
6722    fn control_handle(&self) -> &AudioCoreControlHandle {
6723        &self.control_handle
6724    }
6725
6726    fn drop_without_shutdown(mut self) {
6727        // Safety: drops once, never accessed again due to mem::forget
6728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6729        // Prevent Drop from running (which would shut down the channel)
6730        std::mem::forget(self);
6731    }
6732}
6733
6734impl AudioCoreGetDbFromVolumeResponder {
6735    /// Sends a response to the FIDL transaction.
6736    ///
6737    /// Sets the channel to shutdown if an error occurs.
6738    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6739        let _result = self.send_raw(gain_db);
6740        if _result.is_err() {
6741            self.control_handle.shutdown();
6742        }
6743        self.drop_without_shutdown();
6744        _result
6745    }
6746
6747    /// Similar to "send" but does not shutdown the channel if an error occurs.
6748    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6749        let _result = self.send_raw(gain_db);
6750        self.drop_without_shutdown();
6751        _result
6752    }
6753
6754    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6755        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
6756            (gain_db,),
6757            self.tx_id,
6758            0x3e8eec27dd5a8bda,
6759            fidl::encoding::DynamicFlags::empty(),
6760        )
6761    }
6762}
6763
6764#[must_use = "FIDL methods require a response to be sent"]
6765#[derive(Debug)]
6766pub struct AudioCoreGetDbFromVolume2Responder {
6767    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6768    tx_id: u32,
6769}
6770
6771/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6772/// if the responder is dropped without sending a response, so that the client
6773/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6774impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
6775    fn drop(&mut self) {
6776        self.control_handle.shutdown();
6777        // Safety: drops once, never accessed again
6778        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6779    }
6780}
6781
6782impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
6783    type ControlHandle = AudioCoreControlHandle;
6784
6785    fn control_handle(&self) -> &AudioCoreControlHandle {
6786        &self.control_handle
6787    }
6788
6789    fn drop_without_shutdown(mut self) {
6790        // Safety: drops once, never accessed again due to mem::forget
6791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6792        // Prevent Drop from running (which would shut down the channel)
6793        std::mem::forget(self);
6794    }
6795}
6796
6797impl AudioCoreGetDbFromVolume2Responder {
6798    /// Sends a response to the FIDL transaction.
6799    ///
6800    /// Sets the channel to shutdown if an error occurs.
6801    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6802        let _result = self.send_raw(gain_db);
6803        if _result.is_err() {
6804            self.control_handle.shutdown();
6805        }
6806        self.drop_without_shutdown();
6807        _result
6808    }
6809
6810    /// Similar to "send" but does not shutdown the channel if an error occurs.
6811    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
6812        let _result = self.send_raw(gain_db);
6813        self.drop_without_shutdown();
6814        _result
6815    }
6816
6817    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
6818        self.control_handle
6819            .inner
6820            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
6821                fidl::encoding::Flexible::new((gain_db,)),
6822                self.tx_id,
6823                0x5f421a8ebf265bf3,
6824                fidl::encoding::DynamicFlags::FLEXIBLE,
6825            )
6826    }
6827}
6828
6829#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6830pub struct AudioDeviceEnumeratorMarker;
6831
6832impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
6833    type Proxy = AudioDeviceEnumeratorProxy;
6834    type RequestStream = AudioDeviceEnumeratorRequestStream;
6835    #[cfg(target_os = "fuchsia")]
6836    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
6837
6838    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
6839}
6840impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
6841
6842pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
6843    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
6844        + Send;
6845    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
6846    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
6847        + Send;
6848    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
6849    fn r#set_device_gain(
6850        &self,
6851        device_token: u64,
6852        gain_info: &AudioGainInfo,
6853        valid_flags: AudioGainValidFlags,
6854    ) -> Result<(), fidl::Error>;
6855    fn r#add_device_by_channel(
6856        &self,
6857        device_name: &str,
6858        is_input: bool,
6859        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6860    ) -> Result<(), fidl::Error>;
6861}
6862#[derive(Debug)]
6863#[cfg(target_os = "fuchsia")]
6864pub struct AudioDeviceEnumeratorSynchronousProxy {
6865    client: fidl::client::sync::Client,
6866}
6867
6868#[cfg(target_os = "fuchsia")]
6869impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
6870    type Proxy = AudioDeviceEnumeratorProxy;
6871    type Protocol = AudioDeviceEnumeratorMarker;
6872
6873    fn from_channel(inner: fidl::Channel) -> Self {
6874        Self::new(inner)
6875    }
6876
6877    fn into_channel(self) -> fidl::Channel {
6878        self.client.into_channel()
6879    }
6880
6881    fn as_channel(&self) -> &fidl::Channel {
6882        self.client.as_channel()
6883    }
6884}
6885
6886#[cfg(target_os = "fuchsia")]
6887impl AudioDeviceEnumeratorSynchronousProxy {
6888    pub fn new(channel: fidl::Channel) -> Self {
6889        let protocol_name =
6890            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6891        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6892    }
6893
6894    pub fn into_channel(self) -> fidl::Channel {
6895        self.client.into_channel()
6896    }
6897
6898    /// Waits until an event arrives and returns it. It is safe for other
6899    /// threads to make concurrent requests while waiting for an event.
6900    pub fn wait_for_event(
6901        &self,
6902        deadline: zx::MonotonicInstant,
6903    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6904        AudioDeviceEnumeratorEvent::decode(self.client.wait_for_event(deadline)?)
6905    }
6906
6907    /// Obtain the list of currently active audio devices.
6908    pub fn r#get_devices(
6909        &self,
6910        ___deadline: zx::MonotonicInstant,
6911    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6912        let _response = self
6913            .client
6914            .send_query::<fidl::encoding::EmptyPayload, AudioDeviceEnumeratorGetDevicesResponse>(
6915                (),
6916                0x4ce1aa218aeb12a6,
6917                fidl::encoding::DynamicFlags::empty(),
6918                ___deadline,
6919            )?;
6920        Ok(_response.devices)
6921    }
6922
6923    /// Gain/Mute/AGC control
6924    ///
6925    /// Note that each of these operations requires a device_token in order to
6926    /// target the proper input/output.
6927    ///
6928    /// The Get command returns the device_token of the device whose gain is
6929    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6930    /// device_token was invalid or the device had been removed from the system
6931    /// before the Get command could be processed.
6932    ///
6933    /// Set commands which are given an invalid device token are ignored and
6934    /// have no effect on the system. In addition, users do not need to control
6935    /// all of the gain settings for an audio device with each call. Only the
6936    /// settings with a corresponding flag set in the set_flags parameter will
6937    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6938    /// a SetDeviceGain call to care only about the mute setting in the
6939    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6940    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6941    /// status to be changed simultaneously.
6942    pub fn r#get_device_gain(
6943        &self,
6944        mut device_token: u64,
6945        ___deadline: zx::MonotonicInstant,
6946    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
6947        let _response = self.client.send_query::<
6948            AudioDeviceEnumeratorGetDeviceGainRequest,
6949            AudioDeviceEnumeratorGetDeviceGainResponse,
6950        >(
6951            (device_token,),
6952            0x25dd4723403c414b,
6953            fidl::encoding::DynamicFlags::empty(),
6954            ___deadline,
6955        )?;
6956        Ok((_response.device_token, _response.gain_info))
6957    }
6958
6959    pub fn r#set_device_gain(
6960        &self,
6961        mut device_token: u64,
6962        mut gain_info: &AudioGainInfo,
6963        mut valid_flags: AudioGainValidFlags,
6964    ) -> Result<(), fidl::Error> {
6965        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
6966            (device_token, gain_info, valid_flags),
6967            0x5bdabc8ebe83591,
6968            fidl::encoding::DynamicFlags::empty(),
6969        )
6970    }
6971
6972    /// # Deprecation
6973    ///
6974    /// StreamConfig is not supported anymore, instead use an
6975    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6976    /// , see
6977    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6978    pub fn r#add_device_by_channel(
6979        &self,
6980        mut device_name: &str,
6981        mut is_input: bool,
6982        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
6983    ) -> Result<(), fidl::Error> {
6984        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
6985            (device_name, is_input, channel),
6986            0x72cdbada4d70ed67,
6987            fidl::encoding::DynamicFlags::empty(),
6988        )
6989    }
6990}
6991
6992#[cfg(target_os = "fuchsia")]
6993impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::NullableHandle {
6994    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
6995        value.into_channel().into()
6996    }
6997}
6998
6999#[cfg(target_os = "fuchsia")]
7000impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
7001    fn from(value: fidl::Channel) -> Self {
7002        Self::new(value)
7003    }
7004}
7005
7006#[cfg(target_os = "fuchsia")]
7007impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7008    type Protocol = AudioDeviceEnumeratorMarker;
7009
7010    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7011        Self::new(value.into_channel())
7012    }
7013}
7014
7015#[derive(Debug, Clone)]
7016pub struct AudioDeviceEnumeratorProxy {
7017    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7018}
7019
7020impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7021    type Protocol = AudioDeviceEnumeratorMarker;
7022
7023    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7024        Self::new(inner)
7025    }
7026
7027    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7028        self.client.into_channel().map_err(|client| Self { client })
7029    }
7030
7031    fn as_channel(&self) -> &::fidl::AsyncChannel {
7032        self.client.as_channel()
7033    }
7034}
7035
7036impl AudioDeviceEnumeratorProxy {
7037    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7038    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7039        let protocol_name =
7040            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7041        Self { client: fidl::client::Client::new(channel, protocol_name) }
7042    }
7043
7044    /// Get a Stream of events from the remote end of the protocol.
7045    ///
7046    /// # Panics
7047    ///
7048    /// Panics if the event stream was already taken.
7049    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7050        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7051    }
7052
7053    /// Obtain the list of currently active audio devices.
7054    pub fn r#get_devices(
7055        &self,
7056    ) -> fidl::client::QueryResponseFut<
7057        Vec<AudioDeviceInfo>,
7058        fidl::encoding::DefaultFuchsiaResourceDialect,
7059    > {
7060        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7061    }
7062
7063    /// Gain/Mute/AGC control
7064    ///
7065    /// Note that each of these operations requires a device_token in order to
7066    /// target the proper input/output.
7067    ///
7068    /// The Get command returns the device_token of the device whose gain is
7069    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7070    /// device_token was invalid or the device had been removed from the system
7071    /// before the Get command could be processed.
7072    ///
7073    /// Set commands which are given an invalid device token are ignored and
7074    /// have no effect on the system. In addition, users do not need to control
7075    /// all of the gain settings for an audio device with each call. Only the
7076    /// settings with a corresponding flag set in the set_flags parameter will
7077    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7078    /// a SetDeviceGain call to care only about the mute setting in the
7079    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7080    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7081    /// status to be changed simultaneously.
7082    pub fn r#get_device_gain(
7083        &self,
7084        mut device_token: u64,
7085    ) -> fidl::client::QueryResponseFut<
7086        (u64, AudioGainInfo),
7087        fidl::encoding::DefaultFuchsiaResourceDialect,
7088    > {
7089        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7090    }
7091
7092    pub fn r#set_device_gain(
7093        &self,
7094        mut device_token: u64,
7095        mut gain_info: &AudioGainInfo,
7096        mut valid_flags: AudioGainValidFlags,
7097    ) -> Result<(), fidl::Error> {
7098        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7099            self,
7100            device_token,
7101            gain_info,
7102            valid_flags,
7103        )
7104    }
7105
7106    /// # Deprecation
7107    ///
7108    /// StreamConfig is not supported anymore, instead use an
7109    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7110    /// , see
7111    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7112    pub fn r#add_device_by_channel(
7113        &self,
7114        mut device_name: &str,
7115        mut is_input: bool,
7116        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7117    ) -> Result<(), fidl::Error> {
7118        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7119            self,
7120            device_name,
7121            is_input,
7122            channel,
7123        )
7124    }
7125}
7126
7127impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7128    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7129        Vec<AudioDeviceInfo>,
7130        fidl::encoding::DefaultFuchsiaResourceDialect,
7131    >;
7132    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7133        fn _decode(
7134            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7135        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7136            let _response = fidl::client::decode_transaction_body::<
7137                AudioDeviceEnumeratorGetDevicesResponse,
7138                fidl::encoding::DefaultFuchsiaResourceDialect,
7139                0x4ce1aa218aeb12a6,
7140            >(_buf?)?;
7141            Ok(_response.devices)
7142        }
7143        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7144            (),
7145            0x4ce1aa218aeb12a6,
7146            fidl::encoding::DynamicFlags::empty(),
7147            _decode,
7148        )
7149    }
7150
7151    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7152        (u64, AudioGainInfo),
7153        fidl::encoding::DefaultFuchsiaResourceDialect,
7154    >;
7155    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7156        fn _decode(
7157            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7158        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7159            let _response = fidl::client::decode_transaction_body::<
7160                AudioDeviceEnumeratorGetDeviceGainResponse,
7161                fidl::encoding::DefaultFuchsiaResourceDialect,
7162                0x25dd4723403c414b,
7163            >(_buf?)?;
7164            Ok((_response.device_token, _response.gain_info))
7165        }
7166        self.client.send_query_and_decode::<
7167            AudioDeviceEnumeratorGetDeviceGainRequest,
7168            (u64, AudioGainInfo),
7169        >(
7170            (device_token,),
7171            0x25dd4723403c414b,
7172            fidl::encoding::DynamicFlags::empty(),
7173            _decode,
7174        )
7175    }
7176
7177    fn r#set_device_gain(
7178        &self,
7179        mut device_token: u64,
7180        mut gain_info: &AudioGainInfo,
7181        mut valid_flags: AudioGainValidFlags,
7182    ) -> Result<(), fidl::Error> {
7183        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7184            (device_token, gain_info, valid_flags),
7185            0x5bdabc8ebe83591,
7186            fidl::encoding::DynamicFlags::empty(),
7187        )
7188    }
7189
7190    fn r#add_device_by_channel(
7191        &self,
7192        mut device_name: &str,
7193        mut is_input: bool,
7194        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7195    ) -> Result<(), fidl::Error> {
7196        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7197            (device_name, is_input, channel),
7198            0x72cdbada4d70ed67,
7199            fidl::encoding::DynamicFlags::empty(),
7200        )
7201    }
7202}
7203
7204pub struct AudioDeviceEnumeratorEventStream {
7205    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7206}
7207
7208impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7209
7210impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7211    fn is_terminated(&self) -> bool {
7212        self.event_receiver.is_terminated()
7213    }
7214}
7215
7216impl futures::Stream for AudioDeviceEnumeratorEventStream {
7217    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7218
7219    fn poll_next(
7220        mut self: std::pin::Pin<&mut Self>,
7221        cx: &mut std::task::Context<'_>,
7222    ) -> std::task::Poll<Option<Self::Item>> {
7223        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7224            &mut self.event_receiver,
7225            cx
7226        )?) {
7227            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7228            None => std::task::Poll::Ready(None),
7229        }
7230    }
7231}
7232
7233#[derive(Debug)]
7234pub enum AudioDeviceEnumeratorEvent {
7235    OnDeviceAdded { device: AudioDeviceInfo },
7236    OnDeviceRemoved { device_token: u64 },
7237    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7238    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7239}
7240
7241impl AudioDeviceEnumeratorEvent {
7242    #[allow(irrefutable_let_patterns)]
7243    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7244        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7245            Some((device))
7246        } else {
7247            None
7248        }
7249    }
7250    #[allow(irrefutable_let_patterns)]
7251    pub fn into_on_device_removed(self) -> Option<u64> {
7252        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7253            Some((device_token))
7254        } else {
7255            None
7256        }
7257    }
7258    #[allow(irrefutable_let_patterns)]
7259    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7260        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7261            Some((device_token, gain_info))
7262        } else {
7263            None
7264        }
7265    }
7266    #[allow(irrefutable_let_patterns)]
7267    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7268        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7269            old_default_token,
7270            new_default_token,
7271        } = self
7272        {
7273            Some((old_default_token, new_default_token))
7274        } else {
7275            None
7276        }
7277    }
7278
7279    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7280    fn decode(
7281        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7282    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7283        let (bytes, _handles) = buf.split_mut();
7284        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7285        debug_assert_eq!(tx_header.tx_id, 0);
7286        match tx_header.ordinal {
7287            0xe0fbe40057c4b44 => {
7288                let mut out = fidl::new_empty!(
7289                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7290                    fidl::encoding::DefaultFuchsiaResourceDialect
7291                );
7292                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7293                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7294            }
7295            0x6f3b7574463d9ff8 => {
7296                let mut out = fidl::new_empty!(
7297                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7298                    fidl::encoding::DefaultFuchsiaResourceDialect
7299                );
7300                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7301                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7302            }
7303            0x14aefcbbb076b0e9 => {
7304                let mut out = fidl::new_empty!(
7305                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7306                    fidl::encoding::DefaultFuchsiaResourceDialect
7307                );
7308                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7309                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7310                    device_token: out.device_token,
7311                    gain_info: out.gain_info,
7312                }))
7313            }
7314            0x16357b42d4c16e11 => {
7315                let mut out = fidl::new_empty!(
7316                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7317                    fidl::encoding::DefaultFuchsiaResourceDialect
7318                );
7319                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7320                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7321                    old_default_token: out.old_default_token,
7322                    new_default_token: out.new_default_token,
7323                }))
7324            }
7325            _ => Err(fidl::Error::UnknownOrdinal {
7326                ordinal: tx_header.ordinal,
7327                protocol_name:
7328                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7329            }),
7330        }
7331    }
7332}
7333
7334/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7335pub struct AudioDeviceEnumeratorRequestStream {
7336    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7337    is_terminated: bool,
7338}
7339
7340impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7341
7342impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7343    fn is_terminated(&self) -> bool {
7344        self.is_terminated
7345    }
7346}
7347
7348impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7349    type Protocol = AudioDeviceEnumeratorMarker;
7350    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7351
7352    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7353        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7354    }
7355
7356    fn control_handle(&self) -> Self::ControlHandle {
7357        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7358    }
7359
7360    fn into_inner(
7361        self,
7362    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7363    {
7364        (self.inner, self.is_terminated)
7365    }
7366
7367    fn from_inner(
7368        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7369        is_terminated: bool,
7370    ) -> Self {
7371        Self { inner, is_terminated }
7372    }
7373}
7374
7375impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7376    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7377
7378    fn poll_next(
7379        mut self: std::pin::Pin<&mut Self>,
7380        cx: &mut std::task::Context<'_>,
7381    ) -> std::task::Poll<Option<Self::Item>> {
7382        let this = &mut *self;
7383        if this.inner.check_shutdown(cx) {
7384            this.is_terminated = true;
7385            return std::task::Poll::Ready(None);
7386        }
7387        if this.is_terminated {
7388            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7389        }
7390        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7391            |bytes, handles| {
7392                match this.inner.channel().read_etc(cx, bytes, handles) {
7393                    std::task::Poll::Ready(Ok(())) => {}
7394                    std::task::Poll::Pending => return std::task::Poll::Pending,
7395                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7396                        this.is_terminated = true;
7397                        return std::task::Poll::Ready(None);
7398                    }
7399                    std::task::Poll::Ready(Err(e)) => {
7400                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7401                            e.into(),
7402                        ))));
7403                    }
7404                }
7405
7406                // A message has been received from the channel
7407                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7408
7409                std::task::Poll::Ready(Some(match header.ordinal {
7410                0x4ce1aa218aeb12a6 => {
7411                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7412                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7413                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7414                    let control_handle = AudioDeviceEnumeratorControlHandle {
7415                        inner: this.inner.clone(),
7416                    };
7417                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7418                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7419                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7420                            tx_id: header.tx_id,
7421                        },
7422                    })
7423                }
7424                0x25dd4723403c414b => {
7425                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7426                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7427                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7428                    let control_handle = AudioDeviceEnumeratorControlHandle {
7429                        inner: this.inner.clone(),
7430                    };
7431                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7432
7433                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7434                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7435                            tx_id: header.tx_id,
7436                        },
7437                    })
7438                }
7439                0x5bdabc8ebe83591 => {
7440                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7441                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7442                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7443                    let control_handle = AudioDeviceEnumeratorControlHandle {
7444                        inner: this.inner.clone(),
7445                    };
7446                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7447gain_info: req.gain_info,
7448valid_flags: req.valid_flags,
7449
7450                        control_handle,
7451                    })
7452                }
7453                0x72cdbada4d70ed67 => {
7454                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7455                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7456                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7457                    let control_handle = AudioDeviceEnumeratorControlHandle {
7458                        inner: this.inner.clone(),
7459                    };
7460                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7461is_input: req.is_input,
7462channel: req.channel,
7463
7464                        control_handle,
7465                    })
7466                }
7467                _ => Err(fidl::Error::UnknownOrdinal {
7468                    ordinal: header.ordinal,
7469                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7470                }),
7471            }))
7472            },
7473        )
7474    }
7475}
7476
7477#[derive(Debug)]
7478pub enum AudioDeviceEnumeratorRequest {
7479    /// Obtain the list of currently active audio devices.
7480    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7481    /// Gain/Mute/AGC control
7482    ///
7483    /// Note that each of these operations requires a device_token in order to
7484    /// target the proper input/output.
7485    ///
7486    /// The Get command returns the device_token of the device whose gain is
7487    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7488    /// device_token was invalid or the device had been removed from the system
7489    /// before the Get command could be processed.
7490    ///
7491    /// Set commands which are given an invalid device token are ignored and
7492    /// have no effect on the system. In addition, users do not need to control
7493    /// all of the gain settings for an audio device with each call. Only the
7494    /// settings with a corresponding flag set in the set_flags parameter will
7495    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7496    /// a SetDeviceGain call to care only about the mute setting in the
7497    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7498    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7499    /// status to be changed simultaneously.
7500    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7501    SetDeviceGain {
7502        device_token: u64,
7503        gain_info: AudioGainInfo,
7504        valid_flags: AudioGainValidFlags,
7505        control_handle: AudioDeviceEnumeratorControlHandle,
7506    },
7507    /// # Deprecation
7508    ///
7509    /// StreamConfig is not supported anymore, instead use an
7510    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7511    /// , see
7512    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7513    AddDeviceByChannel {
7514        device_name: String,
7515        is_input: bool,
7516        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7517        control_handle: AudioDeviceEnumeratorControlHandle,
7518    },
7519}
7520
7521impl AudioDeviceEnumeratorRequest {
7522    #[allow(irrefutable_let_patterns)]
7523    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7524        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7525            Some((responder))
7526        } else {
7527            None
7528        }
7529    }
7530
7531    #[allow(irrefutable_let_patterns)]
7532    pub fn into_get_device_gain(
7533        self,
7534    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7535        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7536            Some((device_token, responder))
7537        } else {
7538            None
7539        }
7540    }
7541
7542    #[allow(irrefutable_let_patterns)]
7543    pub fn into_set_device_gain(
7544        self,
7545    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7546        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7547            device_token,
7548            gain_info,
7549            valid_flags,
7550            control_handle,
7551        } = self
7552        {
7553            Some((device_token, gain_info, valid_flags, control_handle))
7554        } else {
7555            None
7556        }
7557    }
7558
7559    #[allow(irrefutable_let_patterns)]
7560    pub fn into_add_device_by_channel(
7561        self,
7562    ) -> Option<(
7563        String,
7564        bool,
7565        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7566        AudioDeviceEnumeratorControlHandle,
7567    )> {
7568        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7569            device_name,
7570            is_input,
7571            channel,
7572            control_handle,
7573        } = self
7574        {
7575            Some((device_name, is_input, channel, control_handle))
7576        } else {
7577            None
7578        }
7579    }
7580
7581    /// Name of the method defined in FIDL
7582    pub fn method_name(&self) -> &'static str {
7583        match *self {
7584            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7585            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7586            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7587            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7588        }
7589    }
7590}
7591
7592#[derive(Debug, Clone)]
7593pub struct AudioDeviceEnumeratorControlHandle {
7594    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7595}
7596
7597impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7598    fn shutdown(&self) {
7599        self.inner.shutdown()
7600    }
7601
7602    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7603        self.inner.shutdown_with_epitaph(status)
7604    }
7605
7606    fn is_closed(&self) -> bool {
7607        self.inner.channel().is_closed()
7608    }
7609    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7610        self.inner.channel().on_closed()
7611    }
7612
7613    #[cfg(target_os = "fuchsia")]
7614    fn signal_peer(
7615        &self,
7616        clear_mask: zx::Signals,
7617        set_mask: zx::Signals,
7618    ) -> Result<(), zx_status::Status> {
7619        use fidl::Peered;
7620        self.inner.channel().signal_peer(clear_mask, set_mask)
7621    }
7622}
7623
7624impl AudioDeviceEnumeratorControlHandle {
7625    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7626        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7627            (device,),
7628            0,
7629            0xe0fbe40057c4b44,
7630            fidl::encoding::DynamicFlags::empty(),
7631        )
7632    }
7633
7634    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7635        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7636            (device_token,),
7637            0,
7638            0x6f3b7574463d9ff8,
7639            fidl::encoding::DynamicFlags::empty(),
7640        )
7641    }
7642
7643    pub fn send_on_device_gain_changed(
7644        &self,
7645        mut device_token: u64,
7646        mut gain_info: &AudioGainInfo,
7647    ) -> Result<(), fidl::Error> {
7648        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7649            (device_token, gain_info),
7650            0,
7651            0x14aefcbbb076b0e9,
7652            fidl::encoding::DynamicFlags::empty(),
7653        )
7654    }
7655
7656    pub fn send_on_default_device_changed(
7657        &self,
7658        mut old_default_token: u64,
7659        mut new_default_token: u64,
7660    ) -> Result<(), fidl::Error> {
7661        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
7662            (old_default_token, new_default_token),
7663            0,
7664            0x16357b42d4c16e11,
7665            fidl::encoding::DynamicFlags::empty(),
7666        )
7667    }
7668}
7669
7670#[must_use = "FIDL methods require a response to be sent"]
7671#[derive(Debug)]
7672pub struct AudioDeviceEnumeratorGetDevicesResponder {
7673    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7674    tx_id: u32,
7675}
7676
7677/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7678/// if the responder is dropped without sending a response, so that the client
7679/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7680impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
7681    fn drop(&mut self) {
7682        self.control_handle.shutdown();
7683        // Safety: drops once, never accessed again
7684        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7685    }
7686}
7687
7688impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
7689    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7690
7691    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7692        &self.control_handle
7693    }
7694
7695    fn drop_without_shutdown(mut self) {
7696        // Safety: drops once, never accessed again due to mem::forget
7697        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7698        // Prevent Drop from running (which would shut down the channel)
7699        std::mem::forget(self);
7700    }
7701}
7702
7703impl AudioDeviceEnumeratorGetDevicesResponder {
7704    /// Sends a response to the FIDL transaction.
7705    ///
7706    /// Sets the channel to shutdown if an error occurs.
7707    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7708        let _result = self.send_raw(devices);
7709        if _result.is_err() {
7710            self.control_handle.shutdown();
7711        }
7712        self.drop_without_shutdown();
7713        _result
7714    }
7715
7716    /// Similar to "send" but does not shutdown the channel if an error occurs.
7717    pub fn send_no_shutdown_on_err(
7718        self,
7719        mut devices: &[AudioDeviceInfo],
7720    ) -> Result<(), fidl::Error> {
7721        let _result = self.send_raw(devices);
7722        self.drop_without_shutdown();
7723        _result
7724    }
7725
7726    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
7727        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
7728            (devices,),
7729            self.tx_id,
7730            0x4ce1aa218aeb12a6,
7731            fidl::encoding::DynamicFlags::empty(),
7732        )
7733    }
7734}
7735
7736#[must_use = "FIDL methods require a response to be sent"]
7737#[derive(Debug)]
7738pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
7739    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
7740    tx_id: u32,
7741}
7742
7743/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
7744/// if the responder is dropped without sending a response, so that the client
7745/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7746impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
7747    fn drop(&mut self) {
7748        self.control_handle.shutdown();
7749        // Safety: drops once, never accessed again
7750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7751    }
7752}
7753
7754impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
7755    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7756
7757    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
7758        &self.control_handle
7759    }
7760
7761    fn drop_without_shutdown(mut self) {
7762        // Safety: drops once, never accessed again due to mem::forget
7763        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7764        // Prevent Drop from running (which would shut down the channel)
7765        std::mem::forget(self);
7766    }
7767}
7768
7769impl AudioDeviceEnumeratorGetDeviceGainResponder {
7770    /// Sends a response to the FIDL transaction.
7771    ///
7772    /// Sets the channel to shutdown if an error occurs.
7773    pub fn send(
7774        self,
7775        mut device_token: u64,
7776        mut gain_info: &AudioGainInfo,
7777    ) -> Result<(), fidl::Error> {
7778        let _result = self.send_raw(device_token, gain_info);
7779        if _result.is_err() {
7780            self.control_handle.shutdown();
7781        }
7782        self.drop_without_shutdown();
7783        _result
7784    }
7785
7786    /// Similar to "send" but does not shutdown the channel if an error occurs.
7787    pub fn send_no_shutdown_on_err(
7788        self,
7789        mut device_token: u64,
7790        mut gain_info: &AudioGainInfo,
7791    ) -> Result<(), fidl::Error> {
7792        let _result = self.send_raw(device_token, gain_info);
7793        self.drop_without_shutdown();
7794        _result
7795    }
7796
7797    fn send_raw(
7798        &self,
7799        mut device_token: u64,
7800        mut gain_info: &AudioGainInfo,
7801    ) -> Result<(), fidl::Error> {
7802        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
7803            (device_token, gain_info),
7804            self.tx_id,
7805            0x25dd4723403c414b,
7806            fidl::encoding::DynamicFlags::empty(),
7807        )
7808    }
7809}
7810
7811#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7812pub struct AudioRendererMarker;
7813
7814impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
7815    type Proxy = AudioRendererProxy;
7816    type RequestStream = AudioRendererRequestStream;
7817    #[cfg(target_os = "fuchsia")]
7818    type SynchronousProxy = AudioRendererSynchronousProxy;
7819
7820    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
7821}
7822impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
7823
7824pub trait AudioRendererProxyInterface: Send + Sync {
7825    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
7826    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
7827    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7828    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
7829    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
7830    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
7831    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7832    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
7833    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
7834    fn r#bind_gain_control(
7835        &self,
7836        gain_control_request: fidl::endpoints::ServerEnd<
7837            fidl_fuchsia_media_audio::GainControlMarker,
7838        >,
7839    ) -> Result<(), fidl::Error>;
7840    fn r#set_pts_units(
7841        &self,
7842        tick_per_second_numerator: u32,
7843        tick_per_second_denominator: u32,
7844    ) -> Result<(), fidl::Error>;
7845    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
7846    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
7847        + Send;
7848    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
7849    fn r#set_reference_clock(
7850        &self,
7851        reference_clock: Option<fidl::Clock>,
7852    ) -> Result<(), fidl::Error>;
7853    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
7854    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
7855    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
7856    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
7857    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
7858    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
7859    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7860    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
7861    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
7862    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
7863    fn r#pause(&self) -> Self::PauseResponseFut;
7864    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
7865}
7866#[derive(Debug)]
7867#[cfg(target_os = "fuchsia")]
7868pub struct AudioRendererSynchronousProxy {
7869    client: fidl::client::sync::Client,
7870}
7871
7872#[cfg(target_os = "fuchsia")]
7873impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
7874    type Proxy = AudioRendererProxy;
7875    type Protocol = AudioRendererMarker;
7876
7877    fn from_channel(inner: fidl::Channel) -> Self {
7878        Self::new(inner)
7879    }
7880
7881    fn into_channel(self) -> fidl::Channel {
7882        self.client.into_channel()
7883    }
7884
7885    fn as_channel(&self) -> &fidl::Channel {
7886        self.client.as_channel()
7887    }
7888}
7889
7890#[cfg(target_os = "fuchsia")]
7891impl AudioRendererSynchronousProxy {
7892    pub fn new(channel: fidl::Channel) -> Self {
7893        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7894        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7895    }
7896
7897    pub fn into_channel(self) -> fidl::Channel {
7898        self.client.into_channel()
7899    }
7900
7901    /// Waits until an event arrives and returns it. It is safe for other
7902    /// threads to make concurrent requests while waiting for an event.
7903    pub fn wait_for_event(
7904        &self,
7905        deadline: zx::MonotonicInstant,
7906    ) -> Result<AudioRendererEvent, fidl::Error> {
7907        AudioRendererEvent::decode(self.client.wait_for_event(deadline)?)
7908    }
7909
7910    /// Adds a payload buffer to the current buffer set associated with the
7911    /// connection. A `StreamPacket` struct reference a payload buffer in the
7912    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
7913    ///
7914    /// A buffer with ID `id` must not be in the current set when this method is
7915    /// invoked, otherwise the service will close the connection.
7916    pub fn r#add_payload_buffer(
7917        &self,
7918        mut id: u32,
7919        mut payload_buffer: fidl::Vmo,
7920    ) -> Result<(), fidl::Error> {
7921        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7922            (id, payload_buffer),
7923            0x3b3a37fc34fe5b56,
7924            fidl::encoding::DynamicFlags::empty(),
7925        )
7926    }
7927
7928    /// Removes a payload buffer from the current buffer set associated with the
7929    /// connection.
7930    ///
7931    /// A buffer with ID `id` must exist in the current set when this method is
7932    /// invoked, otherwise the service will will close the connection.
7933    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7934        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7935            (id,),
7936            0x5d1e4f74c3658262,
7937            fidl::encoding::DynamicFlags::empty(),
7938        )
7939    }
7940
7941    /// Sends a packet to the service. The response is sent when the service is
7942    /// done with the associated payload memory.
7943    ///
7944    /// `packet` must be valid for the current buffer set, otherwise the service
7945    /// will close the connection.
7946    pub fn r#send_packet(
7947        &self,
7948        mut packet: &StreamPacket,
7949        ___deadline: zx::MonotonicInstant,
7950    ) -> Result<(), fidl::Error> {
7951        let _response =
7952            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
7953                (packet,),
7954                0x67cddd607442775f,
7955                fidl::encoding::DynamicFlags::empty(),
7956                ___deadline,
7957            )?;
7958        Ok(_response)
7959    }
7960
7961    /// Sends a packet to the service. This interface doesn't define how the
7962    /// client knows when the sink is done with the associated payload memory.
7963    /// The inheriting interface must define that.
7964    ///
7965    /// `packet` must be valid for the current buffer set, otherwise the service
7966    /// will close the connection.
7967    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7968        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7969            (packet,),
7970            0x8d9b8b413ceba9d,
7971            fidl::encoding::DynamicFlags::empty(),
7972        )
7973    }
7974
7975    /// Indicates the stream has ended. The precise semantics of this method are
7976    /// determined by the inheriting interface.
7977    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
7978        self.client.send::<fidl::encoding::EmptyPayload>(
7979            (),
7980            0x6180fd6f7e793b71,
7981            fidl::encoding::DynamicFlags::empty(),
7982        )
7983    }
7984
7985    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
7986    /// and not yet released. The response is sent after all packets have been
7987    /// released.
7988    pub fn r#discard_all_packets(
7989        &self,
7990        ___deadline: zx::MonotonicInstant,
7991    ) -> Result<(), fidl::Error> {
7992        let _response =
7993            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
7994                (),
7995                0x6f4dad7af2917665,
7996                fidl::encoding::DynamicFlags::empty(),
7997                ___deadline,
7998            )?;
7999        Ok(_response)
8000    }
8001
8002    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8003    /// and not yet released.
8004    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8005        self.client.send::<fidl::encoding::EmptyPayload>(
8006            (),
8007            0x50d36d0d23081bc4,
8008            fidl::encoding::DynamicFlags::empty(),
8009        )
8010    }
8011
8012    /// Binds to the gain control for this AudioRenderer.
8013    pub fn r#bind_gain_control(
8014        &self,
8015        mut gain_control_request: fidl::endpoints::ServerEnd<
8016            fidl_fuchsia_media_audio::GainControlMarker,
8017        >,
8018    ) -> Result<(), fidl::Error> {
8019        self.client.send::<AudioRendererBindGainControlRequest>(
8020            (gain_control_request,),
8021            0x293f5c7f8fba2bdc,
8022            fidl::encoding::DynamicFlags::empty(),
8023        )
8024    }
8025
8026    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8027    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8028    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8029    pub fn r#set_pts_units(
8030        &self,
8031        mut tick_per_second_numerator: u32,
8032        mut tick_per_second_denominator: u32,
8033    ) -> Result<(), fidl::Error> {
8034        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8035            (tick_per_second_numerator, tick_per_second_denominator),
8036            0xf68cd108785a27c,
8037            fidl::encoding::DynamicFlags::empty(),
8038        )
8039    }
8040
8041    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8042    /// and expected PTS (determined using interpolation). Beyond this threshold,
8043    /// a stream is no longer considered 'continuous' by the renderer.
8044    ///
8045    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8046    /// Most users should not need to change this value from its default.
8047    ///
8048    /// Example:
8049    /// A user is playing back 48KHz audio from a container, which also contains
8050    /// video and needs to be synchronized with the audio. The timestamps are
8051    /// provided explicitly per packet by the container, and expressed in mSec
8052    /// units. This means that a single tick of the media timeline (1 mSec)
8053    /// represents exactly 48 frames of audio. The application in this scenario
8054    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8055    /// frames of audio, and each with an explicit timestamp set to the best
8056    /// possible representation of the presentation time (given this media
8057    /// clock's resolution). So, starting from zero, the timestamps would be..
8058    ///
8059    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8060    ///
8061    /// In this example, attempting to use the presentation time to compute the
8062    /// starting frame number of the audio in the packet would be wrong the
8063    /// majority of the time. The first timestamp is correct (by definition), but
8064    /// it will be 24 packets before the timestamps and frame numbers come back
8065    /// into alignment (the 24th packet would start with the 11280th audio frame
8066    /// and have a PTS of exactly 235).
8067    ///
8068    /// One way to fix this situation is to set the PTS continuity threshold
8069    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8070    /// the number of frames contained within a single tick of the media clock,
8071    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8072    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8073    /// explicitly provided PTS would be considered to be a continuation of the
8074    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8075    /// would work well.
8076    ///
8077    /// Other possible uses:
8078    /// Users who are scheduling audio explicitly, relative to a clock which has
8079    /// not been configured as the reference clock, can use this value to control
8080    /// the maximum acceptable synchronization error before a discontinuity is
8081    /// introduced. E.g., if a user is scheduling audio based on a recovered
8082    /// common media clock, and has not published that clock as the reference
8083    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8084    /// can accumulate before the AudioRenderer deliberately inserts a
8085    /// presentation discontinuity to account for the error.
8086    ///
8087    /// Users whose need to deal with a container where their timestamps may be
8088    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8089    /// something larger. This should be the maximum level of inaccuracy present
8090    /// in the container timestamps, if known. Failing that, it could be set to
8091    /// the maximum tolerable level of drift error before absolute timestamps are
8092    /// explicitly obeyed. Finally, a user could set this number to a very large
8093    /// value (86400.0 seconds, for example) to effectively cause *all*
8094    /// timestamps to be ignored after the first, thus treating all audio as
8095    /// continuous with previously delivered packets. Conversely, users who wish
8096    /// to *always* explicitly schedule their audio packets exactly may specify
8097    /// a CT of 0.
8098    ///
8099    /// Note: explicitly specifying high-frequency PTS units reduces the default
8100    /// continuity threshold accordingly. Internally, this threshold is stored as an
8101    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8102    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8103    /// For this reason, specifying PTS units with a frequency greater than 8192x
8104    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8105    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8106    pub fn r#set_pts_continuity_threshold(
8107        &self,
8108        mut threshold_seconds: f32,
8109    ) -> Result<(), fidl::Error> {
8110        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8111            (threshold_seconds,),
8112            0x2849ba571d1971ba,
8113            fidl::encoding::DynamicFlags::empty(),
8114        )
8115    }
8116
8117    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8118    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8119    pub fn r#get_reference_clock(
8120        &self,
8121        ___deadline: zx::MonotonicInstant,
8122    ) -> Result<fidl::Clock, fidl::Error> {
8123        let _response = self
8124            .client
8125            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetReferenceClockResponse>(
8126                (),
8127                0x2f7a7f011a172f7e,
8128                fidl::encoding::DynamicFlags::empty(),
8129                ___deadline,
8130            )?;
8131        Ok(_response.reference_clock)
8132    }
8133
8134    /// Sets the reference clock that controls this renderer's playback rate. If the input
8135    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8136    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8137    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8138    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8139    ///
8140    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8141    /// cannot be called a second time (even if the renderer format has not yet been set).
8142    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8143    /// diverge at some later time, they should create a clone of the monotonic clock, set
8144    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8145    pub fn r#set_reference_clock(
8146        &self,
8147        mut reference_clock: Option<fidl::Clock>,
8148    ) -> Result<(), fidl::Error> {
8149        self.client.send::<AudioRendererSetReferenceClockRequest>(
8150            (reference_clock,),
8151            0x39acd05d832b5fed,
8152            fidl::encoding::DynamicFlags::empty(),
8153        )
8154    }
8155
8156    /// Sets the usage of the render stream. This method may not be called after
8157    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8158    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8159        self.client.send::<AudioRendererSetUsageRequest>(
8160            (usage,),
8161            0x3994bd23b55a733e,
8162            fidl::encoding::DynamicFlags::empty(),
8163        )
8164    }
8165
8166    /// Sets the usage of the render stream. This method may not be called after
8167    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8168    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8169        self.client.send::<AudioRendererSetUsage2Request>(
8170            (usage2,),
8171            0x2904035c7132b103,
8172            fidl::encoding::DynamicFlags::FLEXIBLE,
8173        )
8174    }
8175
8176    /// Sets the type of the stream to be delivered by the client. Using this method implies
8177    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8178    ///
8179    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8180    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8181    /// methods such as `SendPacket`/`SendPacketNoReply`.
8182    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8183        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8184            (type_,),
8185            0x27aa715d8901fa19,
8186            fidl::encoding::DynamicFlags::empty(),
8187        )
8188    }
8189
8190    /// Enables or disables notifications about changes to the minimum clock lead
8191    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8192    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8193    /// event with the current minimum lead time for the AudioRenderer. If the
8194    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8195    /// new value. This behavior will continue until the user calls
8196    /// `EnableMinLeadTimeEvents(false)`.
8197    ///
8198    /// The minimum clock lead time is the amount of time ahead of the reference
8199    /// clock's understanding of "now" that packets needs to arrive (relative to
8200    /// the playback clock transformation) in order for the mixer to be able to
8201    /// mix packet. For example...
8202    ///
8203    /// + Let the PTS of packet X be P(X)
8204    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8205    ///   function is determined by the call to Play(...)
8206    /// + Let the minimum lead time be MLT
8207    ///
8208    /// If R(P(X)) < RefClock.Now() + MLT
8209    /// Then the packet is late, and some (or all) of the packet's payload will
8210    /// need to be skipped in order to present the packet at the scheduled time.
8211    ///
8212    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8213    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8214    /// is called before the AudioRenderer is routed, any played packets will be
8215    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8216    /// calling `Play`.
8217    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8218        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8219            (enabled,),
8220            0x62808dfad72bf890,
8221            fidl::encoding::DynamicFlags::empty(),
8222        )
8223    }
8224
8225    ///
8226    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8227    /// there's little reason to do so. This is because lead time is a function
8228    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8229    /// If min lead time events are enabled before `SetPcmStreamType` (with
8230    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8231    /// response to `SetPcmStreamType`.
8232    pub fn r#get_min_lead_time(
8233        &self,
8234        ___deadline: zx::MonotonicInstant,
8235    ) -> Result<i64, fidl::Error> {
8236        let _response = self
8237            .client
8238            .send_query::<fidl::encoding::EmptyPayload, AudioRendererGetMinLeadTimeResponse>(
8239                (),
8240                0x1cf3c3ecd8fec26b,
8241                fidl::encoding::DynamicFlags::empty(),
8242                ___deadline,
8243            )?;
8244        Ok(_response.min_lead_time_nsec)
8245    }
8246
8247    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8248    /// of the media timeline, using specific values provided by the caller (or
8249    /// default values if not specified). In an optional callback, returns the
8250    /// timestamp values ultimately used -- these set the ongoing relationship
8251    /// between the media and reference timelines (i.e., how to translate between
8252    /// the domain of presentation timestamps, and the realm of local system
8253    /// time).
8254    ///
8255    /// Local system time is specified in units of nanoseconds; media_time is
8256    /// specified in the units defined by the user in the `SetPtsUnits` function,
8257    /// or nanoseconds if `SetPtsUnits` is not called.
8258    ///
8259    /// The act of placing an AudioRenderer into the playback state establishes a
8260    /// relationship between 1) the user-defined media (or presentation) timeline
8261    /// for this particular AudioRenderer, and 2) the real-world system reference
8262    /// timeline. To communicate how to translate between timelines, the Play()
8263    /// callback provides an equivalent timestamp in each time domain. The first
8264    /// value ('reference_time') is given in terms of this renderer's reference
8265    /// clock; the second value ('media_time') is what media instant exactly
8266    /// corresponds to that local time. Restated, the frame at 'media_time' in
8267    /// the audio stream should be presented at 'reference_time' according to
8268    /// the reference clock.
8269    ///
8270    /// Note: on calling this API, media_time immediately starts advancing. It is
8271    /// possible (if uncommon) for a caller to specify a system time that is
8272    /// far in the past, or far into the future. This, along with the specified
8273    /// media time, is simply used to determine what media time corresponds to
8274    /// 'now', and THAT media time is then intersected with presentation
8275    /// timestamps of packets already submitted, to determine which media frames
8276    /// should be presented next.
8277    ///
8278    /// With the corresponding reference_time and media_time values, a user can
8279    /// translate arbitrary time values from one timeline into the other. After
8280    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8281    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8282    /// any 'ref_time':
8283    ///
8284    /// media_time = ( (ref_time - ref_start) / 1e9
8285    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8286    ///              + media_start
8287    ///
8288    /// Conversely, for any presentation timestamp 'media_time':
8289    ///
8290    /// ref_time = ( (media_time - media_start)
8291    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8292    ///              * 1e9 )
8293    ///            + ref_start
8294    ///
8295    /// Users, depending on their use case, may optionally choose not to specify
8296    /// one or both of these timestamps. A timestamp may be omitted by supplying
8297    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8298    /// any omitted timestamp value using the following rules:
8299    ///
8300    /// Reference Time
8301    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8302    /// reference time to begin presentation, based on the minimum lead times for
8303    /// the output devices that are currently bound to this AudioRenderer. For
8304    /// example, if an AudioRenderer is bound to an internal audio output
8305    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8306    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8307    /// is omitted) select a reference time 80 mSec from now.
8308    ///
8309    /// Media Time
8310    /// If media_time is omitted, the AudioRenderer will select one of two
8311    /// values.
8312    /// - If the AudioRenderer is resuming from the paused state, and packets
8313    /// have not been discarded since being paused, then the AudioRenderer will
8314    /// use a media_time corresponding to the instant at which the presentation
8315    /// became paused.
8316    /// - If the AudioRenderer is being placed into a playing state for the first
8317    /// time following startup or a 'discard packets' operation, the initial
8318    /// media_time will be set to the PTS of the first payload in the pending
8319    /// packet queue. If the pending queue is empty, initial media_time will be
8320    /// set to zero.
8321    ///
8322    /// Return Value
8323    /// When requested, the AudioRenderer will return the 'reference_time' and
8324    /// 'media_time' which were selected and used (whether they were explicitly
8325    /// specified or not) in the return value of the play call.
8326    ///
8327    /// Examples
8328    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8329    /// to start playing as soon as possible. The user may call Play without
8330    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8331    ///
8332    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8333    /// playback at a specified 'reference_time', in sync with some other media
8334    /// stream, either initially or after discarding packets. The user would call
8335    /// `Play(reference_time, NO_TIMESTAMP)`.
8336    ///
8337    /// 3. A user has queued some audio using `SendPacket`. The first of these
8338    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8339    /// as possible, but wishes to skip all of the audio content between PTS 0
8340    /// and PTS 'media_time'. The user would call
8341    /// `Play(NO_TIMESTAMP, media_time)`.
8342    ///
8343    /// 4. A user has queued some audio using `SendPacket` and want to present
8344    /// this media in synch with another player in a different device. The
8345    /// coordinator of the group of distributed players sends an explicit
8346    /// message to each player telling them to begin presentation of audio at
8347    /// PTS 'media_time', at the time (based on the group's shared reference
8348    /// clock) 'reference_time'. Here the user would call
8349    /// `Play(reference_time, media_time)`.
8350    pub fn r#play(
8351        &self,
8352        mut reference_time: i64,
8353        mut media_time: i64,
8354        ___deadline: zx::MonotonicInstant,
8355    ) -> Result<(i64, i64), fidl::Error> {
8356        let _response =
8357            self.client.send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse>(
8358                (reference_time, media_time),
8359                0x3c0162db084f74a3,
8360                fidl::encoding::DynamicFlags::empty(),
8361                ___deadline,
8362            )?;
8363        Ok((_response.reference_time, _response.media_time))
8364    }
8365
8366    pub fn r#play_no_reply(
8367        &self,
8368        mut reference_time: i64,
8369        mut media_time: i64,
8370    ) -> Result<(), fidl::Error> {
8371        self.client.send::<AudioRendererPlayNoReplyRequest>(
8372            (reference_time, media_time),
8373            0x1b7fe832b68c22ef,
8374            fidl::encoding::DynamicFlags::empty(),
8375        )
8376    }
8377
8378    /// Immediately puts the AudioRenderer into the paused state and then report
8379    /// the relationship between the media and reference timelines which was
8380    /// established (if requested).
8381    ///
8382    /// If the AudioRenderer is already in the paused state when this called,
8383    /// the previously-established timeline values are returned (if requested).
8384    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8385        let _response =
8386            self.client.send_query::<fidl::encoding::EmptyPayload, AudioRendererPauseResponse>(
8387                (),
8388                0x41d557588d93d153,
8389                fidl::encoding::DynamicFlags::empty(),
8390                ___deadline,
8391            )?;
8392        Ok((_response.reference_time, _response.media_time))
8393    }
8394
8395    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8396        self.client.send::<fidl::encoding::EmptyPayload>(
8397            (),
8398            0x24cc45d4f3855ab,
8399            fidl::encoding::DynamicFlags::empty(),
8400        )
8401    }
8402}
8403
8404#[cfg(target_os = "fuchsia")]
8405impl From<AudioRendererSynchronousProxy> for zx::NullableHandle {
8406    fn from(value: AudioRendererSynchronousProxy) -> Self {
8407        value.into_channel().into()
8408    }
8409}
8410
8411#[cfg(target_os = "fuchsia")]
8412impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8413    fn from(value: fidl::Channel) -> Self {
8414        Self::new(value)
8415    }
8416}
8417
8418#[cfg(target_os = "fuchsia")]
8419impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8420    type Protocol = AudioRendererMarker;
8421
8422    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8423        Self::new(value.into_channel())
8424    }
8425}
8426
8427#[derive(Debug, Clone)]
8428pub struct AudioRendererProxy {
8429    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8430}
8431
8432impl fidl::endpoints::Proxy for AudioRendererProxy {
8433    type Protocol = AudioRendererMarker;
8434
8435    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8436        Self::new(inner)
8437    }
8438
8439    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8440        self.client.into_channel().map_err(|client| Self { client })
8441    }
8442
8443    fn as_channel(&self) -> &::fidl::AsyncChannel {
8444        self.client.as_channel()
8445    }
8446}
8447
8448impl AudioRendererProxy {
8449    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8450    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8451        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8452        Self { client: fidl::client::Client::new(channel, protocol_name) }
8453    }
8454
8455    /// Get a Stream of events from the remote end of the protocol.
8456    ///
8457    /// # Panics
8458    ///
8459    /// Panics if the event stream was already taken.
8460    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8461        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8462    }
8463
8464    /// Adds a payload buffer to the current buffer set associated with the
8465    /// connection. A `StreamPacket` struct reference a payload buffer in the
8466    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8467    ///
8468    /// A buffer with ID `id` must not be in the current set when this method is
8469    /// invoked, otherwise the service will close the connection.
8470    pub fn r#add_payload_buffer(
8471        &self,
8472        mut id: u32,
8473        mut payload_buffer: fidl::Vmo,
8474    ) -> Result<(), fidl::Error> {
8475        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8476    }
8477
8478    /// Removes a payload buffer from the current buffer set associated with the
8479    /// connection.
8480    ///
8481    /// A buffer with ID `id` must exist in the current set when this method is
8482    /// invoked, otherwise the service will will close the connection.
8483    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8484        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8485    }
8486
8487    /// Sends a packet to the service. The response is sent when the service is
8488    /// done with the associated payload memory.
8489    ///
8490    /// `packet` must be valid for the current buffer set, otherwise the service
8491    /// will close the connection.
8492    pub fn r#send_packet(
8493        &self,
8494        mut packet: &StreamPacket,
8495    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8496        AudioRendererProxyInterface::r#send_packet(self, packet)
8497    }
8498
8499    /// Sends a packet to the service. This interface doesn't define how the
8500    /// client knows when the sink is done with the associated payload memory.
8501    /// The inheriting interface must define that.
8502    ///
8503    /// `packet` must be valid for the current buffer set, otherwise the service
8504    /// will close the connection.
8505    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8506        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8507    }
8508
8509    /// Indicates the stream has ended. The precise semantics of this method are
8510    /// determined by the inheriting interface.
8511    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8512        AudioRendererProxyInterface::r#end_of_stream(self)
8513    }
8514
8515    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8516    /// and not yet released. The response is sent after all packets have been
8517    /// released.
8518    pub fn r#discard_all_packets(
8519        &self,
8520    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8521        AudioRendererProxyInterface::r#discard_all_packets(self)
8522    }
8523
8524    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8525    /// and not yet released.
8526    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8527        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8528    }
8529
8530    /// Binds to the gain control for this AudioRenderer.
8531    pub fn r#bind_gain_control(
8532        &self,
8533        mut gain_control_request: fidl::endpoints::ServerEnd<
8534            fidl_fuchsia_media_audio::GainControlMarker,
8535        >,
8536    ) -> Result<(), fidl::Error> {
8537        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8538    }
8539
8540    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8541    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8542    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8543    pub fn r#set_pts_units(
8544        &self,
8545        mut tick_per_second_numerator: u32,
8546        mut tick_per_second_denominator: u32,
8547    ) -> Result<(), fidl::Error> {
8548        AudioRendererProxyInterface::r#set_pts_units(
8549            self,
8550            tick_per_second_numerator,
8551            tick_per_second_denominator,
8552        )
8553    }
8554
8555    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8556    /// and expected PTS (determined using interpolation). Beyond this threshold,
8557    /// a stream is no longer considered 'continuous' by the renderer.
8558    ///
8559    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8560    /// Most users should not need to change this value from its default.
8561    ///
8562    /// Example:
8563    /// A user is playing back 48KHz audio from a container, which also contains
8564    /// video and needs to be synchronized with the audio. The timestamps are
8565    /// provided explicitly per packet by the container, and expressed in mSec
8566    /// units. This means that a single tick of the media timeline (1 mSec)
8567    /// represents exactly 48 frames of audio. The application in this scenario
8568    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8569    /// frames of audio, and each with an explicit timestamp set to the best
8570    /// possible representation of the presentation time (given this media
8571    /// clock's resolution). So, starting from zero, the timestamps would be..
8572    ///
8573    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8574    ///
8575    /// In this example, attempting to use the presentation time to compute the
8576    /// starting frame number of the audio in the packet would be wrong the
8577    /// majority of the time. The first timestamp is correct (by definition), but
8578    /// it will be 24 packets before the timestamps and frame numbers come back
8579    /// into alignment (the 24th packet would start with the 11280th audio frame
8580    /// and have a PTS of exactly 235).
8581    ///
8582    /// One way to fix this situation is to set the PTS continuity threshold
8583    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8584    /// the number of frames contained within a single tick of the media clock,
8585    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8586    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8587    /// explicitly provided PTS would be considered to be a continuation of the
8588    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8589    /// would work well.
8590    ///
8591    /// Other possible uses:
8592    /// Users who are scheduling audio explicitly, relative to a clock which has
8593    /// not been configured as the reference clock, can use this value to control
8594    /// the maximum acceptable synchronization error before a discontinuity is
8595    /// introduced. E.g., if a user is scheduling audio based on a recovered
8596    /// common media clock, and has not published that clock as the reference
8597    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8598    /// can accumulate before the AudioRenderer deliberately inserts a
8599    /// presentation discontinuity to account for the error.
8600    ///
8601    /// Users whose need to deal with a container where their timestamps may be
8602    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8603    /// something larger. This should be the maximum level of inaccuracy present
8604    /// in the container timestamps, if known. Failing that, it could be set to
8605    /// the maximum tolerable level of drift error before absolute timestamps are
8606    /// explicitly obeyed. Finally, a user could set this number to a very large
8607    /// value (86400.0 seconds, for example) to effectively cause *all*
8608    /// timestamps to be ignored after the first, thus treating all audio as
8609    /// continuous with previously delivered packets. Conversely, users who wish
8610    /// to *always* explicitly schedule their audio packets exactly may specify
8611    /// a CT of 0.
8612    ///
8613    /// Note: explicitly specifying high-frequency PTS units reduces the default
8614    /// continuity threshold accordingly. Internally, this threshold is stored as an
8615    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8616    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8617    /// For this reason, specifying PTS units with a frequency greater than 8192x
8618    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8619    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8620    pub fn r#set_pts_continuity_threshold(
8621        &self,
8622        mut threshold_seconds: f32,
8623    ) -> Result<(), fidl::Error> {
8624        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8625    }
8626
8627    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8628    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8629    pub fn r#get_reference_clock(
8630        &self,
8631    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8632    {
8633        AudioRendererProxyInterface::r#get_reference_clock(self)
8634    }
8635
8636    /// Sets the reference clock that controls this renderer's playback rate. If the input
8637    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8638    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8639    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8640    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8641    ///
8642    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8643    /// cannot be called a second time (even if the renderer format has not yet been set).
8644    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8645    /// diverge at some later time, they should create a clone of the monotonic clock, set
8646    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8647    pub fn r#set_reference_clock(
8648        &self,
8649        mut reference_clock: Option<fidl::Clock>,
8650    ) -> Result<(), fidl::Error> {
8651        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
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_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8657        AudioRendererProxyInterface::r#set_usage(self, usage)
8658    }
8659
8660    /// Sets the usage of the render stream. This method may not be called after
8661    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8662    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8663        AudioRendererProxyInterface::r#set_usage2(self, usage2)
8664    }
8665
8666    /// Sets the type of the stream to be delivered by the client. Using this method implies
8667    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8668    ///
8669    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8670    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8671    /// methods such as `SendPacket`/`SendPacketNoReply`.
8672    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8673        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
8674    }
8675
8676    /// Enables or disables notifications about changes to the minimum clock lead
8677    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8678    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8679    /// event with the current minimum lead time for the AudioRenderer. If the
8680    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8681    /// new value. This behavior will continue until the user calls
8682    /// `EnableMinLeadTimeEvents(false)`.
8683    ///
8684    /// The minimum clock lead time is the amount of time ahead of the reference
8685    /// clock's understanding of "now" that packets needs to arrive (relative to
8686    /// the playback clock transformation) in order for the mixer to be able to
8687    /// mix packet. For example...
8688    ///
8689    /// + Let the PTS of packet X be P(X)
8690    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8691    ///   function is determined by the call to Play(...)
8692    /// + Let the minimum lead time be MLT
8693    ///
8694    /// If R(P(X)) < RefClock.Now() + MLT
8695    /// Then the packet is late, and some (or all) of the packet's payload will
8696    /// need to be skipped in order to present the packet at the scheduled time.
8697    ///
8698    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8699    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8700    /// is called before the AudioRenderer is routed, any played packets will be
8701    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8702    /// calling `Play`.
8703    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8704        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
8705    }
8706
8707    ///
8708    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8709    /// there's little reason to do so. This is because lead time is a function
8710    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8711    /// If min lead time events are enabled before `SetPcmStreamType` (with
8712    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8713    /// response to `SetPcmStreamType`.
8714    pub fn r#get_min_lead_time(
8715        &self,
8716    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
8717        AudioRendererProxyInterface::r#get_min_lead_time(self)
8718    }
8719
8720    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8721    /// of the media timeline, using specific values provided by the caller (or
8722    /// default values if not specified). In an optional callback, returns the
8723    /// timestamp values ultimately used -- these set the ongoing relationship
8724    /// between the media and reference timelines (i.e., how to translate between
8725    /// the domain of presentation timestamps, and the realm of local system
8726    /// time).
8727    ///
8728    /// Local system time is specified in units of nanoseconds; media_time is
8729    /// specified in the units defined by the user in the `SetPtsUnits` function,
8730    /// or nanoseconds if `SetPtsUnits` is not called.
8731    ///
8732    /// The act of placing an AudioRenderer into the playback state establishes a
8733    /// relationship between 1) the user-defined media (or presentation) timeline
8734    /// for this particular AudioRenderer, and 2) the real-world system reference
8735    /// timeline. To communicate how to translate between timelines, the Play()
8736    /// callback provides an equivalent timestamp in each time domain. The first
8737    /// value ('reference_time') is given in terms of this renderer's reference
8738    /// clock; the second value ('media_time') is what media instant exactly
8739    /// corresponds to that local time. Restated, the frame at 'media_time' in
8740    /// the audio stream should be presented at 'reference_time' according to
8741    /// the reference clock.
8742    ///
8743    /// Note: on calling this API, media_time immediately starts advancing. It is
8744    /// possible (if uncommon) for a caller to specify a system time that is
8745    /// far in the past, or far into the future. This, along with the specified
8746    /// media time, is simply used to determine what media time corresponds to
8747    /// 'now', and THAT media time is then intersected with presentation
8748    /// timestamps of packets already submitted, to determine which media frames
8749    /// should be presented next.
8750    ///
8751    /// With the corresponding reference_time and media_time values, a user can
8752    /// translate arbitrary time values from one timeline into the other. After
8753    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8754    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8755    /// any 'ref_time':
8756    ///
8757    /// media_time = ( (ref_time - ref_start) / 1e9
8758    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8759    ///              + media_start
8760    ///
8761    /// Conversely, for any presentation timestamp 'media_time':
8762    ///
8763    /// ref_time = ( (media_time - media_start)
8764    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8765    ///              * 1e9 )
8766    ///            + ref_start
8767    ///
8768    /// Users, depending on their use case, may optionally choose not to specify
8769    /// one or both of these timestamps. A timestamp may be omitted by supplying
8770    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8771    /// any omitted timestamp value using the following rules:
8772    ///
8773    /// Reference Time
8774    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8775    /// reference time to begin presentation, based on the minimum lead times for
8776    /// the output devices that are currently bound to this AudioRenderer. For
8777    /// example, if an AudioRenderer is bound to an internal audio output
8778    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8779    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8780    /// is omitted) select a reference time 80 mSec from now.
8781    ///
8782    /// Media Time
8783    /// If media_time is omitted, the AudioRenderer will select one of two
8784    /// values.
8785    /// - If the AudioRenderer is resuming from the paused state, and packets
8786    /// have not been discarded since being paused, then the AudioRenderer will
8787    /// use a media_time corresponding to the instant at which the presentation
8788    /// became paused.
8789    /// - If the AudioRenderer is being placed into a playing state for the first
8790    /// time following startup or a 'discard packets' operation, the initial
8791    /// media_time will be set to the PTS of the first payload in the pending
8792    /// packet queue. If the pending queue is empty, initial media_time will be
8793    /// set to zero.
8794    ///
8795    /// Return Value
8796    /// When requested, the AudioRenderer will return the 'reference_time' and
8797    /// 'media_time' which were selected and used (whether they were explicitly
8798    /// specified or not) in the return value of the play call.
8799    ///
8800    /// Examples
8801    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8802    /// to start playing as soon as possible. The user may call Play without
8803    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8804    ///
8805    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8806    /// playback at a specified 'reference_time', in sync with some other media
8807    /// stream, either initially or after discarding packets. The user would call
8808    /// `Play(reference_time, NO_TIMESTAMP)`.
8809    ///
8810    /// 3. A user has queued some audio using `SendPacket`. The first of these
8811    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8812    /// as possible, but wishes to skip all of the audio content between PTS 0
8813    /// and PTS 'media_time'. The user would call
8814    /// `Play(NO_TIMESTAMP, media_time)`.
8815    ///
8816    /// 4. A user has queued some audio using `SendPacket` and want to present
8817    /// this media in synch with another player in a different device. The
8818    /// coordinator of the group of distributed players sends an explicit
8819    /// message to each player telling them to begin presentation of audio at
8820    /// PTS 'media_time', at the time (based on the group's shared reference
8821    /// clock) 'reference_time'. Here the user would call
8822    /// `Play(reference_time, media_time)`.
8823    pub fn r#play(
8824        &self,
8825        mut reference_time: i64,
8826        mut media_time: i64,
8827    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8828    {
8829        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
8830    }
8831
8832    pub fn r#play_no_reply(
8833        &self,
8834        mut reference_time: i64,
8835        mut media_time: i64,
8836    ) -> Result<(), fidl::Error> {
8837        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
8838    }
8839
8840    /// Immediately puts the AudioRenderer into the paused state and then report
8841    /// the relationship between the media and reference timelines which was
8842    /// established (if requested).
8843    ///
8844    /// If the AudioRenderer is already in the paused state when this called,
8845    /// the previously-established timeline values are returned (if requested).
8846    pub fn r#pause(
8847        &self,
8848    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
8849    {
8850        AudioRendererProxyInterface::r#pause(self)
8851    }
8852
8853    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8854        AudioRendererProxyInterface::r#pause_no_reply(self)
8855    }
8856}
8857
8858impl AudioRendererProxyInterface for AudioRendererProxy {
8859    fn r#add_payload_buffer(
8860        &self,
8861        mut id: u32,
8862        mut payload_buffer: fidl::Vmo,
8863    ) -> Result<(), fidl::Error> {
8864        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8865            (id, payload_buffer),
8866            0x3b3a37fc34fe5b56,
8867            fidl::encoding::DynamicFlags::empty(),
8868        )
8869    }
8870
8871    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8872        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8873            (id,),
8874            0x5d1e4f74c3658262,
8875            fidl::encoding::DynamicFlags::empty(),
8876        )
8877    }
8878
8879    type SendPacketResponseFut =
8880        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8881    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
8882        fn _decode(
8883            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8884        ) -> Result<(), fidl::Error> {
8885            let _response = fidl::client::decode_transaction_body::<
8886                fidl::encoding::EmptyPayload,
8887                fidl::encoding::DefaultFuchsiaResourceDialect,
8888                0x67cddd607442775f,
8889            >(_buf?)?;
8890            Ok(_response)
8891        }
8892        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
8893            (packet,),
8894            0x67cddd607442775f,
8895            fidl::encoding::DynamicFlags::empty(),
8896            _decode,
8897        )
8898    }
8899
8900    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8901        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8902            (packet,),
8903            0x8d9b8b413ceba9d,
8904            fidl::encoding::DynamicFlags::empty(),
8905        )
8906    }
8907
8908    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8909        self.client.send::<fidl::encoding::EmptyPayload>(
8910            (),
8911            0x6180fd6f7e793b71,
8912            fidl::encoding::DynamicFlags::empty(),
8913        )
8914    }
8915
8916    type DiscardAllPacketsResponseFut =
8917        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
8918    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
8919        fn _decode(
8920            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8921        ) -> Result<(), fidl::Error> {
8922            let _response = fidl::client::decode_transaction_body::<
8923                fidl::encoding::EmptyPayload,
8924                fidl::encoding::DefaultFuchsiaResourceDialect,
8925                0x6f4dad7af2917665,
8926            >(_buf?)?;
8927            Ok(_response)
8928        }
8929        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
8930            (),
8931            0x6f4dad7af2917665,
8932            fidl::encoding::DynamicFlags::empty(),
8933            _decode,
8934        )
8935    }
8936
8937    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8938        self.client.send::<fidl::encoding::EmptyPayload>(
8939            (),
8940            0x50d36d0d23081bc4,
8941            fidl::encoding::DynamicFlags::empty(),
8942        )
8943    }
8944
8945    fn r#bind_gain_control(
8946        &self,
8947        mut gain_control_request: fidl::endpoints::ServerEnd<
8948            fidl_fuchsia_media_audio::GainControlMarker,
8949        >,
8950    ) -> Result<(), fidl::Error> {
8951        self.client.send::<AudioRendererBindGainControlRequest>(
8952            (gain_control_request,),
8953            0x293f5c7f8fba2bdc,
8954            fidl::encoding::DynamicFlags::empty(),
8955        )
8956    }
8957
8958    fn r#set_pts_units(
8959        &self,
8960        mut tick_per_second_numerator: u32,
8961        mut tick_per_second_denominator: u32,
8962    ) -> Result<(), fidl::Error> {
8963        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8964            (tick_per_second_numerator, tick_per_second_denominator),
8965            0xf68cd108785a27c,
8966            fidl::encoding::DynamicFlags::empty(),
8967        )
8968    }
8969
8970    fn r#set_pts_continuity_threshold(
8971        &self,
8972        mut threshold_seconds: f32,
8973    ) -> Result<(), fidl::Error> {
8974        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8975            (threshold_seconds,),
8976            0x2849ba571d1971ba,
8977            fidl::encoding::DynamicFlags::empty(),
8978        )
8979    }
8980
8981    type GetReferenceClockResponseFut =
8982        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
8983    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
8984        fn _decode(
8985            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8986        ) -> Result<fidl::Clock, fidl::Error> {
8987            let _response = fidl::client::decode_transaction_body::<
8988                AudioRendererGetReferenceClockResponse,
8989                fidl::encoding::DefaultFuchsiaResourceDialect,
8990                0x2f7a7f011a172f7e,
8991            >(_buf?)?;
8992            Ok(_response.reference_clock)
8993        }
8994        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
8995            (),
8996            0x2f7a7f011a172f7e,
8997            fidl::encoding::DynamicFlags::empty(),
8998            _decode,
8999        )
9000    }
9001
9002    fn r#set_reference_clock(
9003        &self,
9004        mut reference_clock: Option<fidl::Clock>,
9005    ) -> Result<(), fidl::Error> {
9006        self.client.send::<AudioRendererSetReferenceClockRequest>(
9007            (reference_clock,),
9008            0x39acd05d832b5fed,
9009            fidl::encoding::DynamicFlags::empty(),
9010        )
9011    }
9012
9013    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9014        self.client.send::<AudioRendererSetUsageRequest>(
9015            (usage,),
9016            0x3994bd23b55a733e,
9017            fidl::encoding::DynamicFlags::empty(),
9018        )
9019    }
9020
9021    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9022        self.client.send::<AudioRendererSetUsage2Request>(
9023            (usage2,),
9024            0x2904035c7132b103,
9025            fidl::encoding::DynamicFlags::FLEXIBLE,
9026        )
9027    }
9028
9029    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9030        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9031            (type_,),
9032            0x27aa715d8901fa19,
9033            fidl::encoding::DynamicFlags::empty(),
9034        )
9035    }
9036
9037    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9038        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9039            (enabled,),
9040            0x62808dfad72bf890,
9041            fidl::encoding::DynamicFlags::empty(),
9042        )
9043    }
9044
9045    type GetMinLeadTimeResponseFut =
9046        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9047    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9048        fn _decode(
9049            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9050        ) -> Result<i64, fidl::Error> {
9051            let _response = fidl::client::decode_transaction_body::<
9052                AudioRendererGetMinLeadTimeResponse,
9053                fidl::encoding::DefaultFuchsiaResourceDialect,
9054                0x1cf3c3ecd8fec26b,
9055            >(_buf?)?;
9056            Ok(_response.min_lead_time_nsec)
9057        }
9058        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9059            (),
9060            0x1cf3c3ecd8fec26b,
9061            fidl::encoding::DynamicFlags::empty(),
9062            _decode,
9063        )
9064    }
9065
9066    type PlayResponseFut =
9067        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9068    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9069        fn _decode(
9070            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9071        ) -> Result<(i64, i64), fidl::Error> {
9072            let _response = fidl::client::decode_transaction_body::<
9073                AudioRendererPlayResponse,
9074                fidl::encoding::DefaultFuchsiaResourceDialect,
9075                0x3c0162db084f74a3,
9076            >(_buf?)?;
9077            Ok((_response.reference_time, _response.media_time))
9078        }
9079        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9080            (reference_time, media_time),
9081            0x3c0162db084f74a3,
9082            fidl::encoding::DynamicFlags::empty(),
9083            _decode,
9084        )
9085    }
9086
9087    fn r#play_no_reply(
9088        &self,
9089        mut reference_time: i64,
9090        mut media_time: i64,
9091    ) -> Result<(), fidl::Error> {
9092        self.client.send::<AudioRendererPlayNoReplyRequest>(
9093            (reference_time, media_time),
9094            0x1b7fe832b68c22ef,
9095            fidl::encoding::DynamicFlags::empty(),
9096        )
9097    }
9098
9099    type PauseResponseFut =
9100        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9101    fn r#pause(&self) -> Self::PauseResponseFut {
9102        fn _decode(
9103            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9104        ) -> Result<(i64, i64), fidl::Error> {
9105            let _response = fidl::client::decode_transaction_body::<
9106                AudioRendererPauseResponse,
9107                fidl::encoding::DefaultFuchsiaResourceDialect,
9108                0x41d557588d93d153,
9109            >(_buf?)?;
9110            Ok((_response.reference_time, _response.media_time))
9111        }
9112        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9113            (),
9114            0x41d557588d93d153,
9115            fidl::encoding::DynamicFlags::empty(),
9116            _decode,
9117        )
9118    }
9119
9120    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9121        self.client.send::<fidl::encoding::EmptyPayload>(
9122            (),
9123            0x24cc45d4f3855ab,
9124            fidl::encoding::DynamicFlags::empty(),
9125        )
9126    }
9127}
9128
9129pub struct AudioRendererEventStream {
9130    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9131}
9132
9133impl std::marker::Unpin for AudioRendererEventStream {}
9134
9135impl futures::stream::FusedStream for AudioRendererEventStream {
9136    fn is_terminated(&self) -> bool {
9137        self.event_receiver.is_terminated()
9138    }
9139}
9140
9141impl futures::Stream for AudioRendererEventStream {
9142    type Item = Result<AudioRendererEvent, fidl::Error>;
9143
9144    fn poll_next(
9145        mut self: std::pin::Pin<&mut Self>,
9146        cx: &mut std::task::Context<'_>,
9147    ) -> std::task::Poll<Option<Self::Item>> {
9148        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9149            &mut self.event_receiver,
9150            cx
9151        )?) {
9152            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9153            None => std::task::Poll::Ready(None),
9154        }
9155    }
9156}
9157
9158#[derive(Debug)]
9159pub enum AudioRendererEvent {
9160    OnMinLeadTimeChanged {
9161        min_lead_time_nsec: i64,
9162    },
9163    #[non_exhaustive]
9164    _UnknownEvent {
9165        /// Ordinal of the event that was sent.
9166        ordinal: u64,
9167    },
9168}
9169
9170impl AudioRendererEvent {
9171    #[allow(irrefutable_let_patterns)]
9172    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9173        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9174            Some((min_lead_time_nsec))
9175        } else {
9176            None
9177        }
9178    }
9179
9180    /// Decodes a message buffer as a [`AudioRendererEvent`].
9181    fn decode(
9182        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9183    ) -> Result<AudioRendererEvent, fidl::Error> {
9184        let (bytes, _handles) = buf.split_mut();
9185        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9186        debug_assert_eq!(tx_header.tx_id, 0);
9187        match tx_header.ordinal {
9188            0x4feff7d278978c4e => {
9189                let mut out = fidl::new_empty!(
9190                    AudioRendererOnMinLeadTimeChangedRequest,
9191                    fidl::encoding::DefaultFuchsiaResourceDialect
9192                );
9193                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9194                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9195                    min_lead_time_nsec: out.min_lead_time_nsec,
9196                }))
9197            }
9198            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9199                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9200            }
9201            _ => Err(fidl::Error::UnknownOrdinal {
9202                ordinal: tx_header.ordinal,
9203                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9204            }),
9205        }
9206    }
9207}
9208
9209/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9210pub struct AudioRendererRequestStream {
9211    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9212    is_terminated: bool,
9213}
9214
9215impl std::marker::Unpin for AudioRendererRequestStream {}
9216
9217impl futures::stream::FusedStream for AudioRendererRequestStream {
9218    fn is_terminated(&self) -> bool {
9219        self.is_terminated
9220    }
9221}
9222
9223impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9224    type Protocol = AudioRendererMarker;
9225    type ControlHandle = AudioRendererControlHandle;
9226
9227    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9228        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9229    }
9230
9231    fn control_handle(&self) -> Self::ControlHandle {
9232        AudioRendererControlHandle { inner: self.inner.clone() }
9233    }
9234
9235    fn into_inner(
9236        self,
9237    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9238    {
9239        (self.inner, self.is_terminated)
9240    }
9241
9242    fn from_inner(
9243        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9244        is_terminated: bool,
9245    ) -> Self {
9246        Self { inner, is_terminated }
9247    }
9248}
9249
9250impl futures::Stream for AudioRendererRequestStream {
9251    type Item = Result<AudioRendererRequest, fidl::Error>;
9252
9253    fn poll_next(
9254        mut self: std::pin::Pin<&mut Self>,
9255        cx: &mut std::task::Context<'_>,
9256    ) -> std::task::Poll<Option<Self::Item>> {
9257        let this = &mut *self;
9258        if this.inner.check_shutdown(cx) {
9259            this.is_terminated = true;
9260            return std::task::Poll::Ready(None);
9261        }
9262        if this.is_terminated {
9263            panic!("polled AudioRendererRequestStream after completion");
9264        }
9265        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9266            |bytes, handles| {
9267                match this.inner.channel().read_etc(cx, bytes, handles) {
9268                    std::task::Poll::Ready(Ok(())) => {}
9269                    std::task::Poll::Pending => return std::task::Poll::Pending,
9270                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9271                        this.is_terminated = true;
9272                        return std::task::Poll::Ready(None);
9273                    }
9274                    std::task::Poll::Ready(Err(e)) => {
9275                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9276                            e.into(),
9277                        ))));
9278                    }
9279                }
9280
9281                // A message has been received from the channel
9282                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9283
9284                std::task::Poll::Ready(Some(match header.ordinal {
9285                    0x3b3a37fc34fe5b56 => {
9286                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9287                        let mut req = fidl::new_empty!(
9288                            StreamBufferSetAddPayloadBufferRequest,
9289                            fidl::encoding::DefaultFuchsiaResourceDialect
9290                        );
9291                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9292                        let control_handle =
9293                            AudioRendererControlHandle { inner: this.inner.clone() };
9294                        Ok(AudioRendererRequest::AddPayloadBuffer {
9295                            id: req.id,
9296                            payload_buffer: req.payload_buffer,
9297
9298                            control_handle,
9299                        })
9300                    }
9301                    0x5d1e4f74c3658262 => {
9302                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9303                        let mut req = fidl::new_empty!(
9304                            StreamBufferSetRemovePayloadBufferRequest,
9305                            fidl::encoding::DefaultFuchsiaResourceDialect
9306                        );
9307                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9308                        let control_handle =
9309                            AudioRendererControlHandle { inner: this.inner.clone() };
9310                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9311                    }
9312                    0x67cddd607442775f => {
9313                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9314                        let mut req = fidl::new_empty!(
9315                            StreamSinkSendPacketRequest,
9316                            fidl::encoding::DefaultFuchsiaResourceDialect
9317                        );
9318                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9319                        let control_handle =
9320                            AudioRendererControlHandle { inner: this.inner.clone() };
9321                        Ok(AudioRendererRequest::SendPacket {
9322                            packet: req.packet,
9323
9324                            responder: AudioRendererSendPacketResponder {
9325                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9326                                tx_id: header.tx_id,
9327                            },
9328                        })
9329                    }
9330                    0x8d9b8b413ceba9d => {
9331                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9332                        let mut req = fidl::new_empty!(
9333                            StreamSinkSendPacketNoReplyRequest,
9334                            fidl::encoding::DefaultFuchsiaResourceDialect
9335                        );
9336                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9337                        let control_handle =
9338                            AudioRendererControlHandle { inner: this.inner.clone() };
9339                        Ok(AudioRendererRequest::SendPacketNoReply {
9340                            packet: req.packet,
9341
9342                            control_handle,
9343                        })
9344                    }
9345                    0x6180fd6f7e793b71 => {
9346                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9347                        let mut req = fidl::new_empty!(
9348                            fidl::encoding::EmptyPayload,
9349                            fidl::encoding::DefaultFuchsiaResourceDialect
9350                        );
9351                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9352                        let control_handle =
9353                            AudioRendererControlHandle { inner: this.inner.clone() };
9354                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9355                    }
9356                    0x6f4dad7af2917665 => {
9357                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9358                        let mut req = fidl::new_empty!(
9359                            fidl::encoding::EmptyPayload,
9360                            fidl::encoding::DefaultFuchsiaResourceDialect
9361                        );
9362                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9363                        let control_handle =
9364                            AudioRendererControlHandle { inner: this.inner.clone() };
9365                        Ok(AudioRendererRequest::DiscardAllPackets {
9366                            responder: AudioRendererDiscardAllPacketsResponder {
9367                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9368                                tx_id: header.tx_id,
9369                            },
9370                        })
9371                    }
9372                    0x50d36d0d23081bc4 => {
9373                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9374                        let mut req = fidl::new_empty!(
9375                            fidl::encoding::EmptyPayload,
9376                            fidl::encoding::DefaultFuchsiaResourceDialect
9377                        );
9378                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9379                        let control_handle =
9380                            AudioRendererControlHandle { inner: this.inner.clone() };
9381                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9382                    }
9383                    0x293f5c7f8fba2bdc => {
9384                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9385                        let mut req = fidl::new_empty!(
9386                            AudioRendererBindGainControlRequest,
9387                            fidl::encoding::DefaultFuchsiaResourceDialect
9388                        );
9389                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9390                        let control_handle =
9391                            AudioRendererControlHandle { inner: this.inner.clone() };
9392                        Ok(AudioRendererRequest::BindGainControl {
9393                            gain_control_request: req.gain_control_request,
9394
9395                            control_handle,
9396                        })
9397                    }
9398                    0xf68cd108785a27c => {
9399                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9400                        let mut req = fidl::new_empty!(
9401                            AudioRendererSetPtsUnitsRequest,
9402                            fidl::encoding::DefaultFuchsiaResourceDialect
9403                        );
9404                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9405                        let control_handle =
9406                            AudioRendererControlHandle { inner: this.inner.clone() };
9407                        Ok(AudioRendererRequest::SetPtsUnits {
9408                            tick_per_second_numerator: req.tick_per_second_numerator,
9409                            tick_per_second_denominator: req.tick_per_second_denominator,
9410
9411                            control_handle,
9412                        })
9413                    }
9414                    0x2849ba571d1971ba => {
9415                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9416                        let mut req = fidl::new_empty!(
9417                            AudioRendererSetPtsContinuityThresholdRequest,
9418                            fidl::encoding::DefaultFuchsiaResourceDialect
9419                        );
9420                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9421                        let control_handle =
9422                            AudioRendererControlHandle { inner: this.inner.clone() };
9423                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9424                            threshold_seconds: req.threshold_seconds,
9425
9426                            control_handle,
9427                        })
9428                    }
9429                    0x2f7a7f011a172f7e => {
9430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9431                        let mut req = fidl::new_empty!(
9432                            fidl::encoding::EmptyPayload,
9433                            fidl::encoding::DefaultFuchsiaResourceDialect
9434                        );
9435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9436                        let control_handle =
9437                            AudioRendererControlHandle { inner: this.inner.clone() };
9438                        Ok(AudioRendererRequest::GetReferenceClock {
9439                            responder: AudioRendererGetReferenceClockResponder {
9440                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9441                                tx_id: header.tx_id,
9442                            },
9443                        })
9444                    }
9445                    0x39acd05d832b5fed => {
9446                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9447                        let mut req = fidl::new_empty!(
9448                            AudioRendererSetReferenceClockRequest,
9449                            fidl::encoding::DefaultFuchsiaResourceDialect
9450                        );
9451                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9452                        let control_handle =
9453                            AudioRendererControlHandle { inner: this.inner.clone() };
9454                        Ok(AudioRendererRequest::SetReferenceClock {
9455                            reference_clock: req.reference_clock,
9456
9457                            control_handle,
9458                        })
9459                    }
9460                    0x3994bd23b55a733e => {
9461                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9462                        let mut req = fidl::new_empty!(
9463                            AudioRendererSetUsageRequest,
9464                            fidl::encoding::DefaultFuchsiaResourceDialect
9465                        );
9466                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9467                        let control_handle =
9468                            AudioRendererControlHandle { inner: this.inner.clone() };
9469                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9470                    }
9471                    0x2904035c7132b103 => {
9472                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9473                        let mut req = fidl::new_empty!(
9474                            AudioRendererSetUsage2Request,
9475                            fidl::encoding::DefaultFuchsiaResourceDialect
9476                        );
9477                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9478                        let control_handle =
9479                            AudioRendererControlHandle { inner: this.inner.clone() };
9480                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9481                    }
9482                    0x27aa715d8901fa19 => {
9483                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9484                        let mut req = fidl::new_empty!(
9485                            AudioRendererSetPcmStreamTypeRequest,
9486                            fidl::encoding::DefaultFuchsiaResourceDialect
9487                        );
9488                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9489                        let control_handle =
9490                            AudioRendererControlHandle { inner: this.inner.clone() };
9491                        Ok(AudioRendererRequest::SetPcmStreamType {
9492                            type_: req.type_,
9493
9494                            control_handle,
9495                        })
9496                    }
9497                    0x62808dfad72bf890 => {
9498                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9499                        let mut req = fidl::new_empty!(
9500                            AudioRendererEnableMinLeadTimeEventsRequest,
9501                            fidl::encoding::DefaultFuchsiaResourceDialect
9502                        );
9503                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9504                        let control_handle =
9505                            AudioRendererControlHandle { inner: this.inner.clone() };
9506                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9507                            enabled: req.enabled,
9508
9509                            control_handle,
9510                        })
9511                    }
9512                    0x1cf3c3ecd8fec26b => {
9513                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9514                        let mut req = fidl::new_empty!(
9515                            fidl::encoding::EmptyPayload,
9516                            fidl::encoding::DefaultFuchsiaResourceDialect
9517                        );
9518                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9519                        let control_handle =
9520                            AudioRendererControlHandle { inner: this.inner.clone() };
9521                        Ok(AudioRendererRequest::GetMinLeadTime {
9522                            responder: AudioRendererGetMinLeadTimeResponder {
9523                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9524                                tx_id: header.tx_id,
9525                            },
9526                        })
9527                    }
9528                    0x3c0162db084f74a3 => {
9529                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9530                        let mut req = fidl::new_empty!(
9531                            AudioRendererPlayRequest,
9532                            fidl::encoding::DefaultFuchsiaResourceDialect
9533                        );
9534                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9535                        let control_handle =
9536                            AudioRendererControlHandle { inner: this.inner.clone() };
9537                        Ok(AudioRendererRequest::Play {
9538                            reference_time: req.reference_time,
9539                            media_time: req.media_time,
9540
9541                            responder: AudioRendererPlayResponder {
9542                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9543                                tx_id: header.tx_id,
9544                            },
9545                        })
9546                    }
9547                    0x1b7fe832b68c22ef => {
9548                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9549                        let mut req = fidl::new_empty!(
9550                            AudioRendererPlayNoReplyRequest,
9551                            fidl::encoding::DefaultFuchsiaResourceDialect
9552                        );
9553                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9554                        let control_handle =
9555                            AudioRendererControlHandle { inner: this.inner.clone() };
9556                        Ok(AudioRendererRequest::PlayNoReply {
9557                            reference_time: req.reference_time,
9558                            media_time: req.media_time,
9559
9560                            control_handle,
9561                        })
9562                    }
9563                    0x41d557588d93d153 => {
9564                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9565                        let mut req = fidl::new_empty!(
9566                            fidl::encoding::EmptyPayload,
9567                            fidl::encoding::DefaultFuchsiaResourceDialect
9568                        );
9569                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9570                        let control_handle =
9571                            AudioRendererControlHandle { inner: this.inner.clone() };
9572                        Ok(AudioRendererRequest::Pause {
9573                            responder: AudioRendererPauseResponder {
9574                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9575                                tx_id: header.tx_id,
9576                            },
9577                        })
9578                    }
9579                    0x24cc45d4f3855ab => {
9580                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9581                        let mut req = fidl::new_empty!(
9582                            fidl::encoding::EmptyPayload,
9583                            fidl::encoding::DefaultFuchsiaResourceDialect
9584                        );
9585                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9586                        let control_handle =
9587                            AudioRendererControlHandle { inner: this.inner.clone() };
9588                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9589                    }
9590                    _ if header.tx_id == 0
9591                        && header
9592                            .dynamic_flags()
9593                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9594                    {
9595                        Ok(AudioRendererRequest::_UnknownMethod {
9596                            ordinal: header.ordinal,
9597                            control_handle: AudioRendererControlHandle {
9598                                inner: this.inner.clone(),
9599                            },
9600                            method_type: fidl::MethodType::OneWay,
9601                        })
9602                    }
9603                    _ if header
9604                        .dynamic_flags()
9605                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9606                    {
9607                        this.inner.send_framework_err(
9608                            fidl::encoding::FrameworkErr::UnknownMethod,
9609                            header.tx_id,
9610                            header.ordinal,
9611                            header.dynamic_flags(),
9612                            (bytes, handles),
9613                        )?;
9614                        Ok(AudioRendererRequest::_UnknownMethod {
9615                            ordinal: header.ordinal,
9616                            control_handle: AudioRendererControlHandle {
9617                                inner: this.inner.clone(),
9618                            },
9619                            method_type: fidl::MethodType::TwoWay,
9620                        })
9621                    }
9622                    _ => Err(fidl::Error::UnknownOrdinal {
9623                        ordinal: header.ordinal,
9624                        protocol_name:
9625                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9626                    }),
9627                }))
9628            },
9629        )
9630    }
9631}
9632
9633/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9634/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9635/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9636/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9637/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9638/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9639///
9640/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9641/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9642/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9643/// to reconfiguring the renderer.
9644#[derive(Debug)]
9645pub enum AudioRendererRequest {
9646    /// Adds a payload buffer to the current buffer set associated with the
9647    /// connection. A `StreamPacket` struct reference a payload buffer in the
9648    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
9649    ///
9650    /// A buffer with ID `id` must not be in the current set when this method is
9651    /// invoked, otherwise the service will close the connection.
9652    AddPayloadBuffer {
9653        id: u32,
9654        payload_buffer: fidl::Vmo,
9655        control_handle: AudioRendererControlHandle,
9656    },
9657    /// Removes a payload buffer from the current buffer set associated with the
9658    /// connection.
9659    ///
9660    /// A buffer with ID `id` must exist in the current set when this method is
9661    /// invoked, otherwise the service will will close the connection.
9662    RemovePayloadBuffer {
9663        id: u32,
9664        control_handle: AudioRendererControlHandle,
9665    },
9666    /// Sends a packet to the service. The response is sent when the service is
9667    /// done with the associated payload memory.
9668    ///
9669    /// `packet` must be valid for the current buffer set, otherwise the service
9670    /// will close the connection.
9671    SendPacket {
9672        packet: StreamPacket,
9673        responder: AudioRendererSendPacketResponder,
9674    },
9675    /// Sends a packet to the service. This interface doesn't define how the
9676    /// client knows when the sink is done with the associated payload memory.
9677    /// The inheriting interface must define that.
9678    ///
9679    /// `packet` must be valid for the current buffer set, otherwise the service
9680    /// will close the connection.
9681    SendPacketNoReply {
9682        packet: StreamPacket,
9683        control_handle: AudioRendererControlHandle,
9684    },
9685    /// Indicates the stream has ended. The precise semantics of this method are
9686    /// determined by the inheriting interface.
9687    EndOfStream {
9688        control_handle: AudioRendererControlHandle,
9689    },
9690    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9691    /// and not yet released. The response is sent after all packets have been
9692    /// released.
9693    DiscardAllPackets {
9694        responder: AudioRendererDiscardAllPacketsResponder,
9695    },
9696    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
9697    /// and not yet released.
9698    DiscardAllPacketsNoReply {
9699        control_handle: AudioRendererControlHandle,
9700    },
9701    /// Binds to the gain control for this AudioRenderer.
9702    BindGainControl {
9703        gain_control_request:
9704            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
9705        control_handle: AudioRendererControlHandle,
9706    },
9707    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
9708    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
9709    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
9710    SetPtsUnits {
9711        tick_per_second_numerator: u32,
9712        tick_per_second_denominator: u32,
9713        control_handle: AudioRendererControlHandle,
9714    },
9715    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
9716    /// and expected PTS (determined using interpolation). Beyond this threshold,
9717    /// a stream is no longer considered 'continuous' by the renderer.
9718    ///
9719    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
9720    /// Most users should not need to change this value from its default.
9721    ///
9722    /// Example:
9723    /// A user is playing back 48KHz audio from a container, which also contains
9724    /// video and needs to be synchronized with the audio. The timestamps are
9725    /// provided explicitly per packet by the container, and expressed in mSec
9726    /// units. This means that a single tick of the media timeline (1 mSec)
9727    /// represents exactly 48 frames of audio. The application in this scenario
9728    /// delivers packets of audio to the AudioRenderer, each with exactly 470
9729    /// frames of audio, and each with an explicit timestamp set to the best
9730    /// possible representation of the presentation time (given this media
9731    /// clock's resolution). So, starting from zero, the timestamps would be..
9732    ///
9733    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
9734    ///
9735    /// In this example, attempting to use the presentation time to compute the
9736    /// starting frame number of the audio in the packet would be wrong the
9737    /// majority of the time. The first timestamp is correct (by definition), but
9738    /// it will be 24 packets before the timestamps and frame numbers come back
9739    /// into alignment (the 24th packet would start with the 11280th audio frame
9740    /// and have a PTS of exactly 235).
9741    ///
9742    /// One way to fix this situation is to set the PTS continuity threshold
9743    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
9744    /// the number of frames contained within a single tick of the media clock,
9745    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
9746    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
9747    /// explicitly provided PTS would be considered to be a continuation of the
9748    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
9749    /// would work well.
9750    ///
9751    /// Other possible uses:
9752    /// Users who are scheduling audio explicitly, relative to a clock which has
9753    /// not been configured as the reference clock, can use this value to control
9754    /// the maximum acceptable synchronization error before a discontinuity is
9755    /// introduced. E.g., if a user is scheduling audio based on a recovered
9756    /// common media clock, and has not published that clock as the reference
9757    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
9758    /// can accumulate before the AudioRenderer deliberately inserts a
9759    /// presentation discontinuity to account for the error.
9760    ///
9761    /// Users whose need to deal with a container where their timestamps may be
9762    /// even less correct than +/- 1/2 of a PTS tick may set this value to
9763    /// something larger. This should be the maximum level of inaccuracy present
9764    /// in the container timestamps, if known. Failing that, it could be set to
9765    /// the maximum tolerable level of drift error before absolute timestamps are
9766    /// explicitly obeyed. Finally, a user could set this number to a very large
9767    /// value (86400.0 seconds, for example) to effectively cause *all*
9768    /// timestamps to be ignored after the first, thus treating all audio as
9769    /// continuous with previously delivered packets. Conversely, users who wish
9770    /// to *always* explicitly schedule their audio packets exactly may specify
9771    /// a CT of 0.
9772    ///
9773    /// Note: explicitly specifying high-frequency PTS units reduces the default
9774    /// continuity threshold accordingly. Internally, this threshold is stored as an
9775    /// integer of 1/8192 subframes. The default threshold is computed as follows:
9776    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
9777    /// For this reason, specifying PTS units with a frequency greater than 8192x
9778    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
9779    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
9780    SetPtsContinuityThreshold {
9781        threshold_seconds: f32,
9782        control_handle: AudioRendererControlHandle,
9783    },
9784    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
9785    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
9786    GetReferenceClock {
9787        responder: AudioRendererGetReferenceClockResponder,
9788    },
9789    /// Sets the reference clock that controls this renderer's playback rate. If the input
9790    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
9791    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
9792    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
9793    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
9794    ///
9795    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
9796    /// cannot be called a second time (even if the renderer format has not yet been set).
9797    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
9798    /// diverge at some later time, they should create a clone of the monotonic clock, set
9799    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
9800    SetReferenceClock {
9801        reference_clock: Option<fidl::Clock>,
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    SetUsage {
9807        usage: AudioRenderUsage,
9808        control_handle: AudioRendererControlHandle,
9809    },
9810    /// Sets the usage of the render stream. This method may not be called after
9811    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9812    SetUsage2 {
9813        usage2: AudioRenderUsage2,
9814        control_handle: AudioRendererControlHandle,
9815    },
9816    /// Sets the type of the stream to be delivered by the client. Using this method implies
9817    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
9818    ///
9819    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
9820    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
9821    /// methods such as `SendPacket`/`SendPacketNoReply`.
9822    SetPcmStreamType {
9823        type_: AudioStreamType,
9824        control_handle: AudioRendererControlHandle,
9825    },
9826    /// Enables or disables notifications about changes to the minimum clock lead
9827    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
9828    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
9829    /// event with the current minimum lead time for the AudioRenderer. If the
9830    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
9831    /// new value. This behavior will continue until the user calls
9832    /// `EnableMinLeadTimeEvents(false)`.
9833    ///
9834    /// The minimum clock lead time is the amount of time ahead of the reference
9835    /// clock's understanding of "now" that packets needs to arrive (relative to
9836    /// the playback clock transformation) in order for the mixer to be able to
9837    /// mix packet. For example...
9838    ///
9839    /// + Let the PTS of packet X be P(X)
9840    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9841    ///   function is determined by the call to Play(...)
9842    /// + Let the minimum lead time be MLT
9843    ///
9844    /// If R(P(X)) < RefClock.Now() + MLT
9845    /// Then the packet is late, and some (or all) of the packet's payload will
9846    /// need to be skipped in order to present the packet at the scheduled time.
9847    ///
9848    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9849    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9850    /// is called before the AudioRenderer is routed, any played packets will be
9851    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9852    /// calling `Play`.
9853    EnableMinLeadTimeEvents {
9854        enabled: bool,
9855        control_handle: AudioRendererControlHandle,
9856    },
9857    ///
9858    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9859    /// there's little reason to do so. This is because lead time is a function
9860    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9861    /// If min lead time events are enabled before `SetPcmStreamType` (with
9862    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9863    /// response to `SetPcmStreamType`.
9864    GetMinLeadTime {
9865        responder: AudioRendererGetMinLeadTimeResponder,
9866    },
9867    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9868    /// of the media timeline, using specific values provided by the caller (or
9869    /// default values if not specified). In an optional callback, returns the
9870    /// timestamp values ultimately used -- these set the ongoing relationship
9871    /// between the media and reference timelines (i.e., how to translate between
9872    /// the domain of presentation timestamps, and the realm of local system
9873    /// time).
9874    ///
9875    /// Local system time is specified in units of nanoseconds; media_time is
9876    /// specified in the units defined by the user in the `SetPtsUnits` function,
9877    /// or nanoseconds if `SetPtsUnits` is not called.
9878    ///
9879    /// The act of placing an AudioRenderer into the playback state establishes a
9880    /// relationship between 1) the user-defined media (or presentation) timeline
9881    /// for this particular AudioRenderer, and 2) the real-world system reference
9882    /// timeline. To communicate how to translate between timelines, the Play()
9883    /// callback provides an equivalent timestamp in each time domain. The first
9884    /// value ('reference_time') is given in terms of this renderer's reference
9885    /// clock; the second value ('media_time') is what media instant exactly
9886    /// corresponds to that local time. Restated, the frame at 'media_time' in
9887    /// the audio stream should be presented at 'reference_time' according to
9888    /// the reference clock.
9889    ///
9890    /// Note: on calling this API, media_time immediately starts advancing. It is
9891    /// possible (if uncommon) for a caller to specify a system time that is
9892    /// far in the past, or far into the future. This, along with the specified
9893    /// media time, is simply used to determine what media time corresponds to
9894    /// 'now', and THAT media time is then intersected with presentation
9895    /// timestamps of packets already submitted, to determine which media frames
9896    /// should be presented next.
9897    ///
9898    /// With the corresponding reference_time and media_time values, a user can
9899    /// translate arbitrary time values from one timeline into the other. After
9900    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9901    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9902    /// any 'ref_time':
9903    ///
9904    /// media_time = ( (ref_time - ref_start) / 1e9
9905    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9906    ///              + media_start
9907    ///
9908    /// Conversely, for any presentation timestamp 'media_time':
9909    ///
9910    /// ref_time = ( (media_time - media_start)
9911    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9912    ///              * 1e9 )
9913    ///            + ref_start
9914    ///
9915    /// Users, depending on their use case, may optionally choose not to specify
9916    /// one or both of these timestamps. A timestamp may be omitted by supplying
9917    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9918    /// any omitted timestamp value using the following rules:
9919    ///
9920    /// Reference Time
9921    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9922    /// reference time to begin presentation, based on the minimum lead times for
9923    /// the output devices that are currently bound to this AudioRenderer. For
9924    /// example, if an AudioRenderer is bound to an internal audio output
9925    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9926    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9927    /// is omitted) select a reference time 80 mSec from now.
9928    ///
9929    /// Media Time
9930    /// If media_time is omitted, the AudioRenderer will select one of two
9931    /// values.
9932    /// - If the AudioRenderer is resuming from the paused state, and packets
9933    /// have not been discarded since being paused, then the AudioRenderer will
9934    /// use a media_time corresponding to the instant at which the presentation
9935    /// became paused.
9936    /// - If the AudioRenderer is being placed into a playing state for the first
9937    /// time following startup or a 'discard packets' operation, the initial
9938    /// media_time will be set to the PTS of the first payload in the pending
9939    /// packet queue. If the pending queue is empty, initial media_time will be
9940    /// set to zero.
9941    ///
9942    /// Return Value
9943    /// When requested, the AudioRenderer will return the 'reference_time' and
9944    /// 'media_time' which were selected and used (whether they were explicitly
9945    /// specified or not) in the return value of the play call.
9946    ///
9947    /// Examples
9948    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
9949    /// to start playing as soon as possible. The user may call Play without
9950    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
9951    ///
9952    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
9953    /// playback at a specified 'reference_time', in sync with some other media
9954    /// stream, either initially or after discarding packets. The user would call
9955    /// `Play(reference_time, NO_TIMESTAMP)`.
9956    ///
9957    /// 3. A user has queued some audio using `SendPacket`. The first of these
9958    /// packets has a PTS of zero, and the user wishes playback to begin as soon
9959    /// as possible, but wishes to skip all of the audio content between PTS 0
9960    /// and PTS 'media_time'. The user would call
9961    /// `Play(NO_TIMESTAMP, media_time)`.
9962    ///
9963    /// 4. A user has queued some audio using `SendPacket` and want to present
9964    /// this media in synch with another player in a different device. The
9965    /// coordinator of the group of distributed players sends an explicit
9966    /// message to each player telling them to begin presentation of audio at
9967    /// PTS 'media_time', at the time (based on the group's shared reference
9968    /// clock) 'reference_time'. Here the user would call
9969    /// `Play(reference_time, media_time)`.
9970    Play {
9971        reference_time: i64,
9972        media_time: i64,
9973        responder: AudioRendererPlayResponder,
9974    },
9975    PlayNoReply {
9976        reference_time: i64,
9977        media_time: i64,
9978        control_handle: AudioRendererControlHandle,
9979    },
9980    /// Immediately puts the AudioRenderer into the paused state and then report
9981    /// the relationship between the media and reference timelines which was
9982    /// established (if requested).
9983    ///
9984    /// If the AudioRenderer is already in the paused state when this called,
9985    /// the previously-established timeline values are returned (if requested).
9986    Pause {
9987        responder: AudioRendererPauseResponder,
9988    },
9989    PauseNoReply {
9990        control_handle: AudioRendererControlHandle,
9991    },
9992    /// An interaction was received which does not match any known method.
9993    #[non_exhaustive]
9994    _UnknownMethod {
9995        /// Ordinal of the method that was called.
9996        ordinal: u64,
9997        control_handle: AudioRendererControlHandle,
9998        method_type: fidl::MethodType,
9999    },
10000}
10001
10002impl AudioRendererRequest {
10003    #[allow(irrefutable_let_patterns)]
10004    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
10005        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10006        {
10007            Some((id, payload_buffer, control_handle))
10008        } else {
10009            None
10010        }
10011    }
10012
10013    #[allow(irrefutable_let_patterns)]
10014    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10015        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10016            Some((id, control_handle))
10017        } else {
10018            None
10019        }
10020    }
10021
10022    #[allow(irrefutable_let_patterns)]
10023    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10024        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10025            Some((packet, responder))
10026        } else {
10027            None
10028        }
10029    }
10030
10031    #[allow(irrefutable_let_patterns)]
10032    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10033        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10034            Some((packet, control_handle))
10035        } else {
10036            None
10037        }
10038    }
10039
10040    #[allow(irrefutable_let_patterns)]
10041    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10042        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10043            Some((control_handle))
10044        } else {
10045            None
10046        }
10047    }
10048
10049    #[allow(irrefutable_let_patterns)]
10050    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10051        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10052            Some((responder))
10053        } else {
10054            None
10055        }
10056    }
10057
10058    #[allow(irrefutable_let_patterns)]
10059    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10060        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10061            Some((control_handle))
10062        } else {
10063            None
10064        }
10065    }
10066
10067    #[allow(irrefutable_let_patterns)]
10068    pub fn into_bind_gain_control(
10069        self,
10070    ) -> Option<(
10071        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10072        AudioRendererControlHandle,
10073    )> {
10074        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10075        {
10076            Some((gain_control_request, control_handle))
10077        } else {
10078            None
10079        }
10080    }
10081
10082    #[allow(irrefutable_let_patterns)]
10083    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10084        if let AudioRendererRequest::SetPtsUnits {
10085            tick_per_second_numerator,
10086            tick_per_second_denominator,
10087            control_handle,
10088        } = self
10089        {
10090            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10091        } else {
10092            None
10093        }
10094    }
10095
10096    #[allow(irrefutable_let_patterns)]
10097    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10098        if let AudioRendererRequest::SetPtsContinuityThreshold {
10099            threshold_seconds,
10100            control_handle,
10101        } = self
10102        {
10103            Some((threshold_seconds, control_handle))
10104        } else {
10105            None
10106        }
10107    }
10108
10109    #[allow(irrefutable_let_patterns)]
10110    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10111        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10112            Some((responder))
10113        } else {
10114            None
10115        }
10116    }
10117
10118    #[allow(irrefutable_let_patterns)]
10119    pub fn into_set_reference_clock(
10120        self,
10121    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10122        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10123            Some((reference_clock, control_handle))
10124        } else {
10125            None
10126        }
10127    }
10128
10129    #[allow(irrefutable_let_patterns)]
10130    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10131        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10132            Some((usage, control_handle))
10133        } else {
10134            None
10135        }
10136    }
10137
10138    #[allow(irrefutable_let_patterns)]
10139    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10140        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10141            Some((usage2, control_handle))
10142        } else {
10143            None
10144        }
10145    }
10146
10147    #[allow(irrefutable_let_patterns)]
10148    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10149        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10150            Some((type_, control_handle))
10151        } else {
10152            None
10153        }
10154    }
10155
10156    #[allow(irrefutable_let_patterns)]
10157    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10158        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10159            Some((enabled, control_handle))
10160        } else {
10161            None
10162        }
10163    }
10164
10165    #[allow(irrefutable_let_patterns)]
10166    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10167        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10168            Some((responder))
10169        } else {
10170            None
10171        }
10172    }
10173
10174    #[allow(irrefutable_let_patterns)]
10175    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10176        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10177            Some((reference_time, media_time, responder))
10178        } else {
10179            None
10180        }
10181    }
10182
10183    #[allow(irrefutable_let_patterns)]
10184    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10185        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10186            self
10187        {
10188            Some((reference_time, media_time, control_handle))
10189        } else {
10190            None
10191        }
10192    }
10193
10194    #[allow(irrefutable_let_patterns)]
10195    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10196        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
10197    }
10198
10199    #[allow(irrefutable_let_patterns)]
10200    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10201        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10202            Some((control_handle))
10203        } else {
10204            None
10205        }
10206    }
10207
10208    /// Name of the method defined in FIDL
10209    pub fn method_name(&self) -> &'static str {
10210        match *self {
10211            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10212            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10213            AudioRendererRequest::SendPacket { .. } => "send_packet",
10214            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10215            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10216            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10217            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10218            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10219            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10220            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10221                "set_pts_continuity_threshold"
10222            }
10223            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10224            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10225            AudioRendererRequest::SetUsage { .. } => "set_usage",
10226            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10227            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10228            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10229            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10230            AudioRendererRequest::Play { .. } => "play",
10231            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10232            AudioRendererRequest::Pause { .. } => "pause",
10233            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10234            AudioRendererRequest::_UnknownMethod {
10235                method_type: fidl::MethodType::OneWay, ..
10236            } => "unknown one-way method",
10237            AudioRendererRequest::_UnknownMethod {
10238                method_type: fidl::MethodType::TwoWay, ..
10239            } => "unknown two-way method",
10240        }
10241    }
10242}
10243
10244#[derive(Debug, Clone)]
10245pub struct AudioRendererControlHandle {
10246    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10247}
10248
10249impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10250    fn shutdown(&self) {
10251        self.inner.shutdown()
10252    }
10253
10254    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10255        self.inner.shutdown_with_epitaph(status)
10256    }
10257
10258    fn is_closed(&self) -> bool {
10259        self.inner.channel().is_closed()
10260    }
10261    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10262        self.inner.channel().on_closed()
10263    }
10264
10265    #[cfg(target_os = "fuchsia")]
10266    fn signal_peer(
10267        &self,
10268        clear_mask: zx::Signals,
10269        set_mask: zx::Signals,
10270    ) -> Result<(), zx_status::Status> {
10271        use fidl::Peered;
10272        self.inner.channel().signal_peer(clear_mask, set_mask)
10273    }
10274}
10275
10276impl AudioRendererControlHandle {
10277    pub fn send_on_min_lead_time_changed(
10278        &self,
10279        mut min_lead_time_nsec: i64,
10280    ) -> Result<(), fidl::Error> {
10281        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10282            (min_lead_time_nsec,),
10283            0,
10284            0x4feff7d278978c4e,
10285            fidl::encoding::DynamicFlags::empty(),
10286        )
10287    }
10288}
10289
10290#[must_use = "FIDL methods require a response to be sent"]
10291#[derive(Debug)]
10292pub struct AudioRendererSendPacketResponder {
10293    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10294    tx_id: u32,
10295}
10296
10297/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10298/// if the responder is dropped without sending a response, so that the client
10299/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10300impl std::ops::Drop for AudioRendererSendPacketResponder {
10301    fn drop(&mut self) {
10302        self.control_handle.shutdown();
10303        // Safety: drops once, never accessed again
10304        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10305    }
10306}
10307
10308impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10309    type ControlHandle = AudioRendererControlHandle;
10310
10311    fn control_handle(&self) -> &AudioRendererControlHandle {
10312        &self.control_handle
10313    }
10314
10315    fn drop_without_shutdown(mut self) {
10316        // Safety: drops once, never accessed again due to mem::forget
10317        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10318        // Prevent Drop from running (which would shut down the channel)
10319        std::mem::forget(self);
10320    }
10321}
10322
10323impl AudioRendererSendPacketResponder {
10324    /// Sends a response to the FIDL transaction.
10325    ///
10326    /// Sets the channel to shutdown if an error occurs.
10327    pub fn send(self) -> Result<(), fidl::Error> {
10328        let _result = self.send_raw();
10329        if _result.is_err() {
10330            self.control_handle.shutdown();
10331        }
10332        self.drop_without_shutdown();
10333        _result
10334    }
10335
10336    /// Similar to "send" but does not shutdown the channel if an error occurs.
10337    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10338        let _result = self.send_raw();
10339        self.drop_without_shutdown();
10340        _result
10341    }
10342
10343    fn send_raw(&self) -> Result<(), fidl::Error> {
10344        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10345            (),
10346            self.tx_id,
10347            0x67cddd607442775f,
10348            fidl::encoding::DynamicFlags::empty(),
10349        )
10350    }
10351}
10352
10353#[must_use = "FIDL methods require a response to be sent"]
10354#[derive(Debug)]
10355pub struct AudioRendererDiscardAllPacketsResponder {
10356    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10357    tx_id: u32,
10358}
10359
10360/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10361/// if the responder is dropped without sending a response, so that the client
10362/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10363impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10364    fn drop(&mut self) {
10365        self.control_handle.shutdown();
10366        // Safety: drops once, never accessed again
10367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10368    }
10369}
10370
10371impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10372    type ControlHandle = AudioRendererControlHandle;
10373
10374    fn control_handle(&self) -> &AudioRendererControlHandle {
10375        &self.control_handle
10376    }
10377
10378    fn drop_without_shutdown(mut self) {
10379        // Safety: drops once, never accessed again due to mem::forget
10380        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10381        // Prevent Drop from running (which would shut down the channel)
10382        std::mem::forget(self);
10383    }
10384}
10385
10386impl AudioRendererDiscardAllPacketsResponder {
10387    /// Sends a response to the FIDL transaction.
10388    ///
10389    /// Sets the channel to shutdown if an error occurs.
10390    pub fn send(self) -> Result<(), fidl::Error> {
10391        let _result = self.send_raw();
10392        if _result.is_err() {
10393            self.control_handle.shutdown();
10394        }
10395        self.drop_without_shutdown();
10396        _result
10397    }
10398
10399    /// Similar to "send" but does not shutdown the channel if an error occurs.
10400    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10401        let _result = self.send_raw();
10402        self.drop_without_shutdown();
10403        _result
10404    }
10405
10406    fn send_raw(&self) -> Result<(), fidl::Error> {
10407        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10408            (),
10409            self.tx_id,
10410            0x6f4dad7af2917665,
10411            fidl::encoding::DynamicFlags::empty(),
10412        )
10413    }
10414}
10415
10416#[must_use = "FIDL methods require a response to be sent"]
10417#[derive(Debug)]
10418pub struct AudioRendererGetReferenceClockResponder {
10419    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10420    tx_id: u32,
10421}
10422
10423/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10424/// if the responder is dropped without sending a response, so that the client
10425/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10426impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10427    fn drop(&mut self) {
10428        self.control_handle.shutdown();
10429        // Safety: drops once, never accessed again
10430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10431    }
10432}
10433
10434impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10435    type ControlHandle = AudioRendererControlHandle;
10436
10437    fn control_handle(&self) -> &AudioRendererControlHandle {
10438        &self.control_handle
10439    }
10440
10441    fn drop_without_shutdown(mut self) {
10442        // Safety: drops once, never accessed again due to mem::forget
10443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10444        // Prevent Drop from running (which would shut down the channel)
10445        std::mem::forget(self);
10446    }
10447}
10448
10449impl AudioRendererGetReferenceClockResponder {
10450    /// Sends a response to the FIDL transaction.
10451    ///
10452    /// Sets the channel to shutdown if an error occurs.
10453    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10454        let _result = self.send_raw(reference_clock);
10455        if _result.is_err() {
10456            self.control_handle.shutdown();
10457        }
10458        self.drop_without_shutdown();
10459        _result
10460    }
10461
10462    /// Similar to "send" but does not shutdown the channel if an error occurs.
10463    pub fn send_no_shutdown_on_err(
10464        self,
10465        mut reference_clock: fidl::Clock,
10466    ) -> Result<(), fidl::Error> {
10467        let _result = self.send_raw(reference_clock);
10468        self.drop_without_shutdown();
10469        _result
10470    }
10471
10472    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10473        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10474            (reference_clock,),
10475            self.tx_id,
10476            0x2f7a7f011a172f7e,
10477            fidl::encoding::DynamicFlags::empty(),
10478        )
10479    }
10480}
10481
10482#[must_use = "FIDL methods require a response to be sent"]
10483#[derive(Debug)]
10484pub struct AudioRendererGetMinLeadTimeResponder {
10485    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10486    tx_id: u32,
10487}
10488
10489/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10490/// if the responder is dropped without sending a response, so that the client
10491/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10492impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10493    fn drop(&mut self) {
10494        self.control_handle.shutdown();
10495        // Safety: drops once, never accessed again
10496        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10497    }
10498}
10499
10500impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10501    type ControlHandle = AudioRendererControlHandle;
10502
10503    fn control_handle(&self) -> &AudioRendererControlHandle {
10504        &self.control_handle
10505    }
10506
10507    fn drop_without_shutdown(mut self) {
10508        // Safety: drops once, never accessed again due to mem::forget
10509        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10510        // Prevent Drop from running (which would shut down the channel)
10511        std::mem::forget(self);
10512    }
10513}
10514
10515impl AudioRendererGetMinLeadTimeResponder {
10516    /// Sends a response to the FIDL transaction.
10517    ///
10518    /// Sets the channel to shutdown if an error occurs.
10519    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10520        let _result = self.send_raw(min_lead_time_nsec);
10521        if _result.is_err() {
10522            self.control_handle.shutdown();
10523        }
10524        self.drop_without_shutdown();
10525        _result
10526    }
10527
10528    /// Similar to "send" but does not shutdown the channel if an error occurs.
10529    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10530        let _result = self.send_raw(min_lead_time_nsec);
10531        self.drop_without_shutdown();
10532        _result
10533    }
10534
10535    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10536        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10537            (min_lead_time_nsec,),
10538            self.tx_id,
10539            0x1cf3c3ecd8fec26b,
10540            fidl::encoding::DynamicFlags::empty(),
10541        )
10542    }
10543}
10544
10545#[must_use = "FIDL methods require a response to be sent"]
10546#[derive(Debug)]
10547pub struct AudioRendererPlayResponder {
10548    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10549    tx_id: u32,
10550}
10551
10552/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10553/// if the responder is dropped without sending a response, so that the client
10554/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10555impl std::ops::Drop for AudioRendererPlayResponder {
10556    fn drop(&mut self) {
10557        self.control_handle.shutdown();
10558        // Safety: drops once, never accessed again
10559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10560    }
10561}
10562
10563impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10564    type ControlHandle = AudioRendererControlHandle;
10565
10566    fn control_handle(&self) -> &AudioRendererControlHandle {
10567        &self.control_handle
10568    }
10569
10570    fn drop_without_shutdown(mut self) {
10571        // Safety: drops once, never accessed again due to mem::forget
10572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10573        // Prevent Drop from running (which would shut down the channel)
10574        std::mem::forget(self);
10575    }
10576}
10577
10578impl AudioRendererPlayResponder {
10579    /// Sends a response to the FIDL transaction.
10580    ///
10581    /// Sets the channel to shutdown if an error occurs.
10582    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10583        let _result = self.send_raw(reference_time, media_time);
10584        if _result.is_err() {
10585            self.control_handle.shutdown();
10586        }
10587        self.drop_without_shutdown();
10588        _result
10589    }
10590
10591    /// Similar to "send" but does not shutdown the channel if an error occurs.
10592    pub fn send_no_shutdown_on_err(
10593        self,
10594        mut reference_time: i64,
10595        mut media_time: i64,
10596    ) -> Result<(), fidl::Error> {
10597        let _result = self.send_raw(reference_time, media_time);
10598        self.drop_without_shutdown();
10599        _result
10600    }
10601
10602    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10603        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10604            (reference_time, media_time),
10605            self.tx_id,
10606            0x3c0162db084f74a3,
10607            fidl::encoding::DynamicFlags::empty(),
10608        )
10609    }
10610}
10611
10612#[must_use = "FIDL methods require a response to be sent"]
10613#[derive(Debug)]
10614pub struct AudioRendererPauseResponder {
10615    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10616    tx_id: u32,
10617}
10618
10619/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10620/// if the responder is dropped without sending a response, so that the client
10621/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10622impl std::ops::Drop for AudioRendererPauseResponder {
10623    fn drop(&mut self) {
10624        self.control_handle.shutdown();
10625        // Safety: drops once, never accessed again
10626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10627    }
10628}
10629
10630impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10631    type ControlHandle = AudioRendererControlHandle;
10632
10633    fn control_handle(&self) -> &AudioRendererControlHandle {
10634        &self.control_handle
10635    }
10636
10637    fn drop_without_shutdown(mut self) {
10638        // Safety: drops once, never accessed again due to mem::forget
10639        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10640        // Prevent Drop from running (which would shut down the channel)
10641        std::mem::forget(self);
10642    }
10643}
10644
10645impl AudioRendererPauseResponder {
10646    /// Sends a response to the FIDL transaction.
10647    ///
10648    /// Sets the channel to shutdown if an error occurs.
10649    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10650        let _result = self.send_raw(reference_time, media_time);
10651        if _result.is_err() {
10652            self.control_handle.shutdown();
10653        }
10654        self.drop_without_shutdown();
10655        _result
10656    }
10657
10658    /// Similar to "send" but does not shutdown the channel if an error occurs.
10659    pub fn send_no_shutdown_on_err(
10660        self,
10661        mut reference_time: i64,
10662        mut media_time: i64,
10663    ) -> Result<(), fidl::Error> {
10664        let _result = self.send_raw(reference_time, media_time);
10665        self.drop_without_shutdown();
10666        _result
10667    }
10668
10669    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10670        self.control_handle.inner.send::<AudioRendererPauseResponse>(
10671            (reference_time, media_time),
10672            self.tx_id,
10673            0x41d557588d93d153,
10674            fidl::encoding::DynamicFlags::empty(),
10675        )
10676    }
10677}
10678
10679#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10680pub struct ProfileProviderMarker;
10681
10682impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
10683    type Proxy = ProfileProviderProxy;
10684    type RequestStream = ProfileProviderRequestStream;
10685    #[cfg(target_os = "fuchsia")]
10686    type SynchronousProxy = ProfileProviderSynchronousProxy;
10687
10688    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
10689}
10690impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
10691
10692pub trait ProfileProviderProxyInterface: Send + Sync {
10693    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
10694        + Send;
10695    fn r#register_handler_with_capacity(
10696        &self,
10697        thread_handle: fidl::Thread,
10698        name: &str,
10699        period: i64,
10700        capacity: f32,
10701    ) -> Self::RegisterHandlerWithCapacityResponseFut;
10702    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10703    fn r#unregister_handler(
10704        &self,
10705        thread_handle: fidl::Thread,
10706        name: &str,
10707    ) -> Self::UnregisterHandlerResponseFut;
10708    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10709        + Send;
10710    fn r#register_memory_range(
10711        &self,
10712        vmar_handle: fidl::Vmar,
10713        name: &str,
10714    ) -> Self::RegisterMemoryRangeResponseFut;
10715    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
10716        + Send;
10717    fn r#unregister_memory_range(
10718        &self,
10719        vmar_handle: fidl::Vmar,
10720    ) -> Self::UnregisterMemoryRangeResponseFut;
10721}
10722#[derive(Debug)]
10723#[cfg(target_os = "fuchsia")]
10724pub struct ProfileProviderSynchronousProxy {
10725    client: fidl::client::sync::Client,
10726}
10727
10728#[cfg(target_os = "fuchsia")]
10729impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
10730    type Proxy = ProfileProviderProxy;
10731    type Protocol = ProfileProviderMarker;
10732
10733    fn from_channel(inner: fidl::Channel) -> Self {
10734        Self::new(inner)
10735    }
10736
10737    fn into_channel(self) -> fidl::Channel {
10738        self.client.into_channel()
10739    }
10740
10741    fn as_channel(&self) -> &fidl::Channel {
10742        self.client.as_channel()
10743    }
10744}
10745
10746#[cfg(target_os = "fuchsia")]
10747impl ProfileProviderSynchronousProxy {
10748    pub fn new(channel: fidl::Channel) -> Self {
10749        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10750        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
10751    }
10752
10753    pub fn into_channel(self) -> fidl::Channel {
10754        self.client.into_channel()
10755    }
10756
10757    /// Waits until an event arrives and returns it. It is safe for other
10758    /// threads to make concurrent requests while waiting for an event.
10759    pub fn wait_for_event(
10760        &self,
10761        deadline: zx::MonotonicInstant,
10762    ) -> Result<ProfileProviderEvent, fidl::Error> {
10763        ProfileProviderEvent::decode(self.client.wait_for_event(deadline)?)
10764    }
10765
10766    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10767    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10768    /// deadlines.
10769    ///
10770    /// `name` is the name of a system scheduling role to apply to the thread given by
10771    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10772    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10773    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10774    /// the scheduling interval the thread needs to be running to achieve good performance or to
10775    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10776    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10777    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10778    /// be rejected or result in scaling back the performance of other threads to fit resource
10779    /// limits.
10780    ///
10781    /// Capacity, max runtime, and period have the following relationship:
10782    ///
10783    ///   capacity = max runtime / period
10784    ///
10785    /// Where:
10786    ///
10787    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10788    ///
10789    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10790    /// performance processor(s) in the system. The system will automatically adjust the effective
10791    /// capacity to account for slower processors and operating points and will avoid processors and
10792    /// operating points that are too slow to meet the requested scheduling parameters (provided
10793    /// they are reasonable).
10794    ///
10795    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10796    /// may be zero to indicate not applicable.
10797    pub fn r#register_handler_with_capacity(
10798        &self,
10799        mut thread_handle: fidl::Thread,
10800        mut name: &str,
10801        mut period: i64,
10802        mut capacity: f32,
10803        ___deadline: zx::MonotonicInstant,
10804    ) -> Result<(i64, i64), fidl::Error> {
10805        let _response = self.client.send_query::<
10806            ProfileProviderRegisterHandlerWithCapacityRequest,
10807            ProfileProviderRegisterHandlerWithCapacityResponse,
10808        >(
10809            (thread_handle, name, period, capacity,),
10810            0x60459ecef7458176,
10811            fidl::encoding::DynamicFlags::empty(),
10812            ___deadline,
10813        )?;
10814        Ok((_response.period, _response.capacity))
10815    }
10816
10817    /// Reset a thread's scheduling profile to the default.
10818    pub fn r#unregister_handler(
10819        &self,
10820        mut thread_handle: fidl::Thread,
10821        mut name: &str,
10822        ___deadline: zx::MonotonicInstant,
10823    ) -> Result<(), fidl::Error> {
10824        let _response = self
10825            .client
10826            .send_query::<ProfileProviderUnregisterHandlerRequest, fidl::encoding::EmptyPayload>(
10827                (thread_handle, name),
10828                0x724d9d5fd8ef544c,
10829                fidl::encoding::DynamicFlags::empty(),
10830                ___deadline,
10831            )?;
10832        Ok(_response)
10833    }
10834
10835    /// Register a memory range as being used for media processing. This notifies the media
10836    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10837    /// meet audio or video deadlines.
10838    ///
10839    /// `name` is the name of a system memory role to apply to the memory given by
10840    /// `vmar_handle` -- different products may customize the underlying memory strategy based
10841    /// on the requested role.
10842    pub fn r#register_memory_range(
10843        &self,
10844        mut vmar_handle: fidl::Vmar,
10845        mut name: &str,
10846        ___deadline: zx::MonotonicInstant,
10847    ) -> Result<(), fidl::Error> {
10848        let _response = self
10849            .client
10850            .send_query::<ProfileProviderRegisterMemoryRangeRequest, fidl::encoding::EmptyPayload>(
10851                (vmar_handle, name),
10852                0x2f509d3523e9562d,
10853                fidl::encoding::DynamicFlags::empty(),
10854                ___deadline,
10855            )?;
10856        Ok(_response)
10857    }
10858
10859    /// Reset a memory range's memory profile.
10860    pub fn r#unregister_memory_range(
10861        &self,
10862        mut vmar_handle: fidl::Vmar,
10863        ___deadline: zx::MonotonicInstant,
10864    ) -> Result<(), fidl::Error> {
10865        let _response = self.client.send_query::<
10866            ProfileProviderUnregisterMemoryRangeRequest,
10867            fidl::encoding::EmptyPayload,
10868        >(
10869            (vmar_handle,),
10870            0x2dc313d6aa81ad27,
10871            fidl::encoding::DynamicFlags::empty(),
10872            ___deadline,
10873        )?;
10874        Ok(_response)
10875    }
10876}
10877
10878#[cfg(target_os = "fuchsia")]
10879impl From<ProfileProviderSynchronousProxy> for zx::NullableHandle {
10880    fn from(value: ProfileProviderSynchronousProxy) -> Self {
10881        value.into_channel().into()
10882    }
10883}
10884
10885#[cfg(target_os = "fuchsia")]
10886impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
10887    fn from(value: fidl::Channel) -> Self {
10888        Self::new(value)
10889    }
10890}
10891
10892#[cfg(target_os = "fuchsia")]
10893impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
10894    type Protocol = ProfileProviderMarker;
10895
10896    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
10897        Self::new(value.into_channel())
10898    }
10899}
10900
10901#[derive(Debug, Clone)]
10902pub struct ProfileProviderProxy {
10903    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
10904}
10905
10906impl fidl::endpoints::Proxy for ProfileProviderProxy {
10907    type Protocol = ProfileProviderMarker;
10908
10909    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
10910        Self::new(inner)
10911    }
10912
10913    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
10914        self.client.into_channel().map_err(|client| Self { client })
10915    }
10916
10917    fn as_channel(&self) -> &::fidl::AsyncChannel {
10918        self.client.as_channel()
10919    }
10920}
10921
10922impl ProfileProviderProxy {
10923    /// Create a new Proxy for fuchsia.media/ProfileProvider.
10924    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
10925        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
10926        Self { client: fidl::client::Client::new(channel, protocol_name) }
10927    }
10928
10929    /// Get a Stream of events from the remote end of the protocol.
10930    ///
10931    /// # Panics
10932    ///
10933    /// Panics if the event stream was already taken.
10934    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
10935        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
10936    }
10937
10938    /// Register a thread as a media thread. This notifies the media subsystem that this thread
10939    /// should have an elevated scheduling profile applied to it in order to meet audio or video
10940    /// deadlines.
10941    ///
10942    /// `name` is the name of a system scheduling role to apply to the thread given by
10943    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
10944    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
10945    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
10946    /// the scheduling interval the thread needs to be running to achieve good performance or to
10947    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
10948    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
10949    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
10950    /// be rejected or result in scaling back the performance of other threads to fit resource
10951    /// limits.
10952    ///
10953    /// Capacity, max runtime, and period have the following relationship:
10954    ///
10955    ///   capacity = max runtime / period
10956    ///
10957    /// Where:
10958    ///
10959    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
10960    ///
10961    /// For heterogeneous systems, the capacity should be planned / measured against the highest
10962    /// performance processor(s) in the system. The system will automatically adjust the effective
10963    /// capacity to account for slower processors and operating points and will avoid processors and
10964    /// operating points that are too slow to meet the requested scheduling parameters (provided
10965    /// they are reasonable).
10966    ///
10967    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
10968    /// may be zero to indicate not applicable.
10969    pub fn r#register_handler_with_capacity(
10970        &self,
10971        mut thread_handle: fidl::Thread,
10972        mut name: &str,
10973        mut period: i64,
10974        mut capacity: f32,
10975    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
10976    {
10977        ProfileProviderProxyInterface::r#register_handler_with_capacity(
10978            self,
10979            thread_handle,
10980            name,
10981            period,
10982            capacity,
10983        )
10984    }
10985
10986    /// Reset a thread's scheduling profile to the default.
10987    pub fn r#unregister_handler(
10988        &self,
10989        mut thread_handle: fidl::Thread,
10990        mut name: &str,
10991    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
10992        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
10993    }
10994
10995    /// Register a memory range as being used for media processing. This notifies the media
10996    /// subsystem that this memory should have an elevated memory profile applied to it in order to
10997    /// meet audio or video deadlines.
10998    ///
10999    /// `name` is the name of a system memory role to apply to the memory given by
11000    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11001    /// on the requested role.
11002    pub fn r#register_memory_range(
11003        &self,
11004        mut vmar_handle: fidl::Vmar,
11005        mut name: &str,
11006    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11007        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11008    }
11009
11010    /// Reset a memory range's memory profile.
11011    pub fn r#unregister_memory_range(
11012        &self,
11013        mut vmar_handle: fidl::Vmar,
11014    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11015        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11016    }
11017}
11018
11019impl ProfileProviderProxyInterface for ProfileProviderProxy {
11020    type RegisterHandlerWithCapacityResponseFut =
11021        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11022    fn r#register_handler_with_capacity(
11023        &self,
11024        mut thread_handle: fidl::Thread,
11025        mut name: &str,
11026        mut period: i64,
11027        mut capacity: f32,
11028    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11029        fn _decode(
11030            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11031        ) -> Result<(i64, i64), fidl::Error> {
11032            let _response = fidl::client::decode_transaction_body::<
11033                ProfileProviderRegisterHandlerWithCapacityResponse,
11034                fidl::encoding::DefaultFuchsiaResourceDialect,
11035                0x60459ecef7458176,
11036            >(_buf?)?;
11037            Ok((_response.period, _response.capacity))
11038        }
11039        self.client
11040            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11041                (thread_handle, name, period, capacity),
11042                0x60459ecef7458176,
11043                fidl::encoding::DynamicFlags::empty(),
11044                _decode,
11045            )
11046    }
11047
11048    type UnregisterHandlerResponseFut =
11049        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11050    fn r#unregister_handler(
11051        &self,
11052        mut thread_handle: fidl::Thread,
11053        mut name: &str,
11054    ) -> Self::UnregisterHandlerResponseFut {
11055        fn _decode(
11056            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11057        ) -> Result<(), fidl::Error> {
11058            let _response = fidl::client::decode_transaction_body::<
11059                fidl::encoding::EmptyPayload,
11060                fidl::encoding::DefaultFuchsiaResourceDialect,
11061                0x724d9d5fd8ef544c,
11062            >(_buf?)?;
11063            Ok(_response)
11064        }
11065        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11066            (thread_handle, name),
11067            0x724d9d5fd8ef544c,
11068            fidl::encoding::DynamicFlags::empty(),
11069            _decode,
11070        )
11071    }
11072
11073    type RegisterMemoryRangeResponseFut =
11074        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11075    fn r#register_memory_range(
11076        &self,
11077        mut vmar_handle: fidl::Vmar,
11078        mut name: &str,
11079    ) -> Self::RegisterMemoryRangeResponseFut {
11080        fn _decode(
11081            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11082        ) -> Result<(), fidl::Error> {
11083            let _response = fidl::client::decode_transaction_body::<
11084                fidl::encoding::EmptyPayload,
11085                fidl::encoding::DefaultFuchsiaResourceDialect,
11086                0x2f509d3523e9562d,
11087            >(_buf?)?;
11088            Ok(_response)
11089        }
11090        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11091            (vmar_handle, name),
11092            0x2f509d3523e9562d,
11093            fidl::encoding::DynamicFlags::empty(),
11094            _decode,
11095        )
11096    }
11097
11098    type UnregisterMemoryRangeResponseFut =
11099        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11100    fn r#unregister_memory_range(
11101        &self,
11102        mut vmar_handle: fidl::Vmar,
11103    ) -> Self::UnregisterMemoryRangeResponseFut {
11104        fn _decode(
11105            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11106        ) -> Result<(), fidl::Error> {
11107            let _response = fidl::client::decode_transaction_body::<
11108                fidl::encoding::EmptyPayload,
11109                fidl::encoding::DefaultFuchsiaResourceDialect,
11110                0x2dc313d6aa81ad27,
11111            >(_buf?)?;
11112            Ok(_response)
11113        }
11114        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11115            (vmar_handle,),
11116            0x2dc313d6aa81ad27,
11117            fidl::encoding::DynamicFlags::empty(),
11118            _decode,
11119        )
11120    }
11121}
11122
11123pub struct ProfileProviderEventStream {
11124    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11125}
11126
11127impl std::marker::Unpin for ProfileProviderEventStream {}
11128
11129impl futures::stream::FusedStream for ProfileProviderEventStream {
11130    fn is_terminated(&self) -> bool {
11131        self.event_receiver.is_terminated()
11132    }
11133}
11134
11135impl futures::Stream for ProfileProviderEventStream {
11136    type Item = Result<ProfileProviderEvent, fidl::Error>;
11137
11138    fn poll_next(
11139        mut self: std::pin::Pin<&mut Self>,
11140        cx: &mut std::task::Context<'_>,
11141    ) -> std::task::Poll<Option<Self::Item>> {
11142        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11143            &mut self.event_receiver,
11144            cx
11145        )?) {
11146            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11147            None => std::task::Poll::Ready(None),
11148        }
11149    }
11150}
11151
11152#[derive(Debug)]
11153pub enum ProfileProviderEvent {}
11154
11155impl ProfileProviderEvent {
11156    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11157    fn decode(
11158        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11159    ) -> Result<ProfileProviderEvent, fidl::Error> {
11160        let (bytes, _handles) = buf.split_mut();
11161        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11162        debug_assert_eq!(tx_header.tx_id, 0);
11163        match tx_header.ordinal {
11164            _ => Err(fidl::Error::UnknownOrdinal {
11165                ordinal: tx_header.ordinal,
11166                protocol_name:
11167                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11168            }),
11169        }
11170    }
11171}
11172
11173/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11174pub struct ProfileProviderRequestStream {
11175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11176    is_terminated: bool,
11177}
11178
11179impl std::marker::Unpin for ProfileProviderRequestStream {}
11180
11181impl futures::stream::FusedStream for ProfileProviderRequestStream {
11182    fn is_terminated(&self) -> bool {
11183        self.is_terminated
11184    }
11185}
11186
11187impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11188    type Protocol = ProfileProviderMarker;
11189    type ControlHandle = ProfileProviderControlHandle;
11190
11191    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11192        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11193    }
11194
11195    fn control_handle(&self) -> Self::ControlHandle {
11196        ProfileProviderControlHandle { inner: self.inner.clone() }
11197    }
11198
11199    fn into_inner(
11200        self,
11201    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11202    {
11203        (self.inner, self.is_terminated)
11204    }
11205
11206    fn from_inner(
11207        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11208        is_terminated: bool,
11209    ) -> Self {
11210        Self { inner, is_terminated }
11211    }
11212}
11213
11214impl futures::Stream for ProfileProviderRequestStream {
11215    type Item = Result<ProfileProviderRequest, fidl::Error>;
11216
11217    fn poll_next(
11218        mut self: std::pin::Pin<&mut Self>,
11219        cx: &mut std::task::Context<'_>,
11220    ) -> std::task::Poll<Option<Self::Item>> {
11221        let this = &mut *self;
11222        if this.inner.check_shutdown(cx) {
11223            this.is_terminated = true;
11224            return std::task::Poll::Ready(None);
11225        }
11226        if this.is_terminated {
11227            panic!("polled ProfileProviderRequestStream after completion");
11228        }
11229        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11230            |bytes, handles| {
11231                match this.inner.channel().read_etc(cx, bytes, handles) {
11232                    std::task::Poll::Ready(Ok(())) => {}
11233                    std::task::Poll::Pending => return std::task::Poll::Pending,
11234                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11235                        this.is_terminated = true;
11236                        return std::task::Poll::Ready(None);
11237                    }
11238                    std::task::Poll::Ready(Err(e)) => {
11239                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11240                            e.into(),
11241                        ))));
11242                    }
11243                }
11244
11245                // A message has been received from the channel
11246                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11247
11248                std::task::Poll::Ready(Some(match header.ordinal {
11249                    0x60459ecef7458176 => {
11250                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11251                        let mut req = fidl::new_empty!(
11252                            ProfileProviderRegisterHandlerWithCapacityRequest,
11253                            fidl::encoding::DefaultFuchsiaResourceDialect
11254                        );
11255                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11256                        let control_handle =
11257                            ProfileProviderControlHandle { inner: this.inner.clone() };
11258                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11259                            thread_handle: req.thread_handle,
11260                            name: req.name,
11261                            period: req.period,
11262                            capacity: req.capacity,
11263
11264                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11265                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11266                                tx_id: header.tx_id,
11267                            },
11268                        })
11269                    }
11270                    0x724d9d5fd8ef544c => {
11271                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11272                        let mut req = fidl::new_empty!(
11273                            ProfileProviderUnregisterHandlerRequest,
11274                            fidl::encoding::DefaultFuchsiaResourceDialect
11275                        );
11276                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11277                        let control_handle =
11278                            ProfileProviderControlHandle { inner: this.inner.clone() };
11279                        Ok(ProfileProviderRequest::UnregisterHandler {
11280                            thread_handle: req.thread_handle,
11281                            name: req.name,
11282
11283                            responder: ProfileProviderUnregisterHandlerResponder {
11284                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11285                                tx_id: header.tx_id,
11286                            },
11287                        })
11288                    }
11289                    0x2f509d3523e9562d => {
11290                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11291                        let mut req = fidl::new_empty!(
11292                            ProfileProviderRegisterMemoryRangeRequest,
11293                            fidl::encoding::DefaultFuchsiaResourceDialect
11294                        );
11295                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11296                        let control_handle =
11297                            ProfileProviderControlHandle { inner: this.inner.clone() };
11298                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11299                            vmar_handle: req.vmar_handle,
11300                            name: req.name,
11301
11302                            responder: ProfileProviderRegisterMemoryRangeResponder {
11303                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11304                                tx_id: header.tx_id,
11305                            },
11306                        })
11307                    }
11308                    0x2dc313d6aa81ad27 => {
11309                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11310                        let mut req = fidl::new_empty!(
11311                            ProfileProviderUnregisterMemoryRangeRequest,
11312                            fidl::encoding::DefaultFuchsiaResourceDialect
11313                        );
11314                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11315                        let control_handle =
11316                            ProfileProviderControlHandle { inner: this.inner.clone() };
11317                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11318                            vmar_handle: req.vmar_handle,
11319
11320                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11321                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11322                                tx_id: header.tx_id,
11323                            },
11324                        })
11325                    }
11326                    _ => Err(fidl::Error::UnknownOrdinal {
11327                        ordinal: header.ordinal,
11328                        protocol_name:
11329                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11330                    }),
11331                }))
11332            },
11333        )
11334    }
11335}
11336
11337#[derive(Debug)]
11338pub enum ProfileProviderRequest {
11339    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11340    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11341    /// deadlines.
11342    ///
11343    /// `name` is the name of a system scheduling role to apply to the thread given by
11344    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11345    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11346    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11347    /// the scheduling interval the thread needs to be running to achieve good performance or to
11348    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11349    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11350    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11351    /// be rejected or result in scaling back the performance of other threads to fit resource
11352    /// limits.
11353    ///
11354    /// Capacity, max runtime, and period have the following relationship:
11355    ///
11356    ///   capacity = max runtime / period
11357    ///
11358    /// Where:
11359    ///
11360    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11361    ///
11362    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11363    /// performance processor(s) in the system. The system will automatically adjust the effective
11364    /// capacity to account for slower processors and operating points and will avoid processors and
11365    /// operating points that are too slow to meet the requested scheduling parameters (provided
11366    /// they are reasonable).
11367    ///
11368    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11369    /// may be zero to indicate not applicable.
11370    RegisterHandlerWithCapacity {
11371        thread_handle: fidl::Thread,
11372        name: String,
11373        period: i64,
11374        capacity: f32,
11375        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11376    },
11377    /// Reset a thread's scheduling profile to the default.
11378    UnregisterHandler {
11379        thread_handle: fidl::Thread,
11380        name: String,
11381        responder: ProfileProviderUnregisterHandlerResponder,
11382    },
11383    /// Register a memory range as being used for media processing. This notifies the media
11384    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11385    /// meet audio or video deadlines.
11386    ///
11387    /// `name` is the name of a system memory role to apply to the memory given by
11388    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11389    /// on the requested role.
11390    RegisterMemoryRange {
11391        vmar_handle: fidl::Vmar,
11392        name: String,
11393        responder: ProfileProviderRegisterMemoryRangeResponder,
11394    },
11395    /// Reset a memory range's memory profile.
11396    UnregisterMemoryRange {
11397        vmar_handle: fidl::Vmar,
11398        responder: ProfileProviderUnregisterMemoryRangeResponder,
11399    },
11400}
11401
11402impl ProfileProviderRequest {
11403    #[allow(irrefutable_let_patterns)]
11404    pub fn into_register_handler_with_capacity(
11405        self,
11406    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11407    {
11408        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11409            thread_handle,
11410            name,
11411            period,
11412            capacity,
11413            responder,
11414        } = self
11415        {
11416            Some((thread_handle, name, period, capacity, responder))
11417        } else {
11418            None
11419        }
11420    }
11421
11422    #[allow(irrefutable_let_patterns)]
11423    pub fn into_unregister_handler(
11424        self,
11425    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11426        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11427            Some((thread_handle, name, responder))
11428        } else {
11429            None
11430        }
11431    }
11432
11433    #[allow(irrefutable_let_patterns)]
11434    pub fn into_register_memory_range(
11435        self,
11436    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11437        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11438            Some((vmar_handle, name, responder))
11439        } else {
11440            None
11441        }
11442    }
11443
11444    #[allow(irrefutable_let_patterns)]
11445    pub fn into_unregister_memory_range(
11446        self,
11447    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11448        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11449            Some((vmar_handle, responder))
11450        } else {
11451            None
11452        }
11453    }
11454
11455    /// Name of the method defined in FIDL
11456    pub fn method_name(&self) -> &'static str {
11457        match *self {
11458            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11459                "register_handler_with_capacity"
11460            }
11461            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11462            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11463            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11464        }
11465    }
11466}
11467
11468#[derive(Debug, Clone)]
11469pub struct ProfileProviderControlHandle {
11470    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11471}
11472
11473impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11474    fn shutdown(&self) {
11475        self.inner.shutdown()
11476    }
11477
11478    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11479        self.inner.shutdown_with_epitaph(status)
11480    }
11481
11482    fn is_closed(&self) -> bool {
11483        self.inner.channel().is_closed()
11484    }
11485    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11486        self.inner.channel().on_closed()
11487    }
11488
11489    #[cfg(target_os = "fuchsia")]
11490    fn signal_peer(
11491        &self,
11492        clear_mask: zx::Signals,
11493        set_mask: zx::Signals,
11494    ) -> Result<(), zx_status::Status> {
11495        use fidl::Peered;
11496        self.inner.channel().signal_peer(clear_mask, set_mask)
11497    }
11498}
11499
11500impl ProfileProviderControlHandle {}
11501
11502#[must_use = "FIDL methods require a response to be sent"]
11503#[derive(Debug)]
11504pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11505    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11506    tx_id: u32,
11507}
11508
11509/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11510/// if the responder is dropped without sending a response, so that the client
11511/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11512impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11513    fn drop(&mut self) {
11514        self.control_handle.shutdown();
11515        // Safety: drops once, never accessed again
11516        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11517    }
11518}
11519
11520impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11521    type ControlHandle = ProfileProviderControlHandle;
11522
11523    fn control_handle(&self) -> &ProfileProviderControlHandle {
11524        &self.control_handle
11525    }
11526
11527    fn drop_without_shutdown(mut self) {
11528        // Safety: drops once, never accessed again due to mem::forget
11529        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11530        // Prevent Drop from running (which would shut down the channel)
11531        std::mem::forget(self);
11532    }
11533}
11534
11535impl ProfileProviderRegisterHandlerWithCapacityResponder {
11536    /// Sends a response to the FIDL transaction.
11537    ///
11538    /// Sets the channel to shutdown if an error occurs.
11539    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11540        let _result = self.send_raw(period, capacity);
11541        if _result.is_err() {
11542            self.control_handle.shutdown();
11543        }
11544        self.drop_without_shutdown();
11545        _result
11546    }
11547
11548    /// Similar to "send" but does not shutdown the channel if an error occurs.
11549    pub fn send_no_shutdown_on_err(
11550        self,
11551        mut period: i64,
11552        mut capacity: i64,
11553    ) -> Result<(), fidl::Error> {
11554        let _result = self.send_raw(period, capacity);
11555        self.drop_without_shutdown();
11556        _result
11557    }
11558
11559    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11560        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11561            (period, capacity),
11562            self.tx_id,
11563            0x60459ecef7458176,
11564            fidl::encoding::DynamicFlags::empty(),
11565        )
11566    }
11567}
11568
11569#[must_use = "FIDL methods require a response to be sent"]
11570#[derive(Debug)]
11571pub struct ProfileProviderUnregisterHandlerResponder {
11572    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11573    tx_id: u32,
11574}
11575
11576/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11577/// if the responder is dropped without sending a response, so that the client
11578/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11579impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11580    fn drop(&mut self) {
11581        self.control_handle.shutdown();
11582        // Safety: drops once, never accessed again
11583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11584    }
11585}
11586
11587impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11588    type ControlHandle = ProfileProviderControlHandle;
11589
11590    fn control_handle(&self) -> &ProfileProviderControlHandle {
11591        &self.control_handle
11592    }
11593
11594    fn drop_without_shutdown(mut self) {
11595        // Safety: drops once, never accessed again due to mem::forget
11596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11597        // Prevent Drop from running (which would shut down the channel)
11598        std::mem::forget(self);
11599    }
11600}
11601
11602impl ProfileProviderUnregisterHandlerResponder {
11603    /// Sends a response to the FIDL transaction.
11604    ///
11605    /// Sets the channel to shutdown if an error occurs.
11606    pub fn send(self) -> Result<(), fidl::Error> {
11607        let _result = self.send_raw();
11608        if _result.is_err() {
11609            self.control_handle.shutdown();
11610        }
11611        self.drop_without_shutdown();
11612        _result
11613    }
11614
11615    /// Similar to "send" but does not shutdown the channel if an error occurs.
11616    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11617        let _result = self.send_raw();
11618        self.drop_without_shutdown();
11619        _result
11620    }
11621
11622    fn send_raw(&self) -> Result<(), fidl::Error> {
11623        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11624            (),
11625            self.tx_id,
11626            0x724d9d5fd8ef544c,
11627            fidl::encoding::DynamicFlags::empty(),
11628        )
11629    }
11630}
11631
11632#[must_use = "FIDL methods require a response to be sent"]
11633#[derive(Debug)]
11634pub struct ProfileProviderRegisterMemoryRangeResponder {
11635    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11636    tx_id: u32,
11637}
11638
11639/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11640/// if the responder is dropped without sending a response, so that the client
11641/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11642impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
11643    fn drop(&mut self) {
11644        self.control_handle.shutdown();
11645        // Safety: drops once, never accessed again
11646        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11647    }
11648}
11649
11650impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
11651    type ControlHandle = ProfileProviderControlHandle;
11652
11653    fn control_handle(&self) -> &ProfileProviderControlHandle {
11654        &self.control_handle
11655    }
11656
11657    fn drop_without_shutdown(mut self) {
11658        // Safety: drops once, never accessed again due to mem::forget
11659        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11660        // Prevent Drop from running (which would shut down the channel)
11661        std::mem::forget(self);
11662    }
11663}
11664
11665impl ProfileProviderRegisterMemoryRangeResponder {
11666    /// Sends a response to the FIDL transaction.
11667    ///
11668    /// Sets the channel to shutdown if an error occurs.
11669    pub fn send(self) -> Result<(), fidl::Error> {
11670        let _result = self.send_raw();
11671        if _result.is_err() {
11672            self.control_handle.shutdown();
11673        }
11674        self.drop_without_shutdown();
11675        _result
11676    }
11677
11678    /// Similar to "send" but does not shutdown the channel if an error occurs.
11679    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11680        let _result = self.send_raw();
11681        self.drop_without_shutdown();
11682        _result
11683    }
11684
11685    fn send_raw(&self) -> Result<(), fidl::Error> {
11686        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11687            (),
11688            self.tx_id,
11689            0x2f509d3523e9562d,
11690            fidl::encoding::DynamicFlags::empty(),
11691        )
11692    }
11693}
11694
11695#[must_use = "FIDL methods require a response to be sent"]
11696#[derive(Debug)]
11697pub struct ProfileProviderUnregisterMemoryRangeResponder {
11698    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11699    tx_id: u32,
11700}
11701
11702/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11703/// if the responder is dropped without sending a response, so that the client
11704/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11705impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
11706    fn drop(&mut self) {
11707        self.control_handle.shutdown();
11708        // Safety: drops once, never accessed again
11709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11710    }
11711}
11712
11713impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
11714    type ControlHandle = ProfileProviderControlHandle;
11715
11716    fn control_handle(&self) -> &ProfileProviderControlHandle {
11717        &self.control_handle
11718    }
11719
11720    fn drop_without_shutdown(mut self) {
11721        // Safety: drops once, never accessed again due to mem::forget
11722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11723        // Prevent Drop from running (which would shut down the channel)
11724        std::mem::forget(self);
11725    }
11726}
11727
11728impl ProfileProviderUnregisterMemoryRangeResponder {
11729    /// Sends a response to the FIDL transaction.
11730    ///
11731    /// Sets the channel to shutdown if an error occurs.
11732    pub fn send(self) -> Result<(), fidl::Error> {
11733        let _result = self.send_raw();
11734        if _result.is_err() {
11735            self.control_handle.shutdown();
11736        }
11737        self.drop_without_shutdown();
11738        _result
11739    }
11740
11741    /// Similar to "send" but does not shutdown the channel if an error occurs.
11742    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11743        let _result = self.send_raw();
11744        self.drop_without_shutdown();
11745        _result
11746    }
11747
11748    fn send_raw(&self) -> Result<(), fidl::Error> {
11749        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11750            (),
11751            self.tx_id,
11752            0x2dc313d6aa81ad27,
11753            fidl::encoding::DynamicFlags::empty(),
11754        )
11755    }
11756}
11757
11758#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11759pub struct SessionAudioConsumerFactoryMarker;
11760
11761impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
11762    type Proxy = SessionAudioConsumerFactoryProxy;
11763    type RequestStream = SessionAudioConsumerFactoryRequestStream;
11764    #[cfg(target_os = "fuchsia")]
11765    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
11766
11767    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
11768}
11769impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
11770
11771pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
11772    fn r#create_audio_consumer(
11773        &self,
11774        session_id: u64,
11775        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11776    ) -> Result<(), fidl::Error>;
11777}
11778#[derive(Debug)]
11779#[cfg(target_os = "fuchsia")]
11780pub struct SessionAudioConsumerFactorySynchronousProxy {
11781    client: fidl::client::sync::Client,
11782}
11783
11784#[cfg(target_os = "fuchsia")]
11785impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
11786    type Proxy = SessionAudioConsumerFactoryProxy;
11787    type Protocol = SessionAudioConsumerFactoryMarker;
11788
11789    fn from_channel(inner: fidl::Channel) -> Self {
11790        Self::new(inner)
11791    }
11792
11793    fn into_channel(self) -> fidl::Channel {
11794        self.client.into_channel()
11795    }
11796
11797    fn as_channel(&self) -> &fidl::Channel {
11798        self.client.as_channel()
11799    }
11800}
11801
11802#[cfg(target_os = "fuchsia")]
11803impl SessionAudioConsumerFactorySynchronousProxy {
11804    pub fn new(channel: fidl::Channel) -> Self {
11805        let protocol_name =
11806            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11807        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
11808    }
11809
11810    pub fn into_channel(self) -> fidl::Channel {
11811        self.client.into_channel()
11812    }
11813
11814    /// Waits until an event arrives and returns it. It is safe for other
11815    /// threads to make concurrent requests while waiting for an event.
11816    pub fn wait_for_event(
11817        &self,
11818        deadline: zx::MonotonicInstant,
11819    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11820        SessionAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
11821    }
11822
11823    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11824    /// to a particular session. `session_id` is the identifier of the media session
11825    /// for which audio is to be rendered.
11826    pub fn r#create_audio_consumer(
11827        &self,
11828        mut session_id: u64,
11829        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11830    ) -> Result<(), fidl::Error> {
11831        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11832            (session_id, audio_consumer_request),
11833            0x6fab96f988e7d7fb,
11834            fidl::encoding::DynamicFlags::empty(),
11835        )
11836    }
11837}
11838
11839#[cfg(target_os = "fuchsia")]
11840impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
11841    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
11842        value.into_channel().into()
11843    }
11844}
11845
11846#[cfg(target_os = "fuchsia")]
11847impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
11848    fn from(value: fidl::Channel) -> Self {
11849        Self::new(value)
11850    }
11851}
11852
11853#[cfg(target_os = "fuchsia")]
11854impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
11855    type Protocol = SessionAudioConsumerFactoryMarker;
11856
11857    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
11858        Self::new(value.into_channel())
11859    }
11860}
11861
11862#[derive(Debug, Clone)]
11863pub struct SessionAudioConsumerFactoryProxy {
11864    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11865}
11866
11867impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
11868    type Protocol = SessionAudioConsumerFactoryMarker;
11869
11870    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11871        Self::new(inner)
11872    }
11873
11874    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11875        self.client.into_channel().map_err(|client| Self { client })
11876    }
11877
11878    fn as_channel(&self) -> &::fidl::AsyncChannel {
11879        self.client.as_channel()
11880    }
11881}
11882
11883impl SessionAudioConsumerFactoryProxy {
11884    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
11885    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11886        let protocol_name =
11887            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11888        Self { client: fidl::client::Client::new(channel, protocol_name) }
11889    }
11890
11891    /// Get a Stream of events from the remote end of the protocol.
11892    ///
11893    /// # Panics
11894    ///
11895    /// Panics if the event stream was already taken.
11896    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
11897        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
11898    }
11899
11900    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
11901    /// to a particular session. `session_id` is the identifier of the media session
11902    /// for which audio is to be rendered.
11903    pub fn r#create_audio_consumer(
11904        &self,
11905        mut session_id: u64,
11906        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11907    ) -> Result<(), fidl::Error> {
11908        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
11909            self,
11910            session_id,
11911            audio_consumer_request,
11912        )
11913    }
11914}
11915
11916impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
11917    fn r#create_audio_consumer(
11918        &self,
11919        mut session_id: u64,
11920        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
11921    ) -> Result<(), fidl::Error> {
11922        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
11923            (session_id, audio_consumer_request),
11924            0x6fab96f988e7d7fb,
11925            fidl::encoding::DynamicFlags::empty(),
11926        )
11927    }
11928}
11929
11930pub struct SessionAudioConsumerFactoryEventStream {
11931    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11932}
11933
11934impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
11935
11936impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
11937    fn is_terminated(&self) -> bool {
11938        self.event_receiver.is_terminated()
11939    }
11940}
11941
11942impl futures::Stream for SessionAudioConsumerFactoryEventStream {
11943    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
11944
11945    fn poll_next(
11946        mut self: std::pin::Pin<&mut Self>,
11947        cx: &mut std::task::Context<'_>,
11948    ) -> std::task::Poll<Option<Self::Item>> {
11949        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11950            &mut self.event_receiver,
11951            cx
11952        )?) {
11953            Some(buf) => {
11954                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
11955            }
11956            None => std::task::Poll::Ready(None),
11957        }
11958    }
11959}
11960
11961#[derive(Debug)]
11962pub enum SessionAudioConsumerFactoryEvent {}
11963
11964impl SessionAudioConsumerFactoryEvent {
11965    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
11966    fn decode(
11967        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11968    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
11969        let (bytes, _handles) = buf.split_mut();
11970        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11971        debug_assert_eq!(tx_header.tx_id, 0);
11972        match tx_header.ordinal {
11973            _ => Err(fidl::Error::UnknownOrdinal {
11974                ordinal: tx_header.ordinal,
11975                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11976            })
11977        }
11978    }
11979}
11980
11981/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
11982pub struct SessionAudioConsumerFactoryRequestStream {
11983    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11984    is_terminated: bool,
11985}
11986
11987impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
11988
11989impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
11990    fn is_terminated(&self) -> bool {
11991        self.is_terminated
11992    }
11993}
11994
11995impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
11996    type Protocol = SessionAudioConsumerFactoryMarker;
11997    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
11998
11999    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12000        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12001    }
12002
12003    fn control_handle(&self) -> Self::ControlHandle {
12004        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
12005    }
12006
12007    fn into_inner(
12008        self,
12009    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12010    {
12011        (self.inner, self.is_terminated)
12012    }
12013
12014    fn from_inner(
12015        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12016        is_terminated: bool,
12017    ) -> Self {
12018        Self { inner, is_terminated }
12019    }
12020}
12021
12022impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12023    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12024
12025    fn poll_next(
12026        mut self: std::pin::Pin<&mut Self>,
12027        cx: &mut std::task::Context<'_>,
12028    ) -> std::task::Poll<Option<Self::Item>> {
12029        let this = &mut *self;
12030        if this.inner.check_shutdown(cx) {
12031            this.is_terminated = true;
12032            return std::task::Poll::Ready(None);
12033        }
12034        if this.is_terminated {
12035            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12036        }
12037        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12038            |bytes, handles| {
12039                match this.inner.channel().read_etc(cx, bytes, handles) {
12040                    std::task::Poll::Ready(Ok(())) => {}
12041                    std::task::Poll::Pending => return std::task::Poll::Pending,
12042                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12043                        this.is_terminated = true;
12044                        return std::task::Poll::Ready(None);
12045                    }
12046                    std::task::Poll::Ready(Err(e)) => {
12047                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12048                            e.into(),
12049                        ))));
12050                    }
12051                }
12052
12053                // A message has been received from the channel
12054                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12055
12056                std::task::Poll::Ready(Some(match header.ordinal {
12057                0x6fab96f988e7d7fb => {
12058                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12059                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12060                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12061                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12062                        inner: this.inner.clone(),
12063                    };
12064                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12065audio_consumer_request: req.audio_consumer_request,
12066
12067                        control_handle,
12068                    })
12069                }
12070                _ => Err(fidl::Error::UnknownOrdinal {
12071                    ordinal: header.ordinal,
12072                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12073                }),
12074            }))
12075            },
12076        )
12077    }
12078}
12079
12080/// Interface for creating audio consumers bound to a session.
12081#[derive(Debug)]
12082pub enum SessionAudioConsumerFactoryRequest {
12083    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12084    /// to a particular session. `session_id` is the identifier of the media session
12085    /// for which audio is to be rendered.
12086    CreateAudioConsumer {
12087        session_id: u64,
12088        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12089        control_handle: SessionAudioConsumerFactoryControlHandle,
12090    },
12091}
12092
12093impl SessionAudioConsumerFactoryRequest {
12094    #[allow(irrefutable_let_patterns)]
12095    pub fn into_create_audio_consumer(
12096        self,
12097    ) -> Option<(
12098        u64,
12099        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12100        SessionAudioConsumerFactoryControlHandle,
12101    )> {
12102        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12103            session_id,
12104            audio_consumer_request,
12105            control_handle,
12106        } = self
12107        {
12108            Some((session_id, audio_consumer_request, control_handle))
12109        } else {
12110            None
12111        }
12112    }
12113
12114    /// Name of the method defined in FIDL
12115    pub fn method_name(&self) -> &'static str {
12116        match *self {
12117            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12118                "create_audio_consumer"
12119            }
12120        }
12121    }
12122}
12123
12124#[derive(Debug, Clone)]
12125pub struct SessionAudioConsumerFactoryControlHandle {
12126    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12127}
12128
12129impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12130    fn shutdown(&self) {
12131        self.inner.shutdown()
12132    }
12133
12134    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12135        self.inner.shutdown_with_epitaph(status)
12136    }
12137
12138    fn is_closed(&self) -> bool {
12139        self.inner.channel().is_closed()
12140    }
12141    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12142        self.inner.channel().on_closed()
12143    }
12144
12145    #[cfg(target_os = "fuchsia")]
12146    fn signal_peer(
12147        &self,
12148        clear_mask: zx::Signals,
12149        set_mask: zx::Signals,
12150    ) -> Result<(), zx_status::Status> {
12151        use fidl::Peered;
12152        self.inner.channel().signal_peer(clear_mask, set_mask)
12153    }
12154}
12155
12156impl SessionAudioConsumerFactoryControlHandle {}
12157
12158#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12159pub struct SimpleStreamSinkMarker;
12160
12161impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12162    type Proxy = SimpleStreamSinkProxy;
12163    type RequestStream = SimpleStreamSinkRequestStream;
12164    #[cfg(target_os = "fuchsia")]
12165    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12166
12167    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12168}
12169
12170pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12171    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12172    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12173    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12174    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12175    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12176    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12177    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12178    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12179    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12180}
12181#[derive(Debug)]
12182#[cfg(target_os = "fuchsia")]
12183pub struct SimpleStreamSinkSynchronousProxy {
12184    client: fidl::client::sync::Client,
12185}
12186
12187#[cfg(target_os = "fuchsia")]
12188impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12189    type Proxy = SimpleStreamSinkProxy;
12190    type Protocol = SimpleStreamSinkMarker;
12191
12192    fn from_channel(inner: fidl::Channel) -> Self {
12193        Self::new(inner)
12194    }
12195
12196    fn into_channel(self) -> fidl::Channel {
12197        self.client.into_channel()
12198    }
12199
12200    fn as_channel(&self) -> &fidl::Channel {
12201        self.client.as_channel()
12202    }
12203}
12204
12205#[cfg(target_os = "fuchsia")]
12206impl SimpleStreamSinkSynchronousProxy {
12207    pub fn new(channel: fidl::Channel) -> Self {
12208        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12209        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
12210    }
12211
12212    pub fn into_channel(self) -> fidl::Channel {
12213        self.client.into_channel()
12214    }
12215
12216    /// Waits until an event arrives and returns it. It is safe for other
12217    /// threads to make concurrent requests while waiting for an event.
12218    pub fn wait_for_event(
12219        &self,
12220        deadline: zx::MonotonicInstant,
12221    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12222        SimpleStreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
12223    }
12224
12225    /// Adds a payload buffer to the current buffer set associated with the
12226    /// connection. A `StreamPacket` struct reference a payload buffer in the
12227    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12228    ///
12229    /// A buffer with ID `id` must not be in the current set when this method is
12230    /// invoked, otherwise the service will close the connection.
12231    pub fn r#add_payload_buffer(
12232        &self,
12233        mut id: u32,
12234        mut payload_buffer: fidl::Vmo,
12235    ) -> Result<(), fidl::Error> {
12236        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12237            (id, payload_buffer),
12238            0x3b3a37fc34fe5b56,
12239            fidl::encoding::DynamicFlags::empty(),
12240        )
12241    }
12242
12243    /// Removes a payload buffer from the current buffer set associated with the
12244    /// connection.
12245    ///
12246    /// A buffer with ID `id` must exist in the current set when this method is
12247    /// invoked, otherwise the service will will close the connection.
12248    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12249        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12250            (id,),
12251            0x5d1e4f74c3658262,
12252            fidl::encoding::DynamicFlags::empty(),
12253        )
12254    }
12255
12256    /// Sends a packet to the service. The response is sent when the service is
12257    /// done with the associated payload memory.
12258    ///
12259    /// `packet` must be valid for the current buffer set, otherwise the service
12260    /// will close the connection.
12261    pub fn r#send_packet(
12262        &self,
12263        mut packet: &StreamPacket,
12264        ___deadline: zx::MonotonicInstant,
12265    ) -> Result<(), fidl::Error> {
12266        let _response =
12267            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
12268                (packet,),
12269                0x67cddd607442775f,
12270                fidl::encoding::DynamicFlags::empty(),
12271                ___deadline,
12272            )?;
12273        Ok(_response)
12274    }
12275
12276    /// Sends a packet to the service. This interface doesn't define how the
12277    /// client knows when the sink is done with the associated payload memory.
12278    /// The inheriting interface must define that.
12279    ///
12280    /// `packet` must be valid for the current buffer set, otherwise the service
12281    /// will close the connection.
12282    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12283        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12284            (packet,),
12285            0x8d9b8b413ceba9d,
12286            fidl::encoding::DynamicFlags::empty(),
12287        )
12288    }
12289
12290    /// Indicates the stream has ended. The precise semantics of this method are
12291    /// determined by the inheriting interface.
12292    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12293        self.client.send::<fidl::encoding::EmptyPayload>(
12294            (),
12295            0x6180fd6f7e793b71,
12296            fidl::encoding::DynamicFlags::empty(),
12297        )
12298    }
12299
12300    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12301    /// and not yet released. The response is sent after all packets have been
12302    /// released.
12303    pub fn r#discard_all_packets(
12304        &self,
12305        ___deadline: zx::MonotonicInstant,
12306    ) -> Result<(), fidl::Error> {
12307        let _response =
12308            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
12309                (),
12310                0x6f4dad7af2917665,
12311                fidl::encoding::DynamicFlags::empty(),
12312                ___deadline,
12313            )?;
12314        Ok(_response)
12315    }
12316
12317    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12318    /// and not yet released.
12319    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12320        self.client.send::<fidl::encoding::EmptyPayload>(
12321            (),
12322            0x50d36d0d23081bc4,
12323            fidl::encoding::DynamicFlags::empty(),
12324        )
12325    }
12326}
12327
12328#[cfg(target_os = "fuchsia")]
12329impl From<SimpleStreamSinkSynchronousProxy> for zx::NullableHandle {
12330    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12331        value.into_channel().into()
12332    }
12333}
12334
12335#[cfg(target_os = "fuchsia")]
12336impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12337    fn from(value: fidl::Channel) -> Self {
12338        Self::new(value)
12339    }
12340}
12341
12342#[cfg(target_os = "fuchsia")]
12343impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12344    type Protocol = SimpleStreamSinkMarker;
12345
12346    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12347        Self::new(value.into_channel())
12348    }
12349}
12350
12351#[derive(Debug, Clone)]
12352pub struct SimpleStreamSinkProxy {
12353    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12354}
12355
12356impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12357    type Protocol = SimpleStreamSinkMarker;
12358
12359    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12360        Self::new(inner)
12361    }
12362
12363    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12364        self.client.into_channel().map_err(|client| Self { client })
12365    }
12366
12367    fn as_channel(&self) -> &::fidl::AsyncChannel {
12368        self.client.as_channel()
12369    }
12370}
12371
12372impl SimpleStreamSinkProxy {
12373    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12374    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12375        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12376        Self { client: fidl::client::Client::new(channel, protocol_name) }
12377    }
12378
12379    /// Get a Stream of events from the remote end of the protocol.
12380    ///
12381    /// # Panics
12382    ///
12383    /// Panics if the event stream was already taken.
12384    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12385        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12386    }
12387
12388    /// Adds a payload buffer to the current buffer set associated with the
12389    /// connection. A `StreamPacket` struct reference a payload buffer in the
12390    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12391    ///
12392    /// A buffer with ID `id` must not be in the current set when this method is
12393    /// invoked, otherwise the service will close the connection.
12394    pub fn r#add_payload_buffer(
12395        &self,
12396        mut id: u32,
12397        mut payload_buffer: fidl::Vmo,
12398    ) -> Result<(), fidl::Error> {
12399        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12400    }
12401
12402    /// Removes a payload buffer from the current buffer set associated with the
12403    /// connection.
12404    ///
12405    /// A buffer with ID `id` must exist in the current set when this method is
12406    /// invoked, otherwise the service will will close the connection.
12407    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12408        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12409    }
12410
12411    /// Sends a packet to the service. The response is sent when the service is
12412    /// done with the associated payload memory.
12413    ///
12414    /// `packet` must be valid for the current buffer set, otherwise the service
12415    /// will close the connection.
12416    pub fn r#send_packet(
12417        &self,
12418        mut packet: &StreamPacket,
12419    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12420        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12421    }
12422
12423    /// Sends a packet to the service. This interface doesn't define how the
12424    /// client knows when the sink is done with the associated payload memory.
12425    /// The inheriting interface must define that.
12426    ///
12427    /// `packet` must be valid for the current buffer set, otherwise the service
12428    /// will close the connection.
12429    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12430        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12431    }
12432
12433    /// Indicates the stream has ended. The precise semantics of this method are
12434    /// determined by the inheriting interface.
12435    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12436        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12437    }
12438
12439    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12440    /// and not yet released. The response is sent after all packets have been
12441    /// released.
12442    pub fn r#discard_all_packets(
12443        &self,
12444    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12445        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12446    }
12447
12448    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12449    /// and not yet released.
12450    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12451        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12452    }
12453}
12454
12455impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12456    fn r#add_payload_buffer(
12457        &self,
12458        mut id: u32,
12459        mut payload_buffer: fidl::Vmo,
12460    ) -> Result<(), fidl::Error> {
12461        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12462            (id, payload_buffer),
12463            0x3b3a37fc34fe5b56,
12464            fidl::encoding::DynamicFlags::empty(),
12465        )
12466    }
12467
12468    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12469        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12470            (id,),
12471            0x5d1e4f74c3658262,
12472            fidl::encoding::DynamicFlags::empty(),
12473        )
12474    }
12475
12476    type SendPacketResponseFut =
12477        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12478    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12479        fn _decode(
12480            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12481        ) -> Result<(), fidl::Error> {
12482            let _response = fidl::client::decode_transaction_body::<
12483                fidl::encoding::EmptyPayload,
12484                fidl::encoding::DefaultFuchsiaResourceDialect,
12485                0x67cddd607442775f,
12486            >(_buf?)?;
12487            Ok(_response)
12488        }
12489        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12490            (packet,),
12491            0x67cddd607442775f,
12492            fidl::encoding::DynamicFlags::empty(),
12493            _decode,
12494        )
12495    }
12496
12497    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12498        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12499            (packet,),
12500            0x8d9b8b413ceba9d,
12501            fidl::encoding::DynamicFlags::empty(),
12502        )
12503    }
12504
12505    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12506        self.client.send::<fidl::encoding::EmptyPayload>(
12507            (),
12508            0x6180fd6f7e793b71,
12509            fidl::encoding::DynamicFlags::empty(),
12510        )
12511    }
12512
12513    type DiscardAllPacketsResponseFut =
12514        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12515    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12516        fn _decode(
12517            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12518        ) -> Result<(), fidl::Error> {
12519            let _response = fidl::client::decode_transaction_body::<
12520                fidl::encoding::EmptyPayload,
12521                fidl::encoding::DefaultFuchsiaResourceDialect,
12522                0x6f4dad7af2917665,
12523            >(_buf?)?;
12524            Ok(_response)
12525        }
12526        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12527            (),
12528            0x6f4dad7af2917665,
12529            fidl::encoding::DynamicFlags::empty(),
12530            _decode,
12531        )
12532    }
12533
12534    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12535        self.client.send::<fidl::encoding::EmptyPayload>(
12536            (),
12537            0x50d36d0d23081bc4,
12538            fidl::encoding::DynamicFlags::empty(),
12539        )
12540    }
12541}
12542
12543pub struct SimpleStreamSinkEventStream {
12544    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12545}
12546
12547impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12548
12549impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12550    fn is_terminated(&self) -> bool {
12551        self.event_receiver.is_terminated()
12552    }
12553}
12554
12555impl futures::Stream for SimpleStreamSinkEventStream {
12556    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12557
12558    fn poll_next(
12559        mut self: std::pin::Pin<&mut Self>,
12560        cx: &mut std::task::Context<'_>,
12561    ) -> std::task::Poll<Option<Self::Item>> {
12562        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12563            &mut self.event_receiver,
12564            cx
12565        )?) {
12566            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12567            None => std::task::Poll::Ready(None),
12568        }
12569    }
12570}
12571
12572#[derive(Debug)]
12573pub enum SimpleStreamSinkEvent {}
12574
12575impl SimpleStreamSinkEvent {
12576    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12577    fn decode(
12578        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12579    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12580        let (bytes, _handles) = buf.split_mut();
12581        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12582        debug_assert_eq!(tx_header.tx_id, 0);
12583        match tx_header.ordinal {
12584            _ => Err(fidl::Error::UnknownOrdinal {
12585                ordinal: tx_header.ordinal,
12586                protocol_name:
12587                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12588            }),
12589        }
12590    }
12591}
12592
12593/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12594pub struct SimpleStreamSinkRequestStream {
12595    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12596    is_terminated: bool,
12597}
12598
12599impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12600
12601impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12602    fn is_terminated(&self) -> bool {
12603        self.is_terminated
12604    }
12605}
12606
12607impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12608    type Protocol = SimpleStreamSinkMarker;
12609    type ControlHandle = SimpleStreamSinkControlHandle;
12610
12611    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12612        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12613    }
12614
12615    fn control_handle(&self) -> Self::ControlHandle {
12616        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12617    }
12618
12619    fn into_inner(
12620        self,
12621    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12622    {
12623        (self.inner, self.is_terminated)
12624    }
12625
12626    fn from_inner(
12627        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12628        is_terminated: bool,
12629    ) -> Self {
12630        Self { inner, is_terminated }
12631    }
12632}
12633
12634impl futures::Stream for SimpleStreamSinkRequestStream {
12635    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
12636
12637    fn poll_next(
12638        mut self: std::pin::Pin<&mut Self>,
12639        cx: &mut std::task::Context<'_>,
12640    ) -> std::task::Poll<Option<Self::Item>> {
12641        let this = &mut *self;
12642        if this.inner.check_shutdown(cx) {
12643            this.is_terminated = true;
12644            return std::task::Poll::Ready(None);
12645        }
12646        if this.is_terminated {
12647            panic!("polled SimpleStreamSinkRequestStream after completion");
12648        }
12649        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12650            |bytes, handles| {
12651                match this.inner.channel().read_etc(cx, bytes, handles) {
12652                    std::task::Poll::Ready(Ok(())) => {}
12653                    std::task::Poll::Pending => return std::task::Poll::Pending,
12654                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12655                        this.is_terminated = true;
12656                        return std::task::Poll::Ready(None);
12657                    }
12658                    std::task::Poll::Ready(Err(e)) => {
12659                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12660                            e.into(),
12661                        ))));
12662                    }
12663                }
12664
12665                // A message has been received from the channel
12666                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12667
12668                std::task::Poll::Ready(Some(match header.ordinal {
12669                    0x3b3a37fc34fe5b56 => {
12670                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12671                        let mut req = fidl::new_empty!(
12672                            StreamBufferSetAddPayloadBufferRequest,
12673                            fidl::encoding::DefaultFuchsiaResourceDialect
12674                        );
12675                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12676                        let control_handle =
12677                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12678                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
12679                            id: req.id,
12680                            payload_buffer: req.payload_buffer,
12681
12682                            control_handle,
12683                        })
12684                    }
12685                    0x5d1e4f74c3658262 => {
12686                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12687                        let mut req = fidl::new_empty!(
12688                            StreamBufferSetRemovePayloadBufferRequest,
12689                            fidl::encoding::DefaultFuchsiaResourceDialect
12690                        );
12691                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12692                        let control_handle =
12693                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12694                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
12695                            id: req.id,
12696
12697                            control_handle,
12698                        })
12699                    }
12700                    0x67cddd607442775f => {
12701                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12702                        let mut req = fidl::new_empty!(
12703                            StreamSinkSendPacketRequest,
12704                            fidl::encoding::DefaultFuchsiaResourceDialect
12705                        );
12706                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12707                        let control_handle =
12708                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12709                        Ok(SimpleStreamSinkRequest::SendPacket {
12710                            packet: req.packet,
12711
12712                            responder: SimpleStreamSinkSendPacketResponder {
12713                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12714                                tx_id: header.tx_id,
12715                            },
12716                        })
12717                    }
12718                    0x8d9b8b413ceba9d => {
12719                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12720                        let mut req = fidl::new_empty!(
12721                            StreamSinkSendPacketNoReplyRequest,
12722                            fidl::encoding::DefaultFuchsiaResourceDialect
12723                        );
12724                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
12725                        let control_handle =
12726                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12727                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
12728                            packet: req.packet,
12729
12730                            control_handle,
12731                        })
12732                    }
12733                    0x6180fd6f7e793b71 => {
12734                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12735                        let mut req = fidl::new_empty!(
12736                            fidl::encoding::EmptyPayload,
12737                            fidl::encoding::DefaultFuchsiaResourceDialect
12738                        );
12739                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12740                        let control_handle =
12741                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12742                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
12743                    }
12744                    0x6f4dad7af2917665 => {
12745                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12746                        let mut req = fidl::new_empty!(
12747                            fidl::encoding::EmptyPayload,
12748                            fidl::encoding::DefaultFuchsiaResourceDialect
12749                        );
12750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12751                        let control_handle =
12752                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12753                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
12754                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
12755                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12756                                tx_id: header.tx_id,
12757                            },
12758                        })
12759                    }
12760                    0x50d36d0d23081bc4 => {
12761                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12762                        let mut req = fidl::new_empty!(
12763                            fidl::encoding::EmptyPayload,
12764                            fidl::encoding::DefaultFuchsiaResourceDialect
12765                        );
12766                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12767                        let control_handle =
12768                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
12769                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
12770                    }
12771                    _ => Err(fidl::Error::UnknownOrdinal {
12772                        ordinal: header.ordinal,
12773                        protocol_name:
12774                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12775                    }),
12776                }))
12777            },
12778        )
12779    }
12780}
12781
12782/// A StreamSink that uses StreamBufferSet for buffer management.
12783#[derive(Debug)]
12784pub enum SimpleStreamSinkRequest {
12785    /// Adds a payload buffer to the current buffer set associated with the
12786    /// connection. A `StreamPacket` struct reference a payload buffer in the
12787    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12788    ///
12789    /// A buffer with ID `id` must not be in the current set when this method is
12790    /// invoked, otherwise the service will close the connection.
12791    AddPayloadBuffer {
12792        id: u32,
12793        payload_buffer: fidl::Vmo,
12794        control_handle: SimpleStreamSinkControlHandle,
12795    },
12796    /// Removes a payload buffer from the current buffer set associated with the
12797    /// connection.
12798    ///
12799    /// A buffer with ID `id` must exist in the current set when this method is
12800    /// invoked, otherwise the service will will close the connection.
12801    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
12802    /// Sends a packet to the service. The response is sent when the service is
12803    /// done with the associated payload memory.
12804    ///
12805    /// `packet` must be valid for the current buffer set, otherwise the service
12806    /// will close the connection.
12807    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
12808    /// Sends a packet to the service. This interface doesn't define how the
12809    /// client knows when the sink is done with the associated payload memory.
12810    /// The inheriting interface must define that.
12811    ///
12812    /// `packet` must be valid for the current buffer set, otherwise the service
12813    /// will close the connection.
12814    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
12815    /// Indicates the stream has ended. The precise semantics of this method are
12816    /// determined by the inheriting interface.
12817    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
12818    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12819    /// and not yet released. The response is sent after all packets have been
12820    /// released.
12821    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
12822    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12823    /// and not yet released.
12824    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
12825}
12826
12827impl SimpleStreamSinkRequest {
12828    #[allow(irrefutable_let_patterns)]
12829    pub fn into_add_payload_buffer(
12830        self,
12831    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
12832        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
12833            self
12834        {
12835            Some((id, payload_buffer, control_handle))
12836        } else {
12837            None
12838        }
12839    }
12840
12841    #[allow(irrefutable_let_patterns)]
12842    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
12843        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
12844            Some((id, control_handle))
12845        } else {
12846            None
12847        }
12848    }
12849
12850    #[allow(irrefutable_let_patterns)]
12851    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
12852        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
12853            Some((packet, responder))
12854        } else {
12855            None
12856        }
12857    }
12858
12859    #[allow(irrefutable_let_patterns)]
12860    pub fn into_send_packet_no_reply(
12861        self,
12862    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
12863        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
12864            Some((packet, control_handle))
12865        } else {
12866            None
12867        }
12868    }
12869
12870    #[allow(irrefutable_let_patterns)]
12871    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
12872        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
12873            Some((control_handle))
12874        } else {
12875            None
12876        }
12877    }
12878
12879    #[allow(irrefutable_let_patterns)]
12880    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
12881        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
12882            Some((responder))
12883        } else {
12884            None
12885        }
12886    }
12887
12888    #[allow(irrefutable_let_patterns)]
12889    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
12890        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
12891            Some((control_handle))
12892        } else {
12893            None
12894        }
12895    }
12896
12897    /// Name of the method defined in FIDL
12898    pub fn method_name(&self) -> &'static str {
12899        match *self {
12900            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
12901            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
12902            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
12903            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
12904            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
12905            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
12906            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
12907                "discard_all_packets_no_reply"
12908            }
12909        }
12910    }
12911}
12912
12913#[derive(Debug, Clone)]
12914pub struct SimpleStreamSinkControlHandle {
12915    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12916}
12917
12918impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
12919    fn shutdown(&self) {
12920        self.inner.shutdown()
12921    }
12922
12923    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12924        self.inner.shutdown_with_epitaph(status)
12925    }
12926
12927    fn is_closed(&self) -> bool {
12928        self.inner.channel().is_closed()
12929    }
12930    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12931        self.inner.channel().on_closed()
12932    }
12933
12934    #[cfg(target_os = "fuchsia")]
12935    fn signal_peer(
12936        &self,
12937        clear_mask: zx::Signals,
12938        set_mask: zx::Signals,
12939    ) -> Result<(), zx_status::Status> {
12940        use fidl::Peered;
12941        self.inner.channel().signal_peer(clear_mask, set_mask)
12942    }
12943}
12944
12945impl SimpleStreamSinkControlHandle {}
12946
12947#[must_use = "FIDL methods require a response to be sent"]
12948#[derive(Debug)]
12949pub struct SimpleStreamSinkSendPacketResponder {
12950    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
12951    tx_id: u32,
12952}
12953
12954/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
12955/// if the responder is dropped without sending a response, so that the client
12956/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12957impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
12958    fn drop(&mut self) {
12959        self.control_handle.shutdown();
12960        // Safety: drops once, never accessed again
12961        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12962    }
12963}
12964
12965impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
12966    type ControlHandle = SimpleStreamSinkControlHandle;
12967
12968    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
12969        &self.control_handle
12970    }
12971
12972    fn drop_without_shutdown(mut self) {
12973        // Safety: drops once, never accessed again due to mem::forget
12974        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12975        // Prevent Drop from running (which would shut down the channel)
12976        std::mem::forget(self);
12977    }
12978}
12979
12980impl SimpleStreamSinkSendPacketResponder {
12981    /// Sends a response to the FIDL transaction.
12982    ///
12983    /// Sets the channel to shutdown if an error occurs.
12984    pub fn send(self) -> Result<(), fidl::Error> {
12985        let _result = self.send_raw();
12986        if _result.is_err() {
12987            self.control_handle.shutdown();
12988        }
12989        self.drop_without_shutdown();
12990        _result
12991    }
12992
12993    /// Similar to "send" but does not shutdown the channel if an error occurs.
12994    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12995        let _result = self.send_raw();
12996        self.drop_without_shutdown();
12997        _result
12998    }
12999
13000    fn send_raw(&self) -> Result<(), fidl::Error> {
13001        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13002            (),
13003            self.tx_id,
13004            0x67cddd607442775f,
13005            fidl::encoding::DynamicFlags::empty(),
13006        )
13007    }
13008}
13009
13010#[must_use = "FIDL methods require a response to be sent"]
13011#[derive(Debug)]
13012pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13013    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13014    tx_id: u32,
13015}
13016
13017/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13018/// if the responder is dropped without sending a response, so that the client
13019/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13020impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13021    fn drop(&mut self) {
13022        self.control_handle.shutdown();
13023        // Safety: drops once, never accessed again
13024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13025    }
13026}
13027
13028impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13029    type ControlHandle = SimpleStreamSinkControlHandle;
13030
13031    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13032        &self.control_handle
13033    }
13034
13035    fn drop_without_shutdown(mut self) {
13036        // Safety: drops once, never accessed again due to mem::forget
13037        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13038        // Prevent Drop from running (which would shut down the channel)
13039        std::mem::forget(self);
13040    }
13041}
13042
13043impl SimpleStreamSinkDiscardAllPacketsResponder {
13044    /// Sends a response to the FIDL transaction.
13045    ///
13046    /// Sets the channel to shutdown if an error occurs.
13047    pub fn send(self) -> Result<(), fidl::Error> {
13048        let _result = self.send_raw();
13049        if _result.is_err() {
13050            self.control_handle.shutdown();
13051        }
13052        self.drop_without_shutdown();
13053        _result
13054    }
13055
13056    /// Similar to "send" but does not shutdown the channel if an error occurs.
13057    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13058        let _result = self.send_raw();
13059        self.drop_without_shutdown();
13060        _result
13061    }
13062
13063    fn send_raw(&self) -> Result<(), fidl::Error> {
13064        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13065            (),
13066            self.tx_id,
13067            0x6f4dad7af2917665,
13068            fidl::encoding::DynamicFlags::empty(),
13069        )
13070    }
13071}
13072
13073#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13074pub struct StreamBufferSetMarker;
13075
13076impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13077    type Proxy = StreamBufferSetProxy;
13078    type RequestStream = StreamBufferSetRequestStream;
13079    #[cfg(target_os = "fuchsia")]
13080    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13081
13082    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13083}
13084
13085pub trait StreamBufferSetProxyInterface: Send + Sync {
13086    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13087    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13088}
13089#[derive(Debug)]
13090#[cfg(target_os = "fuchsia")]
13091pub struct StreamBufferSetSynchronousProxy {
13092    client: fidl::client::sync::Client,
13093}
13094
13095#[cfg(target_os = "fuchsia")]
13096impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13097    type Proxy = StreamBufferSetProxy;
13098    type Protocol = StreamBufferSetMarker;
13099
13100    fn from_channel(inner: fidl::Channel) -> Self {
13101        Self::new(inner)
13102    }
13103
13104    fn into_channel(self) -> fidl::Channel {
13105        self.client.into_channel()
13106    }
13107
13108    fn as_channel(&self) -> &fidl::Channel {
13109        self.client.as_channel()
13110    }
13111}
13112
13113#[cfg(target_os = "fuchsia")]
13114impl StreamBufferSetSynchronousProxy {
13115    pub fn new(channel: fidl::Channel) -> Self {
13116        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13117        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13118    }
13119
13120    pub fn into_channel(self) -> fidl::Channel {
13121        self.client.into_channel()
13122    }
13123
13124    /// Waits until an event arrives and returns it. It is safe for other
13125    /// threads to make concurrent requests while waiting for an event.
13126    pub fn wait_for_event(
13127        &self,
13128        deadline: zx::MonotonicInstant,
13129    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13130        StreamBufferSetEvent::decode(self.client.wait_for_event(deadline)?)
13131    }
13132
13133    /// Adds a payload buffer to the current buffer set associated with the
13134    /// connection. A `StreamPacket` struct reference a payload buffer in the
13135    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13136    ///
13137    /// A buffer with ID `id` must not be in the current set when this method is
13138    /// invoked, otherwise the service will close the connection.
13139    pub fn r#add_payload_buffer(
13140        &self,
13141        mut id: u32,
13142        mut payload_buffer: fidl::Vmo,
13143    ) -> Result<(), fidl::Error> {
13144        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13145            (id, payload_buffer),
13146            0x3b3a37fc34fe5b56,
13147            fidl::encoding::DynamicFlags::empty(),
13148        )
13149    }
13150
13151    /// Removes a payload buffer from the current buffer set associated with the
13152    /// connection.
13153    ///
13154    /// A buffer with ID `id` must exist in the current set when this method is
13155    /// invoked, otherwise the service will will close the connection.
13156    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13157        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13158            (id,),
13159            0x5d1e4f74c3658262,
13160            fidl::encoding::DynamicFlags::empty(),
13161        )
13162    }
13163}
13164
13165#[cfg(target_os = "fuchsia")]
13166impl From<StreamBufferSetSynchronousProxy> for zx::NullableHandle {
13167    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13168        value.into_channel().into()
13169    }
13170}
13171
13172#[cfg(target_os = "fuchsia")]
13173impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13174    fn from(value: fidl::Channel) -> Self {
13175        Self::new(value)
13176    }
13177}
13178
13179#[cfg(target_os = "fuchsia")]
13180impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13181    type Protocol = StreamBufferSetMarker;
13182
13183    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13184        Self::new(value.into_channel())
13185    }
13186}
13187
13188#[derive(Debug, Clone)]
13189pub struct StreamBufferSetProxy {
13190    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13191}
13192
13193impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13194    type Protocol = StreamBufferSetMarker;
13195
13196    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13197        Self::new(inner)
13198    }
13199
13200    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13201        self.client.into_channel().map_err(|client| Self { client })
13202    }
13203
13204    fn as_channel(&self) -> &::fidl::AsyncChannel {
13205        self.client.as_channel()
13206    }
13207}
13208
13209impl StreamBufferSetProxy {
13210    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13211    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13212        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13213        Self { client: fidl::client::Client::new(channel, protocol_name) }
13214    }
13215
13216    /// Get a Stream of events from the remote end of the protocol.
13217    ///
13218    /// # Panics
13219    ///
13220    /// Panics if the event stream was already taken.
13221    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13222        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13223    }
13224
13225    /// Adds a payload buffer to the current buffer set associated with the
13226    /// connection. A `StreamPacket` struct reference a payload buffer in the
13227    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13228    ///
13229    /// A buffer with ID `id` must not be in the current set when this method is
13230    /// invoked, otherwise the service will close the connection.
13231    pub fn r#add_payload_buffer(
13232        &self,
13233        mut id: u32,
13234        mut payload_buffer: fidl::Vmo,
13235    ) -> Result<(), fidl::Error> {
13236        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13237    }
13238
13239    /// Removes a payload buffer from the current buffer set associated with the
13240    /// connection.
13241    ///
13242    /// A buffer with ID `id` must exist in the current set when this method is
13243    /// invoked, otherwise the service will will close the connection.
13244    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13245        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13246    }
13247}
13248
13249impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13250    fn r#add_payload_buffer(
13251        &self,
13252        mut id: u32,
13253        mut payload_buffer: fidl::Vmo,
13254    ) -> Result<(), fidl::Error> {
13255        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13256            (id, payload_buffer),
13257            0x3b3a37fc34fe5b56,
13258            fidl::encoding::DynamicFlags::empty(),
13259        )
13260    }
13261
13262    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13263        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13264            (id,),
13265            0x5d1e4f74c3658262,
13266            fidl::encoding::DynamicFlags::empty(),
13267        )
13268    }
13269}
13270
13271pub struct StreamBufferSetEventStream {
13272    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13273}
13274
13275impl std::marker::Unpin for StreamBufferSetEventStream {}
13276
13277impl futures::stream::FusedStream for StreamBufferSetEventStream {
13278    fn is_terminated(&self) -> bool {
13279        self.event_receiver.is_terminated()
13280    }
13281}
13282
13283impl futures::Stream for StreamBufferSetEventStream {
13284    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13285
13286    fn poll_next(
13287        mut self: std::pin::Pin<&mut Self>,
13288        cx: &mut std::task::Context<'_>,
13289    ) -> std::task::Poll<Option<Self::Item>> {
13290        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13291            &mut self.event_receiver,
13292            cx
13293        )?) {
13294            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13295            None => std::task::Poll::Ready(None),
13296        }
13297    }
13298}
13299
13300#[derive(Debug)]
13301pub enum StreamBufferSetEvent {}
13302
13303impl StreamBufferSetEvent {
13304    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13305    fn decode(
13306        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13307    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13308        let (bytes, _handles) = buf.split_mut();
13309        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13310        debug_assert_eq!(tx_header.tx_id, 0);
13311        match tx_header.ordinal {
13312            _ => Err(fidl::Error::UnknownOrdinal {
13313                ordinal: tx_header.ordinal,
13314                protocol_name:
13315                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13316            }),
13317        }
13318    }
13319}
13320
13321/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13322pub struct StreamBufferSetRequestStream {
13323    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13324    is_terminated: bool,
13325}
13326
13327impl std::marker::Unpin for StreamBufferSetRequestStream {}
13328
13329impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13330    fn is_terminated(&self) -> bool {
13331        self.is_terminated
13332    }
13333}
13334
13335impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13336    type Protocol = StreamBufferSetMarker;
13337    type ControlHandle = StreamBufferSetControlHandle;
13338
13339    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13340        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13341    }
13342
13343    fn control_handle(&self) -> Self::ControlHandle {
13344        StreamBufferSetControlHandle { inner: self.inner.clone() }
13345    }
13346
13347    fn into_inner(
13348        self,
13349    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13350    {
13351        (self.inner, self.is_terminated)
13352    }
13353
13354    fn from_inner(
13355        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13356        is_terminated: bool,
13357    ) -> Self {
13358        Self { inner, is_terminated }
13359    }
13360}
13361
13362impl futures::Stream for StreamBufferSetRequestStream {
13363    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13364
13365    fn poll_next(
13366        mut self: std::pin::Pin<&mut Self>,
13367        cx: &mut std::task::Context<'_>,
13368    ) -> std::task::Poll<Option<Self::Item>> {
13369        let this = &mut *self;
13370        if this.inner.check_shutdown(cx) {
13371            this.is_terminated = true;
13372            return std::task::Poll::Ready(None);
13373        }
13374        if this.is_terminated {
13375            panic!("polled StreamBufferSetRequestStream after completion");
13376        }
13377        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13378            |bytes, handles| {
13379                match this.inner.channel().read_etc(cx, bytes, handles) {
13380                    std::task::Poll::Ready(Ok(())) => {}
13381                    std::task::Poll::Pending => return std::task::Poll::Pending,
13382                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13383                        this.is_terminated = true;
13384                        return std::task::Poll::Ready(None);
13385                    }
13386                    std::task::Poll::Ready(Err(e)) => {
13387                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13388                            e.into(),
13389                        ))));
13390                    }
13391                }
13392
13393                // A message has been received from the channel
13394                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13395
13396                std::task::Poll::Ready(Some(match header.ordinal {
13397                    0x3b3a37fc34fe5b56 => {
13398                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13399                        let mut req = fidl::new_empty!(
13400                            StreamBufferSetAddPayloadBufferRequest,
13401                            fidl::encoding::DefaultFuchsiaResourceDialect
13402                        );
13403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13404                        let control_handle =
13405                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13406                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13407                            id: req.id,
13408                            payload_buffer: req.payload_buffer,
13409
13410                            control_handle,
13411                        })
13412                    }
13413                    0x5d1e4f74c3658262 => {
13414                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13415                        let mut req = fidl::new_empty!(
13416                            StreamBufferSetRemovePayloadBufferRequest,
13417                            fidl::encoding::DefaultFuchsiaResourceDialect
13418                        );
13419                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13420                        let control_handle =
13421                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13422                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13423                            id: req.id,
13424
13425                            control_handle,
13426                        })
13427                    }
13428                    _ => Err(fidl::Error::UnknownOrdinal {
13429                        ordinal: header.ordinal,
13430                        protocol_name:
13431                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13432                    }),
13433                }))
13434            },
13435        )
13436    }
13437}
13438
13439/// Manages a set of payload buffers for a stream. This interface is typically
13440/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13441/// of elementary streams between clients and services.
13442#[derive(Debug)]
13443pub enum StreamBufferSetRequest {
13444    /// Adds a payload buffer to the current buffer set associated with the
13445    /// connection. A `StreamPacket` struct reference a payload buffer in the
13446    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13447    ///
13448    /// A buffer with ID `id` must not be in the current set when this method is
13449    /// invoked, otherwise the service will close the connection.
13450    AddPayloadBuffer {
13451        id: u32,
13452        payload_buffer: fidl::Vmo,
13453        control_handle: StreamBufferSetControlHandle,
13454    },
13455    /// Removes a payload buffer from the current buffer set associated with the
13456    /// connection.
13457    ///
13458    /// A buffer with ID `id` must exist in the current set when this method is
13459    /// invoked, otherwise the service will will close the connection.
13460    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13461}
13462
13463impl StreamBufferSetRequest {
13464    #[allow(irrefutable_let_patterns)]
13465    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13466        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13467            self
13468        {
13469            Some((id, payload_buffer, control_handle))
13470        } else {
13471            None
13472        }
13473    }
13474
13475    #[allow(irrefutable_let_patterns)]
13476    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13477        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13478            Some((id, control_handle))
13479        } else {
13480            None
13481        }
13482    }
13483
13484    /// Name of the method defined in FIDL
13485    pub fn method_name(&self) -> &'static str {
13486        match *self {
13487            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13488            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13489        }
13490    }
13491}
13492
13493#[derive(Debug, Clone)]
13494pub struct StreamBufferSetControlHandle {
13495    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13496}
13497
13498impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13499    fn shutdown(&self) {
13500        self.inner.shutdown()
13501    }
13502
13503    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
13504        self.inner.shutdown_with_epitaph(status)
13505    }
13506
13507    fn is_closed(&self) -> bool {
13508        self.inner.channel().is_closed()
13509    }
13510    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13511        self.inner.channel().on_closed()
13512    }
13513
13514    #[cfg(target_os = "fuchsia")]
13515    fn signal_peer(
13516        &self,
13517        clear_mask: zx::Signals,
13518        set_mask: zx::Signals,
13519    ) -> Result<(), zx_status::Status> {
13520        use fidl::Peered;
13521        self.inner.channel().signal_peer(clear_mask, set_mask)
13522    }
13523}
13524
13525impl StreamBufferSetControlHandle {}
13526
13527#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13528pub struct StreamProcessorMarker;
13529
13530impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13531    type Proxy = StreamProcessorProxy;
13532    type RequestStream = StreamProcessorRequestStream;
13533    #[cfg(target_os = "fuchsia")]
13534    type SynchronousProxy = StreamProcessorSynchronousProxy;
13535
13536    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13537}
13538
13539pub trait StreamProcessorProxyInterface: Send + Sync {
13540    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13541    fn r#set_input_buffer_partial_settings(
13542        &self,
13543        input_settings: StreamBufferPartialSettings,
13544    ) -> Result<(), fidl::Error>;
13545    fn r#set_output_buffer_partial_settings(
13546        &self,
13547        output_settings: StreamBufferPartialSettings,
13548    ) -> Result<(), fidl::Error>;
13549    fn r#complete_output_buffer_partial_settings(
13550        &self,
13551        buffer_lifetime_ordinal: u64,
13552    ) -> Result<(), fidl::Error>;
13553    fn r#flush_end_of_stream_and_close_stream(
13554        &self,
13555        stream_lifetime_ordinal: u64,
13556    ) -> Result<(), fidl::Error>;
13557    fn r#close_current_stream(
13558        &self,
13559        stream_lifetime_ordinal: u64,
13560        release_input_buffers: bool,
13561        release_output_buffers: bool,
13562    ) -> Result<(), fidl::Error>;
13563    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13564    fn r#sync(&self) -> Self::SyncResponseFut;
13565    fn r#recycle_output_packet(
13566        &self,
13567        available_output_packet: &PacketHeader,
13568    ) -> Result<(), fidl::Error>;
13569    fn r#queue_input_format_details(
13570        &self,
13571        stream_lifetime_ordinal: u64,
13572        format_details: &FormatDetails,
13573    ) -> Result<(), fidl::Error>;
13574    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13575    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13576}
13577#[derive(Debug)]
13578#[cfg(target_os = "fuchsia")]
13579pub struct StreamProcessorSynchronousProxy {
13580    client: fidl::client::sync::Client,
13581}
13582
13583#[cfg(target_os = "fuchsia")]
13584impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13585    type Proxy = StreamProcessorProxy;
13586    type Protocol = StreamProcessorMarker;
13587
13588    fn from_channel(inner: fidl::Channel) -> Self {
13589        Self::new(inner)
13590    }
13591
13592    fn into_channel(self) -> fidl::Channel {
13593        self.client.into_channel()
13594    }
13595
13596    fn as_channel(&self) -> &fidl::Channel {
13597        self.client.as_channel()
13598    }
13599}
13600
13601#[cfg(target_os = "fuchsia")]
13602impl StreamProcessorSynchronousProxy {
13603    pub fn new(channel: fidl::Channel) -> Self {
13604        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13605        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
13606    }
13607
13608    pub fn into_channel(self) -> fidl::Channel {
13609        self.client.into_channel()
13610    }
13611
13612    /// Waits until an event arrives and returns it. It is safe for other
13613    /// threads to make concurrent requests while waiting for an event.
13614    pub fn wait_for_event(
13615        &self,
13616        deadline: zx::MonotonicInstant,
13617    ) -> Result<StreamProcessorEvent, fidl::Error> {
13618        StreamProcessorEvent::decode(self.client.wait_for_event(deadline)?)
13619    }
13620
13621    /// Permit the server to use OnStreamFailed() instead of the server just
13622    /// closing the whole StreamProcessor channel on stream failure.
13623    ///
13624    /// If the server hasn't seen this message by the time a stream fails, the
13625    /// server will close the StreamProcessor channel instead of sending
13626    /// OnStreamFailed().
13627    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
13628        self.client.send::<fidl::encoding::EmptyPayload>(
13629            (),
13630            0x3940929617dbf02b,
13631            fidl::encoding::DynamicFlags::empty(),
13632        )
13633    }
13634
13635    /// This is the replacement for SetInputBufferSettings().
13636    ///
13637    /// When the client is using sysmem to allocate buffers, this message is
13638    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
13639    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
13640    /// the client-specified input settings and a BufferCollectionToken which
13641    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
13642    /// client and the StreamProcessor will be informed of the allocated buffers
13643    /// directly by sysmem via their BufferCollection channel (not via the
13644    /// StreamProcessor channel).
13645    ///
13646    /// The client must not QueueInput...() until after sysmem informs the client
13647    /// that buffer allocation has completed and was successful.
13648    ///
13649    /// The server should be prepared to see QueueInput...() before the server
13650    /// has necessarily heard from sysmem that the buffers are allocated - the
13651    /// server must tolerate either ordering, as the QueueInput...() and
13652    /// notification of sysmem allocation completion arrive on different
13653    /// channels, so the client having heard that allocation is complete doesn't
13654    /// mean the server knows that allocation is complete yet.  However, the
13655    /// server can expect that allocation is in fact complete and can expect to
13656    /// get the allocation information from sysmem immediately upon requesting
13657    /// the information from sysmem.
13658    pub fn r#set_input_buffer_partial_settings(
13659        &self,
13660        mut input_settings: StreamBufferPartialSettings,
13661    ) -> Result<(), fidl::Error> {
13662        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
13663            (&mut input_settings,),
13664            0xb02e0663a40e4c4,
13665            fidl::encoding::DynamicFlags::empty(),
13666        )
13667    }
13668
13669    /// This is the replacement for SetOutputBufferSettings().
13670    ///
13671    /// When the client is using sysmem to allocate buffers, this message is
13672    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13673    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13674    /// with the client-specified output settings and a BufferCollectionToken
13675    /// which the StreamProcessor will use to convey constraints to sysmem.
13676    /// Both the client and the StreamProcessor will be informed of the
13677    /// allocated buffers directly by sysmem via their BufferCollection channel
13678    /// (not via the StreamProcessor channel).
13679    ///
13680    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13681    /// received by the client with buffer_constraints_action_required true and
13682    /// stream_lifetime_ordinal equal to the client's current
13683    /// stream_lifetime_ordinal (even if there is an active stream), and is
13684    /// _permitted_ any time there is no current stream.
13685    ///
13686    /// Closing the current stream occurs on the StreamControl ordering domain,
13687    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13688    /// subsequent Sync() completion must be received by the client before the
13689    /// client knows that there's no longer a current stream.
13690    ///
13691    /// See also CompleteOutputBufferPartialSettings().
13692    pub fn r#set_output_buffer_partial_settings(
13693        &self,
13694        mut output_settings: StreamBufferPartialSettings,
13695    ) -> Result<(), fidl::Error> {
13696        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
13697            (&mut output_settings,),
13698            0x118bb8c819a7bbbb,
13699            fidl::encoding::DynamicFlags::empty(),
13700        )
13701    }
13702
13703    /// After SetOutputBufferPartialSettings(), the server won't send
13704    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13705    /// OnOutputEndOfStream() until after the client sends
13706    /// CompleteOutputBufferPartialSettings().
13707    ///
13708    /// Some clients may be able to send
13709    /// CompleteOutputBufferPartialSettings() immediately after
13710    /// SetOutputBufferPartialSettings() - in that case the client needs to be
13711    /// prepared to receive output without knowing the buffer count or packet
13712    /// count yet - such clients may internally delay processing the received
13713    /// output until the client has heard from sysmem (which is when the client
13714    /// will learn the buffer count and packet count).
13715    ///
13716    /// Other clients may first wait for sysmem to allocate, prepare to receive
13717    /// output, and then send CompleteOutputBufferPartialSettings().
13718    pub fn r#complete_output_buffer_partial_settings(
13719        &self,
13720        mut buffer_lifetime_ordinal: u64,
13721    ) -> Result<(), fidl::Error> {
13722        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
13723            (buffer_lifetime_ordinal,),
13724            0x50529e5c680ae3ab,
13725            fidl::encoding::DynamicFlags::empty(),
13726        )
13727    }
13728
13729    /// This message is optional.
13730    ///
13731    /// This message is only valid after QueueInputEndOfStream() for this stream.
13732    /// The stream_lifetime_ordinal input parameter must match the
13733    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13734    /// will close the channel.
13735    ///
13736    /// A client can use this message to flush through (not discard) the last
13737    /// input data of a stream so that the stream processor server generates
13738    /// corresponding output data for all the input data before the server moves
13739    /// on to the next stream, without forcing the client to wait for
13740    /// OnOutputEndOfStream() before queueing data of another stream.
13741    ///
13742    /// The difference between QueueInputEndOfStream() and
13743    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13744    /// from the client that there will not be any more input data for the
13745    /// stream (and this info is needed by some stream processors for the stream
13746    /// processor to ever emit the very last output data).  The
13747    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13748    /// later completely discarding the rest of the current stream by closing
13749    /// the current stream (with or without a stream switch).  In contrast,
13750    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13751    /// the previously-queued input data be processed including the logical
13752    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13753    /// before moving on to any newer stream - this essentially changes the
13754    /// close-stream handling from discard to flush-through for this stream
13755    /// only.
13756    ///
13757    /// A client using this message can start providing input data for a new
13758    /// stream without that causing discard of old stream data.  That's the
13759    /// purpose of this message - to allow a client to flush through (not
13760    /// discard) the old stream's last data (instead of the default when closing
13761    /// or switching streams which is discard).
13762    ///
13763    /// Because the old stream is not done processing yet and the old stream's
13764    /// data is not being discarded, the client must be prepared to continue to
13765    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13766    /// is done. The client will know the stream_lifetime_ordinal is done when
13767    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13768    /// closes.
13769    pub fn r#flush_end_of_stream_and_close_stream(
13770        &self,
13771        mut stream_lifetime_ordinal: u64,
13772    ) -> Result<(), fidl::Error> {
13773        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
13774            (stream_lifetime_ordinal,),
13775            0x2b62c3e26d0667e6,
13776            fidl::encoding::DynamicFlags::empty(),
13777        )
13778    }
13779
13780    /// This "closes" the current stream, leaving no current stream.  In
13781    /// addition, this message can optionally release input buffers or output
13782    /// buffers.
13783    ///
13784    /// If there has never been any active stream, the stream_lifetime_ordinal
13785    /// must be zero or the server will close the channel.  If there has been an
13786    /// active stream, the stream_lifetime_ordinal must be the most recent
13787    /// active stream whether that stream is still active or not.  Else the
13788    /// server will close the channel.
13789    ///
13790    /// Multiple of this message without any new active stream in between is not
13791    /// to be considered an error, which allows a client to use this message to
13792    /// close the current stream to stop wasting processing power on a stream the
13793    /// user no longer cares about, then later decide that buffers should be
13794    /// released and send this message again with release_input_buffers and/or
13795    /// release_output_buffers true to get the buffers released, if the client is
13796    /// interested in trying to avoid overlap in resource usage between old
13797    /// buffers and new buffers (not all clients are).
13798    ///
13799    /// See also Sync().
13800    pub fn r#close_current_stream(
13801        &self,
13802        mut stream_lifetime_ordinal: u64,
13803        mut release_input_buffers: bool,
13804        mut release_output_buffers: bool,
13805    ) -> Result<(), fidl::Error> {
13806        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
13807            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
13808            0x1d8a67522170ca07,
13809            fidl::encoding::DynamicFlags::empty(),
13810        )
13811    }
13812
13813    /// On completion, all previous StreamProcessor calls have done what they're
13814    /// going to do server-side, _except_ for processing of data queued using
13815    /// QueueInputPacket().
13816    ///
13817    /// The main purpose of this call is to enable the client to wait until
13818    /// CloseCurrentStream() with release_input_buffers and/or
13819    /// release_output_buffers set to true to take effect, before the client
13820    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13821    /// de-overlapping of resource usage can be worthwhile for media buffers
13822    /// which can consume resource types whose overall pools aren't necessarily
13823    /// vast in comparison to resources consumed.  Especially if a client is
13824    /// reconfiguring buffers multiple times.
13825    ///
13826    /// Note that Sync() prior to allocating new media buffers is not alone
13827    /// sufficient to achieve non-overlap of media buffer resource usage system
13828    /// wide, but it can be a useful part of achieving that.
13829    ///
13830    /// The Sync() transits the Output ordering domain and the StreamControl
13831    /// ordering domain, but not the InputData ordering domain.
13832    ///
13833    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13834    /// presently 10.  A client that stays <= 8 in-flight streams will
13835    /// comfortably stay under the limit of 10.  While the protocol permits
13836    /// repeated SetInputBufferSettings() and the like, a client that spams the
13837    /// channel can expect that the channel will just close if the server or the
13838    /// channel itself gets too far behind.
13839    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
13840        let _response =
13841            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
13842                (),
13843                0x4b3e44300b0ec6aa,
13844                fidl::encoding::DynamicFlags::empty(),
13845                ___deadline,
13846            )?;
13847        Ok(_response)
13848    }
13849
13850    /// After the client is done with an output packet, the client needs to tell
13851    /// the stream processor that the output packet can be re-used for more
13852    /// output, via this method.
13853    ///
13854    /// It's not permitted to recycle an output packet that's already free with
13855    /// the stream processor server.  It's permitted but discouraged for a
13856    /// client to recycle an output packet that has been deallocated by an
13857    /// explicit or implicit output buffer de-configuration().  See
13858    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
13859    /// stale RecycleOutputPacket() calls.
13860    pub fn r#recycle_output_packet(
13861        &self,
13862        mut available_output_packet: &PacketHeader,
13863    ) -> Result<(), fidl::Error> {
13864        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
13865            (available_output_packet,),
13866            0x32763632b94e0bd5,
13867            fidl::encoding::DynamicFlags::empty(),
13868        )
13869    }
13870
13871    /// If the input format details are still the same as specified during
13872    /// StreamProcessor creation, this message is unnecessary and does not need
13873    /// to be sent.
13874    ///
13875    /// If the stream doesn't exist yet, this message creates the stream.
13876    ///
13877    /// The server won't send OnOutputConstraints() until after the client has
13878    /// sent at least one QueueInput* message.
13879    ///
13880    /// All servers must permit QueueInputFormatDetails() at the start of a
13881    /// stream without failing, as long as the new format is supported by the
13882    /// StreamProcessor instance.  Technically this allows for a server to only
13883    /// support the exact input format set during StreamProcessor creation, and
13884    /// that is by design.  A client that tries to switch formats and gets a
13885    /// StreamProcessor channel failure should try again one more time with a
13886    /// fresh StreamProcessor instance created with CodecFactory using the new
13887    /// input format during creation, before giving up.
13888    ///
13889    /// These format details override the format details specified during stream
13890    /// processor creation for this stream only.  The next stream will default
13891    /// back to the format details set during stream processor creation.
13892    ///
13893    /// This message is permitted at the start of the first stream (just like at
13894    /// the start of any stream).  The format specified need not match what was
13895    /// specified during stream processor creation, but if it doesn't match, the
13896    /// StreamProcessor channel might close as described above.
13897    pub fn r#queue_input_format_details(
13898        &self,
13899        mut stream_lifetime_ordinal: u64,
13900        mut format_details: &FormatDetails,
13901    ) -> Result<(), fidl::Error> {
13902        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
13903            (stream_lifetime_ordinal, format_details),
13904            0x170dc0979d52231,
13905            fidl::encoding::DynamicFlags::empty(),
13906        )
13907    }
13908
13909    /// This message queues input data to the stream processor for processing.
13910    ///
13911    /// If the stream doesn't exist yet, this message creates the new stream.
13912    ///
13913    /// The server won't send OnOutputConstraints() until after the client has
13914    /// sent at least one QueueInput* message.
13915    ///
13916    /// The client must continue to deliver input data via this message even if
13917    /// the stream processor has not yet generated the first OnOutputConstraints(),
13918    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
13919    /// previously-queued input packets.  The input data must continue as long
13920    /// as there are free packets to be assured that the server will ever
13921    /// generate the first OnOutputConstraints().
13922    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
13923        self.client.send::<StreamProcessorQueueInputPacketRequest>(
13924            (packet,),
13925            0x47173d2652d9df3b,
13926            fidl::encoding::DynamicFlags::empty(),
13927        )
13928    }
13929
13930    /// Inform the server that all QueueInputPacket() messages for this stream
13931    /// have been sent.
13932    ///
13933    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
13934    /// or StreamProcessor channel closing), there will later be a corresponding
13935    /// OnOutputEndOfStream().
13936    ///
13937    /// The corresponding OnOutputEndOfStream() message will be generated only if
13938    /// the server finishes processing the stream before the server sees the
13939    /// client close the stream (such as by starting a new stream).  A way to
13940    /// force the server to finish the stream before closing is to use
13941    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
13942    /// new stream.  Another way to force the server to finish the stream before
13943    /// closing is to wait for the OnOutputEndOfStream() before taking any action
13944    /// that closes the stream.
13945    ///
13946    /// In addition to serving as an "EndOfStream" marker to make it obvious
13947    /// client-side when all input data has been processed, if a client never
13948    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
13949    /// result in all input data getting processed through to the output.  Some
13950    /// stream processors have some internally-delayed data which only gets
13951    /// pushed through by additional input data _or_ by this EndOfStream marker.
13952    /// In that sense, this message can be viewed as a flush-through at
13953    /// InputData domain level, but the flush-through only takes effect if the
13954    /// stream processor even gets that far before the stream is just closed at
13955    /// StreamControl domain level.  This message is not alone sufficient to act
13956    /// as an overall flush-through at StreamControl level. For that, send this
13957    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
13958    /// point it becomes possible to queue input data for a new stream without
13959    /// causing discard of this older stream's data), or wait for the
13960    /// OnOutputEndOfStream() before closing the current stream.
13961    ///
13962    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
13963    /// QueueInputEndOfStream() for this stream after the first
13964    /// QueueInputEndOfStream() for this stream, a server should close the
13965    /// StreamProcessor channel.
13966    pub fn r#queue_input_end_of_stream(
13967        &self,
13968        mut stream_lifetime_ordinal: u64,
13969    ) -> Result<(), fidl::Error> {
13970        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
13971            (stream_lifetime_ordinal,),
13972            0x2051b6ad00f20b37,
13973            fidl::encoding::DynamicFlags::empty(),
13974        )
13975    }
13976}
13977
13978#[cfg(target_os = "fuchsia")]
13979impl From<StreamProcessorSynchronousProxy> for zx::NullableHandle {
13980    fn from(value: StreamProcessorSynchronousProxy) -> Self {
13981        value.into_channel().into()
13982    }
13983}
13984
13985#[cfg(target_os = "fuchsia")]
13986impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
13987    fn from(value: fidl::Channel) -> Self {
13988        Self::new(value)
13989    }
13990}
13991
13992#[cfg(target_os = "fuchsia")]
13993impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
13994    type Protocol = StreamProcessorMarker;
13995
13996    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
13997        Self::new(value.into_channel())
13998    }
13999}
14000
14001#[derive(Debug, Clone)]
14002pub struct StreamProcessorProxy {
14003    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
14004}
14005
14006impl fidl::endpoints::Proxy for StreamProcessorProxy {
14007    type Protocol = StreamProcessorMarker;
14008
14009    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
14010        Self::new(inner)
14011    }
14012
14013    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14014        self.client.into_channel().map_err(|client| Self { client })
14015    }
14016
14017    fn as_channel(&self) -> &::fidl::AsyncChannel {
14018        self.client.as_channel()
14019    }
14020}
14021
14022impl StreamProcessorProxy {
14023    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14024    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14025        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14026        Self { client: fidl::client::Client::new(channel, protocol_name) }
14027    }
14028
14029    /// Get a Stream of events from the remote end of the protocol.
14030    ///
14031    /// # Panics
14032    ///
14033    /// Panics if the event stream was already taken.
14034    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14035        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14036    }
14037
14038    /// Permit the server to use OnStreamFailed() instead of the server just
14039    /// closing the whole StreamProcessor channel on stream failure.
14040    ///
14041    /// If the server hasn't seen this message by the time a stream fails, the
14042    /// server will close the StreamProcessor channel instead of sending
14043    /// OnStreamFailed().
14044    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14045        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14046    }
14047
14048    /// This is the replacement for SetInputBufferSettings().
14049    ///
14050    /// When the client is using sysmem to allocate buffers, this message is
14051    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
14052    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
14053    /// the client-specified input settings and a BufferCollectionToken which
14054    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
14055    /// client and the StreamProcessor will be informed of the allocated buffers
14056    /// directly by sysmem via their BufferCollection channel (not via the
14057    /// StreamProcessor channel).
14058    ///
14059    /// The client must not QueueInput...() until after sysmem informs the client
14060    /// that buffer allocation has completed and was successful.
14061    ///
14062    /// The server should be prepared to see QueueInput...() before the server
14063    /// has necessarily heard from sysmem that the buffers are allocated - the
14064    /// server must tolerate either ordering, as the QueueInput...() and
14065    /// notification of sysmem allocation completion arrive on different
14066    /// channels, so the client having heard that allocation is complete doesn't
14067    /// mean the server knows that allocation is complete yet.  However, the
14068    /// server can expect that allocation is in fact complete and can expect to
14069    /// get the allocation information from sysmem immediately upon requesting
14070    /// the information from sysmem.
14071    pub fn r#set_input_buffer_partial_settings(
14072        &self,
14073        mut input_settings: StreamBufferPartialSettings,
14074    ) -> Result<(), fidl::Error> {
14075        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14076    }
14077
14078    /// This is the replacement for SetOutputBufferSettings().
14079    ///
14080    /// When the client is using sysmem to allocate buffers, this message is
14081    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14082    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14083    /// with the client-specified output settings and a BufferCollectionToken
14084    /// which the StreamProcessor will use to convey constraints to sysmem.
14085    /// Both the client and the StreamProcessor will be informed of the
14086    /// allocated buffers directly by sysmem via their BufferCollection channel
14087    /// (not via the StreamProcessor channel).
14088    ///
14089    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14090    /// received by the client with buffer_constraints_action_required true and
14091    /// stream_lifetime_ordinal equal to the client's current
14092    /// stream_lifetime_ordinal (even if there is an active stream), and is
14093    /// _permitted_ any time there is no current stream.
14094    ///
14095    /// Closing the current stream occurs on the StreamControl ordering domain,
14096    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14097    /// subsequent Sync() completion must be received by the client before the
14098    /// client knows that there's no longer a current stream.
14099    ///
14100    /// See also CompleteOutputBufferPartialSettings().
14101    pub fn r#set_output_buffer_partial_settings(
14102        &self,
14103        mut output_settings: StreamBufferPartialSettings,
14104    ) -> Result<(), fidl::Error> {
14105        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
14106    }
14107
14108    /// After SetOutputBufferPartialSettings(), the server won't send
14109    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14110    /// OnOutputEndOfStream() until after the client sends
14111    /// CompleteOutputBufferPartialSettings().
14112    ///
14113    /// Some clients may be able to send
14114    /// CompleteOutputBufferPartialSettings() immediately after
14115    /// SetOutputBufferPartialSettings() - in that case the client needs to be
14116    /// prepared to receive output without knowing the buffer count or packet
14117    /// count yet - such clients may internally delay processing the received
14118    /// output until the client has heard from sysmem (which is when the client
14119    /// will learn the buffer count and packet count).
14120    ///
14121    /// Other clients may first wait for sysmem to allocate, prepare to receive
14122    /// output, and then send CompleteOutputBufferPartialSettings().
14123    pub fn r#complete_output_buffer_partial_settings(
14124        &self,
14125        mut buffer_lifetime_ordinal: u64,
14126    ) -> Result<(), fidl::Error> {
14127        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
14128            self,
14129            buffer_lifetime_ordinal,
14130        )
14131    }
14132
14133    /// This message is optional.
14134    ///
14135    /// This message is only valid after QueueInputEndOfStream() for this stream.
14136    /// The stream_lifetime_ordinal input parameter must match the
14137    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14138    /// will close the channel.
14139    ///
14140    /// A client can use this message to flush through (not discard) the last
14141    /// input data of a stream so that the stream processor server generates
14142    /// corresponding output data for all the input data before the server moves
14143    /// on to the next stream, without forcing the client to wait for
14144    /// OnOutputEndOfStream() before queueing data of another stream.
14145    ///
14146    /// The difference between QueueInputEndOfStream() and
14147    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14148    /// from the client that there will not be any more input data for the
14149    /// stream (and this info is needed by some stream processors for the stream
14150    /// processor to ever emit the very last output data).  The
14151    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14152    /// later completely discarding the rest of the current stream by closing
14153    /// the current stream (with or without a stream switch).  In contrast,
14154    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14155    /// the previously-queued input data be processed including the logical
14156    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14157    /// before moving on to any newer stream - this essentially changes the
14158    /// close-stream handling from discard to flush-through for this stream
14159    /// only.
14160    ///
14161    /// A client using this message can start providing input data for a new
14162    /// stream without that causing discard of old stream data.  That's the
14163    /// purpose of this message - to allow a client to flush through (not
14164    /// discard) the old stream's last data (instead of the default when closing
14165    /// or switching streams which is discard).
14166    ///
14167    /// Because the old stream is not done processing yet and the old stream's
14168    /// data is not being discarded, the client must be prepared to continue to
14169    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14170    /// is done. The client will know the stream_lifetime_ordinal is done when
14171    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14172    /// closes.
14173    pub fn r#flush_end_of_stream_and_close_stream(
14174        &self,
14175        mut stream_lifetime_ordinal: u64,
14176    ) -> Result<(), fidl::Error> {
14177        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
14178            self,
14179            stream_lifetime_ordinal,
14180        )
14181    }
14182
14183    /// This "closes" the current stream, leaving no current stream.  In
14184    /// addition, this message can optionally release input buffers or output
14185    /// buffers.
14186    ///
14187    /// If there has never been any active stream, the stream_lifetime_ordinal
14188    /// must be zero or the server will close the channel.  If there has been an
14189    /// active stream, the stream_lifetime_ordinal must be the most recent
14190    /// active stream whether that stream is still active or not.  Else the
14191    /// server will close the channel.
14192    ///
14193    /// Multiple of this message without any new active stream in between is not
14194    /// to be considered an error, which allows a client to use this message to
14195    /// close the current stream to stop wasting processing power on a stream the
14196    /// user no longer cares about, then later decide that buffers should be
14197    /// released and send this message again with release_input_buffers and/or
14198    /// release_output_buffers true to get the buffers released, if the client is
14199    /// interested in trying to avoid overlap in resource usage between old
14200    /// buffers and new buffers (not all clients are).
14201    ///
14202    /// See also Sync().
14203    pub fn r#close_current_stream(
14204        &self,
14205        mut stream_lifetime_ordinal: u64,
14206        mut release_input_buffers: bool,
14207        mut release_output_buffers: bool,
14208    ) -> Result<(), fidl::Error> {
14209        StreamProcessorProxyInterface::r#close_current_stream(
14210            self,
14211            stream_lifetime_ordinal,
14212            release_input_buffers,
14213            release_output_buffers,
14214        )
14215    }
14216
14217    /// On completion, all previous StreamProcessor calls have done what they're
14218    /// going to do server-side, _except_ for processing of data queued using
14219    /// QueueInputPacket().
14220    ///
14221    /// The main purpose of this call is to enable the client to wait until
14222    /// CloseCurrentStream() with release_input_buffers and/or
14223    /// release_output_buffers set to true to take effect, before the client
14224    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14225    /// de-overlapping of resource usage can be worthwhile for media buffers
14226    /// which can consume resource types whose overall pools aren't necessarily
14227    /// vast in comparison to resources consumed.  Especially if a client is
14228    /// reconfiguring buffers multiple times.
14229    ///
14230    /// Note that Sync() prior to allocating new media buffers is not alone
14231    /// sufficient to achieve non-overlap of media buffer resource usage system
14232    /// wide, but it can be a useful part of achieving that.
14233    ///
14234    /// The Sync() transits the Output ordering domain and the StreamControl
14235    /// ordering domain, but not the InputData ordering domain.
14236    ///
14237    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14238    /// presently 10.  A client that stays <= 8 in-flight streams will
14239    /// comfortably stay under the limit of 10.  While the protocol permits
14240    /// repeated SetInputBufferSettings() and the like, a client that spams the
14241    /// channel can expect that the channel will just close if the server or the
14242    /// channel itself gets too far behind.
14243    pub fn r#sync(
14244        &self,
14245    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
14246        StreamProcessorProxyInterface::r#sync(self)
14247    }
14248
14249    /// After the client is done with an output packet, the client needs to tell
14250    /// the stream processor that the output packet can be re-used for more
14251    /// output, via this method.
14252    ///
14253    /// It's not permitted to recycle an output packet that's already free with
14254    /// the stream processor server.  It's permitted but discouraged for a
14255    /// client to recycle an output packet that has been deallocated by an
14256    /// explicit or implicit output buffer de-configuration().  See
14257    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
14258    /// stale RecycleOutputPacket() calls.
14259    pub fn r#recycle_output_packet(
14260        &self,
14261        mut available_output_packet: &PacketHeader,
14262    ) -> Result<(), fidl::Error> {
14263        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
14264    }
14265
14266    /// If the input format details are still the same as specified during
14267    /// StreamProcessor creation, this message is unnecessary and does not need
14268    /// to be sent.
14269    ///
14270    /// If the stream doesn't exist yet, this message creates the stream.
14271    ///
14272    /// The server won't send OnOutputConstraints() until after the client has
14273    /// sent at least one QueueInput* message.
14274    ///
14275    /// All servers must permit QueueInputFormatDetails() at the start of a
14276    /// stream without failing, as long as the new format is supported by the
14277    /// StreamProcessor instance.  Technically this allows for a server to only
14278    /// support the exact input format set during StreamProcessor creation, and
14279    /// that is by design.  A client that tries to switch formats and gets a
14280    /// StreamProcessor channel failure should try again one more time with a
14281    /// fresh StreamProcessor instance created with CodecFactory using the new
14282    /// input format during creation, before giving up.
14283    ///
14284    /// These format details override the format details specified during stream
14285    /// processor creation for this stream only.  The next stream will default
14286    /// back to the format details set during stream processor creation.
14287    ///
14288    /// This message is permitted at the start of the first stream (just like at
14289    /// the start of any stream).  The format specified need not match what was
14290    /// specified during stream processor creation, but if it doesn't match, the
14291    /// StreamProcessor channel might close as described above.
14292    pub fn r#queue_input_format_details(
14293        &self,
14294        mut stream_lifetime_ordinal: u64,
14295        mut format_details: &FormatDetails,
14296    ) -> Result<(), fidl::Error> {
14297        StreamProcessorProxyInterface::r#queue_input_format_details(
14298            self,
14299            stream_lifetime_ordinal,
14300            format_details,
14301        )
14302    }
14303
14304    /// This message queues input data to the stream processor for processing.
14305    ///
14306    /// If the stream doesn't exist yet, this message creates the new stream.
14307    ///
14308    /// The server won't send OnOutputConstraints() until after the client has
14309    /// sent at least one QueueInput* message.
14310    ///
14311    /// The client must continue to deliver input data via this message even if
14312    /// the stream processor has not yet generated the first OnOutputConstraints(),
14313    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
14314    /// previously-queued input packets.  The input data must continue as long
14315    /// as there are free packets to be assured that the server will ever
14316    /// generate the first OnOutputConstraints().
14317    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14318        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
14319    }
14320
14321    /// Inform the server that all QueueInputPacket() messages for this stream
14322    /// have been sent.
14323    ///
14324    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14325    /// or StreamProcessor channel closing), there will later be a corresponding
14326    /// OnOutputEndOfStream().
14327    ///
14328    /// The corresponding OnOutputEndOfStream() message will be generated only if
14329    /// the server finishes processing the stream before the server sees the
14330    /// client close the stream (such as by starting a new stream).  A way to
14331    /// force the server to finish the stream before closing is to use
14332    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
14333    /// new stream.  Another way to force the server to finish the stream before
14334    /// closing is to wait for the OnOutputEndOfStream() before taking any action
14335    /// that closes the stream.
14336    ///
14337    /// In addition to serving as an "EndOfStream" marker to make it obvious
14338    /// client-side when all input data has been processed, if a client never
14339    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
14340    /// result in all input data getting processed through to the output.  Some
14341    /// stream processors have some internally-delayed data which only gets
14342    /// pushed through by additional input data _or_ by this EndOfStream marker.
14343    /// In that sense, this message can be viewed as a flush-through at
14344    /// InputData domain level, but the flush-through only takes effect if the
14345    /// stream processor even gets that far before the stream is just closed at
14346    /// StreamControl domain level.  This message is not alone sufficient to act
14347    /// as an overall flush-through at StreamControl level. For that, send this
14348    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
14349    /// point it becomes possible to queue input data for a new stream without
14350    /// causing discard of this older stream's data), or wait for the
14351    /// OnOutputEndOfStream() before closing the current stream.
14352    ///
14353    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
14354    /// QueueInputEndOfStream() for this stream after the first
14355    /// QueueInputEndOfStream() for this stream, a server should close the
14356    /// StreamProcessor channel.
14357    pub fn r#queue_input_end_of_stream(
14358        &self,
14359        mut stream_lifetime_ordinal: u64,
14360    ) -> Result<(), fidl::Error> {
14361        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
14362    }
14363}
14364
14365impl StreamProcessorProxyInterface for StreamProcessorProxy {
14366    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14367        self.client.send::<fidl::encoding::EmptyPayload>(
14368            (),
14369            0x3940929617dbf02b,
14370            fidl::encoding::DynamicFlags::empty(),
14371        )
14372    }
14373
14374    fn r#set_input_buffer_partial_settings(
14375        &self,
14376        mut input_settings: StreamBufferPartialSettings,
14377    ) -> Result<(), fidl::Error> {
14378        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14379            (&mut input_settings,),
14380            0xb02e0663a40e4c4,
14381            fidl::encoding::DynamicFlags::empty(),
14382        )
14383    }
14384
14385    fn r#set_output_buffer_partial_settings(
14386        &self,
14387        mut output_settings: StreamBufferPartialSettings,
14388    ) -> Result<(), fidl::Error> {
14389        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14390            (&mut output_settings,),
14391            0x118bb8c819a7bbbb,
14392            fidl::encoding::DynamicFlags::empty(),
14393        )
14394    }
14395
14396    fn r#complete_output_buffer_partial_settings(
14397        &self,
14398        mut buffer_lifetime_ordinal: u64,
14399    ) -> Result<(), fidl::Error> {
14400        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14401            (buffer_lifetime_ordinal,),
14402            0x50529e5c680ae3ab,
14403            fidl::encoding::DynamicFlags::empty(),
14404        )
14405    }
14406
14407    fn r#flush_end_of_stream_and_close_stream(
14408        &self,
14409        mut stream_lifetime_ordinal: u64,
14410    ) -> Result<(), fidl::Error> {
14411        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14412            (stream_lifetime_ordinal,),
14413            0x2b62c3e26d0667e6,
14414            fidl::encoding::DynamicFlags::empty(),
14415        )
14416    }
14417
14418    fn r#close_current_stream(
14419        &self,
14420        mut stream_lifetime_ordinal: u64,
14421        mut release_input_buffers: bool,
14422        mut release_output_buffers: bool,
14423    ) -> Result<(), fidl::Error> {
14424        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14425            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14426            0x1d8a67522170ca07,
14427            fidl::encoding::DynamicFlags::empty(),
14428        )
14429    }
14430
14431    type SyncResponseFut =
14432        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
14433    fn r#sync(&self) -> Self::SyncResponseFut {
14434        fn _decode(
14435            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14436        ) -> Result<(), fidl::Error> {
14437            let _response = fidl::client::decode_transaction_body::<
14438                fidl::encoding::EmptyPayload,
14439                fidl::encoding::DefaultFuchsiaResourceDialect,
14440                0x4b3e44300b0ec6aa,
14441            >(_buf?)?;
14442            Ok(_response)
14443        }
14444        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14445            (),
14446            0x4b3e44300b0ec6aa,
14447            fidl::encoding::DynamicFlags::empty(),
14448            _decode,
14449        )
14450    }
14451
14452    fn r#recycle_output_packet(
14453        &self,
14454        mut available_output_packet: &PacketHeader,
14455    ) -> Result<(), fidl::Error> {
14456        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14457            (available_output_packet,),
14458            0x32763632b94e0bd5,
14459            fidl::encoding::DynamicFlags::empty(),
14460        )
14461    }
14462
14463    fn r#queue_input_format_details(
14464        &self,
14465        mut stream_lifetime_ordinal: u64,
14466        mut format_details: &FormatDetails,
14467    ) -> Result<(), fidl::Error> {
14468        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14469            (stream_lifetime_ordinal, format_details),
14470            0x170dc0979d52231,
14471            fidl::encoding::DynamicFlags::empty(),
14472        )
14473    }
14474
14475    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14476        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14477            (packet,),
14478            0x47173d2652d9df3b,
14479            fidl::encoding::DynamicFlags::empty(),
14480        )
14481    }
14482
14483    fn r#queue_input_end_of_stream(
14484        &self,
14485        mut stream_lifetime_ordinal: u64,
14486    ) -> Result<(), fidl::Error> {
14487        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14488            (stream_lifetime_ordinal,),
14489            0x2051b6ad00f20b37,
14490            fidl::encoding::DynamicFlags::empty(),
14491        )
14492    }
14493}
14494
14495pub struct StreamProcessorEventStream {
14496    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
14497}
14498
14499impl std::marker::Unpin for StreamProcessorEventStream {}
14500
14501impl futures::stream::FusedStream for StreamProcessorEventStream {
14502    fn is_terminated(&self) -> bool {
14503        self.event_receiver.is_terminated()
14504    }
14505}
14506
14507impl futures::Stream for StreamProcessorEventStream {
14508    type Item = Result<StreamProcessorEvent, fidl::Error>;
14509
14510    fn poll_next(
14511        mut self: std::pin::Pin<&mut Self>,
14512        cx: &mut std::task::Context<'_>,
14513    ) -> std::task::Poll<Option<Self::Item>> {
14514        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14515            &mut self.event_receiver,
14516            cx
14517        )?) {
14518            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
14519            None => std::task::Poll::Ready(None),
14520        }
14521    }
14522}
14523
14524#[derive(Debug)]
14525pub enum StreamProcessorEvent {
14526    OnStreamFailed {
14527        stream_lifetime_ordinal: u64,
14528        error: StreamError,
14529    },
14530    OnInputConstraints {
14531        input_constraints: StreamBufferConstraints,
14532    },
14533    OnOutputConstraints {
14534        output_config: StreamOutputConstraints,
14535    },
14536    OnOutputFormat {
14537        output_format: StreamOutputFormat,
14538    },
14539    OnOutputPacket {
14540        output_packet: Packet,
14541        error_detected_before: bool,
14542        error_detected_during: bool,
14543    },
14544    OnOutputEndOfStream {
14545        stream_lifetime_ordinal: u64,
14546        error_detected_before: bool,
14547    },
14548    OnFreeInputPacket {
14549        free_input_packet: PacketHeader,
14550    },
14551}
14552
14553impl StreamProcessorEvent {
14554    #[allow(irrefutable_let_patterns)]
14555    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
14556        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
14557            Some((stream_lifetime_ordinal, error))
14558        } else {
14559            None
14560        }
14561    }
14562    #[allow(irrefutable_let_patterns)]
14563    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
14564        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
14565            Some((input_constraints))
14566        } else {
14567            None
14568        }
14569    }
14570    #[allow(irrefutable_let_patterns)]
14571    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
14572        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
14573            Some((output_config))
14574        } else {
14575            None
14576        }
14577    }
14578    #[allow(irrefutable_let_patterns)]
14579    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
14580        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
14581            Some((output_format))
14582        } else {
14583            None
14584        }
14585    }
14586    #[allow(irrefutable_let_patterns)]
14587    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
14588        if let StreamProcessorEvent::OnOutputPacket {
14589            output_packet,
14590            error_detected_before,
14591            error_detected_during,
14592        } = self
14593        {
14594            Some((output_packet, error_detected_before, error_detected_during))
14595        } else {
14596            None
14597        }
14598    }
14599    #[allow(irrefutable_let_patterns)]
14600    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
14601        if let StreamProcessorEvent::OnOutputEndOfStream {
14602            stream_lifetime_ordinal,
14603            error_detected_before,
14604        } = self
14605        {
14606            Some((stream_lifetime_ordinal, error_detected_before))
14607        } else {
14608            None
14609        }
14610    }
14611    #[allow(irrefutable_let_patterns)]
14612    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
14613        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
14614            Some((free_input_packet))
14615        } else {
14616            None
14617        }
14618    }
14619
14620    /// Decodes a message buffer as a [`StreamProcessorEvent`].
14621    fn decode(
14622        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14623    ) -> Result<StreamProcessorEvent, fidl::Error> {
14624        let (bytes, _handles) = buf.split_mut();
14625        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14626        debug_assert_eq!(tx_header.tx_id, 0);
14627        match tx_header.ordinal {
14628            0x77ccf70bb061cf8e => {
14629                let mut out = fidl::new_empty!(
14630                    StreamProcessorOnStreamFailedRequest,
14631                    fidl::encoding::DefaultFuchsiaResourceDialect
14632                );
14633                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14634                Ok((StreamProcessorEvent::OnStreamFailed {
14635                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14636                    error: out.error,
14637                }))
14638            }
14639            0x211da9966a8ca0 => {
14640                let mut out = fidl::new_empty!(
14641                    StreamProcessorOnInputConstraintsRequest,
14642                    fidl::encoding::DefaultFuchsiaResourceDialect
14643                );
14644                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14645                Ok((StreamProcessorEvent::OnInputConstraints {
14646                    input_constraints: out.input_constraints,
14647                }))
14648            }
14649            0x40d8234504c170f3 => {
14650                let mut out = fidl::new_empty!(
14651                    StreamProcessorOnOutputConstraintsRequest,
14652                    fidl::encoding::DefaultFuchsiaResourceDialect
14653                );
14654                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14655                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
14656            }
14657            0x131b77ae120360bc => {
14658                let mut out = fidl::new_empty!(
14659                    StreamProcessorOnOutputFormatRequest,
14660                    fidl::encoding::DefaultFuchsiaResourceDialect
14661                );
14662                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14663                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
14664            }
14665            0x5c2029be1090ce93 => {
14666                let mut out = fidl::new_empty!(
14667                    StreamProcessorOnOutputPacketRequest,
14668                    fidl::encoding::DefaultFuchsiaResourceDialect
14669                );
14670                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14671                Ok((StreamProcessorEvent::OnOutputPacket {
14672                    output_packet: out.output_packet,
14673                    error_detected_before: out.error_detected_before,
14674                    error_detected_during: out.error_detected_during,
14675                }))
14676            }
14677            0x3bb65d237cfa50e6 => {
14678                let mut out = fidl::new_empty!(
14679                    StreamProcessorOnOutputEndOfStreamRequest,
14680                    fidl::encoding::DefaultFuchsiaResourceDialect
14681                );
14682                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14683                Ok((StreamProcessorEvent::OnOutputEndOfStream {
14684                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14685                    error_detected_before: out.error_detected_before,
14686                }))
14687            }
14688            0xeef799b28708bbd => {
14689                let mut out = fidl::new_empty!(
14690                    StreamProcessorOnFreeInputPacketRequest,
14691                    fidl::encoding::DefaultFuchsiaResourceDialect
14692                );
14693                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14694                Ok((StreamProcessorEvent::OnFreeInputPacket {
14695                    free_input_packet: out.free_input_packet,
14696                }))
14697            }
14698            _ => Err(fidl::Error::UnknownOrdinal {
14699                ordinal: tx_header.ordinal,
14700                protocol_name:
14701                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14702            }),
14703        }
14704    }
14705}
14706
14707/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
14708pub struct StreamProcessorRequestStream {
14709    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14710    is_terminated: bool,
14711}
14712
14713impl std::marker::Unpin for StreamProcessorRequestStream {}
14714
14715impl futures::stream::FusedStream for StreamProcessorRequestStream {
14716    fn is_terminated(&self) -> bool {
14717        self.is_terminated
14718    }
14719}
14720
14721impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
14722    type Protocol = StreamProcessorMarker;
14723    type ControlHandle = StreamProcessorControlHandle;
14724
14725    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
14726        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14727    }
14728
14729    fn control_handle(&self) -> Self::ControlHandle {
14730        StreamProcessorControlHandle { inner: self.inner.clone() }
14731    }
14732
14733    fn into_inner(
14734        self,
14735    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
14736    {
14737        (self.inner, self.is_terminated)
14738    }
14739
14740    fn from_inner(
14741        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14742        is_terminated: bool,
14743    ) -> Self {
14744        Self { inner, is_terminated }
14745    }
14746}
14747
14748impl futures::Stream for StreamProcessorRequestStream {
14749    type Item = Result<StreamProcessorRequest, fidl::Error>;
14750
14751    fn poll_next(
14752        mut self: std::pin::Pin<&mut Self>,
14753        cx: &mut std::task::Context<'_>,
14754    ) -> std::task::Poll<Option<Self::Item>> {
14755        let this = &mut *self;
14756        if this.inner.check_shutdown(cx) {
14757            this.is_terminated = true;
14758            return std::task::Poll::Ready(None);
14759        }
14760        if this.is_terminated {
14761            panic!("polled StreamProcessorRequestStream after completion");
14762        }
14763        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
14764            |bytes, handles| {
14765                match this.inner.channel().read_etc(cx, bytes, handles) {
14766                    std::task::Poll::Ready(Ok(())) => {}
14767                    std::task::Poll::Pending => return std::task::Poll::Pending,
14768                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
14769                        this.is_terminated = true;
14770                        return std::task::Poll::Ready(None);
14771                    }
14772                    std::task::Poll::Ready(Err(e)) => {
14773                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14774                            e.into(),
14775                        ))));
14776                    }
14777                }
14778
14779                // A message has been received from the channel
14780                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14781
14782                std::task::Poll::Ready(Some(match header.ordinal {
14783                    0x3940929617dbf02b => {
14784                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14785                        let mut req = fidl::new_empty!(
14786                            fidl::encoding::EmptyPayload,
14787                            fidl::encoding::DefaultFuchsiaResourceDialect
14788                        );
14789                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14790                        let control_handle =
14791                            StreamProcessorControlHandle { inner: this.inner.clone() };
14792                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
14793                    }
14794                    0xb02e0663a40e4c4 => {
14795                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14796                        let mut req = fidl::new_empty!(
14797                            StreamProcessorSetInputBufferPartialSettingsRequest,
14798                            fidl::encoding::DefaultFuchsiaResourceDialect
14799                        );
14800                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14801                        let control_handle =
14802                            StreamProcessorControlHandle { inner: this.inner.clone() };
14803                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
14804                            input_settings: req.input_settings,
14805
14806                            control_handle,
14807                        })
14808                    }
14809                    0x118bb8c819a7bbbb => {
14810                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14811                        let mut req = fidl::new_empty!(
14812                            StreamProcessorSetOutputBufferPartialSettingsRequest,
14813                            fidl::encoding::DefaultFuchsiaResourceDialect
14814                        );
14815                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14816                        let control_handle =
14817                            StreamProcessorControlHandle { inner: this.inner.clone() };
14818                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
14819                            output_settings: req.output_settings,
14820
14821                            control_handle,
14822                        })
14823                    }
14824                    0x50529e5c680ae3ab => {
14825                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14826                        let mut req = fidl::new_empty!(
14827                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
14828                            fidl::encoding::DefaultFuchsiaResourceDialect
14829                        );
14830                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14831                        let control_handle =
14832                            StreamProcessorControlHandle { inner: this.inner.clone() };
14833                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
14834                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
14835
14836                            control_handle,
14837                        })
14838                    }
14839                    0x2b62c3e26d0667e6 => {
14840                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14841                        let mut req = fidl::new_empty!(
14842                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
14843                            fidl::encoding::DefaultFuchsiaResourceDialect
14844                        );
14845                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14846                        let control_handle =
14847                            StreamProcessorControlHandle { inner: this.inner.clone() };
14848                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
14849                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14850
14851                            control_handle,
14852                        })
14853                    }
14854                    0x1d8a67522170ca07 => {
14855                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14856                        let mut req = fidl::new_empty!(
14857                            StreamProcessorCloseCurrentStreamRequest,
14858                            fidl::encoding::DefaultFuchsiaResourceDialect
14859                        );
14860                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14861                        let control_handle =
14862                            StreamProcessorControlHandle { inner: this.inner.clone() };
14863                        Ok(StreamProcessorRequest::CloseCurrentStream {
14864                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14865                            release_input_buffers: req.release_input_buffers,
14866                            release_output_buffers: req.release_output_buffers,
14867
14868                            control_handle,
14869                        })
14870                    }
14871                    0x4b3e44300b0ec6aa => {
14872                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14873                        let mut req = fidl::new_empty!(
14874                            fidl::encoding::EmptyPayload,
14875                            fidl::encoding::DefaultFuchsiaResourceDialect
14876                        );
14877                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14878                        let control_handle =
14879                            StreamProcessorControlHandle { inner: this.inner.clone() };
14880                        Ok(StreamProcessorRequest::Sync {
14881                            responder: StreamProcessorSyncResponder {
14882                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14883                                tx_id: header.tx_id,
14884                            },
14885                        })
14886                    }
14887                    0x32763632b94e0bd5 => {
14888                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14889                        let mut req = fidl::new_empty!(
14890                            StreamProcessorRecycleOutputPacketRequest,
14891                            fidl::encoding::DefaultFuchsiaResourceDialect
14892                        );
14893                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14894                        let control_handle =
14895                            StreamProcessorControlHandle { inner: this.inner.clone() };
14896                        Ok(StreamProcessorRequest::RecycleOutputPacket {
14897                            available_output_packet: req.available_output_packet,
14898
14899                            control_handle,
14900                        })
14901                    }
14902                    0x170dc0979d52231 => {
14903                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14904                        let mut req = fidl::new_empty!(
14905                            StreamProcessorQueueInputFormatDetailsRequest,
14906                            fidl::encoding::DefaultFuchsiaResourceDialect
14907                        );
14908                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
14909                        let control_handle =
14910                            StreamProcessorControlHandle { inner: this.inner.clone() };
14911                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
14912                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14913                            format_details: req.format_details,
14914
14915                            control_handle,
14916                        })
14917                    }
14918                    0x47173d2652d9df3b => {
14919                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14920                        let mut req = fidl::new_empty!(
14921                            StreamProcessorQueueInputPacketRequest,
14922                            fidl::encoding::DefaultFuchsiaResourceDialect
14923                        );
14924                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14925                        let control_handle =
14926                            StreamProcessorControlHandle { inner: this.inner.clone() };
14927                        Ok(StreamProcessorRequest::QueueInputPacket {
14928                            packet: req.packet,
14929
14930                            control_handle,
14931                        })
14932                    }
14933                    0x2051b6ad00f20b37 => {
14934                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14935                        let mut req = fidl::new_empty!(
14936                            StreamProcessorQueueInputEndOfStreamRequest,
14937                            fidl::encoding::DefaultFuchsiaResourceDialect
14938                        );
14939                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14940                        let control_handle =
14941                            StreamProcessorControlHandle { inner: this.inner.clone() };
14942                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
14943                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14944
14945                            control_handle,
14946                        })
14947                    }
14948                    _ => Err(fidl::Error::UnknownOrdinal {
14949                        ordinal: header.ordinal,
14950                        protocol_name:
14951                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14952                    }),
14953                }))
14954            },
14955        )
14956    }
14957}
14958
14959/// Overview of operation:
14960///
14961/// 1. Create
14962///   * create via CodecFactory - see CodecFactory
14963///   * create via LicenseSession - see LicenseSession
14964/// 2. Get input constraints
14965///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
14966///     stream processor creation.
14967/// 3. Provide input buffers
14968///   * SetInputBufferPartialSettings()
14969/// 4. Deliver input data
14970///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
14971///     possibly working through all input packets repeatedly before...
14972/// 5. Get output constraints and format
14973///   * OnOutputConstraints()
14974///   * This is not sent until after at least one QueueInput* message is sent by
14975///     the client, even if the underlying processor behind the StreamProcessor
14976///     doesn't fundamentally need any input data to determine its output
14977///     constraints.  This server behavior prevents clients taking an incorrect
14978///     dependency on the output constraints showing up before input is
14979///     delivered.
14980///   * A client must tolerate this arriving as late as after substantial input
14981///     data has been delivered, including lots of input packet recycling via
14982///     OnFreeInputPacket().
14983///   * This message can arrive more than once before the first output data.
14984/// 6. Provide output buffers
14985///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
14986/// 7. Data flows, with optional EndOfStream
14987///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
14988///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
14989///
14990/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
14991/// very few capabilities) just in case the decoding SW has a vulnerability
14992/// which could be used to take over the StreamProcessor server.  Clients of the
14993/// stream processor interface using decoders and processing streams of separate
14994/// security contexts, to a greater extent than some other interfaces, need to
14995/// protect themselves against invalid server behavior, such as double-free of a
14996/// packet_index and any other invalid server behavior.  Having fed in
14997/// compressed data of one security context, don't place too much trust in a
14998/// single StreamProcessor instance to not mix data among any buffers that
14999/// StreamProcessor server has ever been told about.  Instead, create separate
15000/// StreamProcessor instances for use by security-separate client-side contexts.
15001/// While the picture for HW-based decoders looks somewhat different and is out
15002/// of scope of this paragraph, the client should always use separate
15003/// StreamProcessor instances for security-separate client-side contexts.
15004///
15005/// Descriptions of actions taken by methods of this protocol and the states of
15006/// things are given as if the methods are synchronously executed by the stream
15007/// processor server, but in reality, as is typical of FIDL interfaces, the
15008/// message processing is async.  The states described are to be read as the
15009/// state from the client's point of view unless otherwise stated.  Events
15010/// coming back from the server are of course delivered async, and a client that
15011/// processes more than one stream per StreamProcessor instance needs to care
15012/// whether a given event is from the current stream vs. some older
15013/// soon-to-be-gone stream.
15014///
15015/// The Sync() method's main purpose is to enable the client to robustly prevent
15016/// having both old and new buffers allocated in the system at the same time,
15017/// since media buffers can be significantly large, depending. The Sync() method
15018/// achieves this by only delivering it's response when all previous calls to
15019/// the StreamProcessor protocol have actually taken effect in the
15020/// StreamControl ordering domain. Sync() can also be used to wait for the
15021/// stream processor server to catch up if there's a possibility that a client
15022/// might otherwise get too far ahead of the StreamProcessor server, by for
15023/// example requesting creation of a large number of streams in a row.  It can
15024/// also be used during debugging to ensure that a stream processor server
15025/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
15026/// for correctness - only potentially required to de-overlap resource usage.
15027///
15028/// It's possible to re-use a StreamProcessor instance for another stream, and
15029/// doing so can sometimes skip over re-allocation of buffers. This can be a
15030/// useful thing to do for cases like seeking to a new location - at the
15031/// StreamProcessor interface that can look like switching to a new stream.
15032#[derive(Debug)]
15033pub enum StreamProcessorRequest {
15034    /// Permit the server to use OnStreamFailed() instead of the server just
15035    /// closing the whole StreamProcessor channel on stream failure.
15036    ///
15037    /// If the server hasn't seen this message by the time a stream fails, the
15038    /// server will close the StreamProcessor channel instead of sending
15039    /// OnStreamFailed().
15040    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
15041    /// This is the replacement for SetInputBufferSettings().
15042    ///
15043    /// When the client is using sysmem to allocate buffers, this message is
15044    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
15045    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
15046    /// the client-specified input settings and a BufferCollectionToken which
15047    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
15048    /// client and the StreamProcessor will be informed of the allocated buffers
15049    /// directly by sysmem via their BufferCollection channel (not via the
15050    /// StreamProcessor channel).
15051    ///
15052    /// The client must not QueueInput...() until after sysmem informs the client
15053    /// that buffer allocation has completed and was successful.
15054    ///
15055    /// The server should be prepared to see QueueInput...() before the server
15056    /// has necessarily heard from sysmem that the buffers are allocated - the
15057    /// server must tolerate either ordering, as the QueueInput...() and
15058    /// notification of sysmem allocation completion arrive on different
15059    /// channels, so the client having heard that allocation is complete doesn't
15060    /// mean the server knows that allocation is complete yet.  However, the
15061    /// server can expect that allocation is in fact complete and can expect to
15062    /// get the allocation information from sysmem immediately upon requesting
15063    /// the information from sysmem.
15064    SetInputBufferPartialSettings {
15065        input_settings: StreamBufferPartialSettings,
15066        control_handle: StreamProcessorControlHandle,
15067    },
15068    /// This is the replacement for SetOutputBufferSettings().
15069    ///
15070    /// When the client is using sysmem to allocate buffers, this message is
15071    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
15072    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
15073    /// with the client-specified output settings and a BufferCollectionToken
15074    /// which the StreamProcessor will use to convey constraints to sysmem.
15075    /// Both the client and the StreamProcessor will be informed of the
15076    /// allocated buffers directly by sysmem via their BufferCollection channel
15077    /// (not via the StreamProcessor channel).
15078    ///
15079    /// Configuring output buffers is _required_ after OnOutputConstraints() is
15080    /// received by the client with buffer_constraints_action_required true and
15081    /// stream_lifetime_ordinal equal to the client's current
15082    /// stream_lifetime_ordinal (even if there is an active stream), and is
15083    /// _permitted_ any time there is no current stream.
15084    ///
15085    /// Closing the current stream occurs on the StreamControl ordering domain,
15086    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15087    /// subsequent Sync() completion must be received by the client before the
15088    /// client knows that there's no longer a current stream.
15089    ///
15090    /// See also CompleteOutputBufferPartialSettings().
15091    SetOutputBufferPartialSettings {
15092        output_settings: StreamBufferPartialSettings,
15093        control_handle: StreamProcessorControlHandle,
15094    },
15095    /// After SetOutputBufferPartialSettings(), the server won't send
15096    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15097    /// OnOutputEndOfStream() until after the client sends
15098    /// CompleteOutputBufferPartialSettings().
15099    ///
15100    /// Some clients may be able to send
15101    /// CompleteOutputBufferPartialSettings() immediately after
15102    /// SetOutputBufferPartialSettings() - in that case the client needs to be
15103    /// prepared to receive output without knowing the buffer count or packet
15104    /// count yet - such clients may internally delay processing the received
15105    /// output until the client has heard from sysmem (which is when the client
15106    /// will learn the buffer count and packet count).
15107    ///
15108    /// Other clients may first wait for sysmem to allocate, prepare to receive
15109    /// output, and then send CompleteOutputBufferPartialSettings().
15110    CompleteOutputBufferPartialSettings {
15111        buffer_lifetime_ordinal: u64,
15112        control_handle: StreamProcessorControlHandle,
15113    },
15114    /// This message is optional.
15115    ///
15116    /// This message is only valid after QueueInputEndOfStream() for this stream.
15117    /// The stream_lifetime_ordinal input parameter must match the
15118    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15119    /// will close the channel.
15120    ///
15121    /// A client can use this message to flush through (not discard) the last
15122    /// input data of a stream so that the stream processor server generates
15123    /// corresponding output data for all the input data before the server moves
15124    /// on to the next stream, without forcing the client to wait for
15125    /// OnOutputEndOfStream() before queueing data of another stream.
15126    ///
15127    /// The difference between QueueInputEndOfStream() and
15128    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15129    /// from the client that there will not be any more input data for the
15130    /// stream (and this info is needed by some stream processors for the stream
15131    /// processor to ever emit the very last output data).  The
15132    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15133    /// later completely discarding the rest of the current stream by closing
15134    /// the current stream (with or without a stream switch).  In contrast,
15135    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15136    /// the previously-queued input data be processed including the logical
15137    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15138    /// before moving on to any newer stream - this essentially changes the
15139    /// close-stream handling from discard to flush-through for this stream
15140    /// only.
15141    ///
15142    /// A client using this message can start providing input data for a new
15143    /// stream without that causing discard of old stream data.  That's the
15144    /// purpose of this message - to allow a client to flush through (not
15145    /// discard) the old stream's last data (instead of the default when closing
15146    /// or switching streams which is discard).
15147    ///
15148    /// Because the old stream is not done processing yet and the old stream's
15149    /// data is not being discarded, the client must be prepared to continue to
15150    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15151    /// is done. The client will know the stream_lifetime_ordinal is done when
15152    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15153    /// closes.
15154    FlushEndOfStreamAndCloseStream {
15155        stream_lifetime_ordinal: u64,
15156        control_handle: StreamProcessorControlHandle,
15157    },
15158    /// This "closes" the current stream, leaving no current stream.  In
15159    /// addition, this message can optionally release input buffers or output
15160    /// buffers.
15161    ///
15162    /// If there has never been any active stream, the stream_lifetime_ordinal
15163    /// must be zero or the server will close the channel.  If there has been an
15164    /// active stream, the stream_lifetime_ordinal must be the most recent
15165    /// active stream whether that stream is still active or not.  Else the
15166    /// server will close the channel.
15167    ///
15168    /// Multiple of this message without any new active stream in between is not
15169    /// to be considered an error, which allows a client to use this message to
15170    /// close the current stream to stop wasting processing power on a stream the
15171    /// user no longer cares about, then later decide that buffers should be
15172    /// released and send this message again with release_input_buffers and/or
15173    /// release_output_buffers true to get the buffers released, if the client is
15174    /// interested in trying to avoid overlap in resource usage between old
15175    /// buffers and new buffers (not all clients are).
15176    ///
15177    /// See also Sync().
15178    CloseCurrentStream {
15179        stream_lifetime_ordinal: u64,
15180        release_input_buffers: bool,
15181        release_output_buffers: bool,
15182        control_handle: StreamProcessorControlHandle,
15183    },
15184    /// On completion, all previous StreamProcessor calls have done what they're
15185    /// going to do server-side, _except_ for processing of data queued using
15186    /// QueueInputPacket().
15187    ///
15188    /// The main purpose of this call is to enable the client to wait until
15189    /// CloseCurrentStream() with release_input_buffers and/or
15190    /// release_output_buffers set to true to take effect, before the client
15191    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15192    /// de-overlapping of resource usage can be worthwhile for media buffers
15193    /// which can consume resource types whose overall pools aren't necessarily
15194    /// vast in comparison to resources consumed.  Especially if a client is
15195    /// reconfiguring buffers multiple times.
15196    ///
15197    /// Note that Sync() prior to allocating new media buffers is not alone
15198    /// sufficient to achieve non-overlap of media buffer resource usage system
15199    /// wide, but it can be a useful part of achieving that.
15200    ///
15201    /// The Sync() transits the Output ordering domain and the StreamControl
15202    /// ordering domain, but not the InputData ordering domain.
15203    ///
15204    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15205    /// presently 10.  A client that stays <= 8 in-flight streams will
15206    /// comfortably stay under the limit of 10.  While the protocol permits
15207    /// repeated SetInputBufferSettings() and the like, a client that spams the
15208    /// channel can expect that the channel will just close if the server or the
15209    /// channel itself gets too far behind.
15210    Sync { responder: StreamProcessorSyncResponder },
15211    /// After the client is done with an output packet, the client needs to tell
15212    /// the stream processor that the output packet can be re-used for more
15213    /// output, via this method.
15214    ///
15215    /// It's not permitted to recycle an output packet that's already free with
15216    /// the stream processor server.  It's permitted but discouraged for a
15217    /// client to recycle an output packet that has been deallocated by an
15218    /// explicit or implicit output buffer de-configuration().  See
15219    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
15220    /// stale RecycleOutputPacket() calls.
15221    RecycleOutputPacket {
15222        available_output_packet: PacketHeader,
15223        control_handle: StreamProcessorControlHandle,
15224    },
15225    /// If the input format details are still the same as specified during
15226    /// StreamProcessor creation, this message is unnecessary and does not need
15227    /// to be sent.
15228    ///
15229    /// If the stream doesn't exist yet, this message creates the stream.
15230    ///
15231    /// The server won't send OnOutputConstraints() until after the client has
15232    /// sent at least one QueueInput* message.
15233    ///
15234    /// All servers must permit QueueInputFormatDetails() at the start of a
15235    /// stream without failing, as long as the new format is supported by the
15236    /// StreamProcessor instance.  Technically this allows for a server to only
15237    /// support the exact input format set during StreamProcessor creation, and
15238    /// that is by design.  A client that tries to switch formats and gets a
15239    /// StreamProcessor channel failure should try again one more time with a
15240    /// fresh StreamProcessor instance created with CodecFactory using the new
15241    /// input format during creation, before giving up.
15242    ///
15243    /// These format details override the format details specified during stream
15244    /// processor creation for this stream only.  The next stream will default
15245    /// back to the format details set during stream processor creation.
15246    ///
15247    /// This message is permitted at the start of the first stream (just like at
15248    /// the start of any stream).  The format specified need not match what was
15249    /// specified during stream processor creation, but if it doesn't match, the
15250    /// StreamProcessor channel might close as described above.
15251    QueueInputFormatDetails {
15252        stream_lifetime_ordinal: u64,
15253        format_details: FormatDetails,
15254        control_handle: StreamProcessorControlHandle,
15255    },
15256    /// This message queues input data to the stream processor for processing.
15257    ///
15258    /// If the stream doesn't exist yet, this message creates the new stream.
15259    ///
15260    /// The server won't send OnOutputConstraints() until after the client has
15261    /// sent at least one QueueInput* message.
15262    ///
15263    /// The client must continue to deliver input data via this message even if
15264    /// the stream processor has not yet generated the first OnOutputConstraints(),
15265    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
15266    /// previously-queued input packets.  The input data must continue as long
15267    /// as there are free packets to be assured that the server will ever
15268    /// generate the first OnOutputConstraints().
15269    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
15270    /// Inform the server that all QueueInputPacket() messages for this stream
15271    /// have been sent.
15272    ///
15273    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15274    /// or StreamProcessor channel closing), there will later be a corresponding
15275    /// OnOutputEndOfStream().
15276    ///
15277    /// The corresponding OnOutputEndOfStream() message will be generated only if
15278    /// the server finishes processing the stream before the server sees the
15279    /// client close the stream (such as by starting a new stream).  A way to
15280    /// force the server to finish the stream before closing is to use
15281    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
15282    /// new stream.  Another way to force the server to finish the stream before
15283    /// closing is to wait for the OnOutputEndOfStream() before taking any action
15284    /// that closes the stream.
15285    ///
15286    /// In addition to serving as an "EndOfStream" marker to make it obvious
15287    /// client-side when all input data has been processed, if a client never
15288    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
15289    /// result in all input data getting processed through to the output.  Some
15290    /// stream processors have some internally-delayed data which only gets
15291    /// pushed through by additional input data _or_ by this EndOfStream marker.
15292    /// In that sense, this message can be viewed as a flush-through at
15293    /// InputData domain level, but the flush-through only takes effect if the
15294    /// stream processor even gets that far before the stream is just closed at
15295    /// StreamControl domain level.  This message is not alone sufficient to act
15296    /// as an overall flush-through at StreamControl level. For that, send this
15297    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
15298    /// point it becomes possible to queue input data for a new stream without
15299    /// causing discard of this older stream's data), or wait for the
15300    /// OnOutputEndOfStream() before closing the current stream.
15301    ///
15302    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
15303    /// QueueInputEndOfStream() for this stream after the first
15304    /// QueueInputEndOfStream() for this stream, a server should close the
15305    /// StreamProcessor channel.
15306    QueueInputEndOfStream {
15307        stream_lifetime_ordinal: u64,
15308        control_handle: StreamProcessorControlHandle,
15309    },
15310}
15311
15312impl StreamProcessorRequest {
15313    #[allow(irrefutable_let_patterns)]
15314    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
15315        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
15316            Some((control_handle))
15317        } else {
15318            None
15319        }
15320    }
15321
15322    #[allow(irrefutable_let_patterns)]
15323    pub fn into_set_input_buffer_partial_settings(
15324        self,
15325    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15326        if let StreamProcessorRequest::SetInputBufferPartialSettings {
15327            input_settings,
15328            control_handle,
15329        } = self
15330        {
15331            Some((input_settings, control_handle))
15332        } else {
15333            None
15334        }
15335    }
15336
15337    #[allow(irrefutable_let_patterns)]
15338    pub fn into_set_output_buffer_partial_settings(
15339        self,
15340    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15341        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
15342            output_settings,
15343            control_handle,
15344        } = self
15345        {
15346            Some((output_settings, control_handle))
15347        } else {
15348            None
15349        }
15350    }
15351
15352    #[allow(irrefutable_let_patterns)]
15353    pub fn into_complete_output_buffer_partial_settings(
15354        self,
15355    ) -> Option<(u64, StreamProcessorControlHandle)> {
15356        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
15357            buffer_lifetime_ordinal,
15358            control_handle,
15359        } = self
15360        {
15361            Some((buffer_lifetime_ordinal, control_handle))
15362        } else {
15363            None
15364        }
15365    }
15366
15367    #[allow(irrefutable_let_patterns)]
15368    pub fn into_flush_end_of_stream_and_close_stream(
15369        self,
15370    ) -> Option<(u64, StreamProcessorControlHandle)> {
15371        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
15372            stream_lifetime_ordinal,
15373            control_handle,
15374        } = self
15375        {
15376            Some((stream_lifetime_ordinal, control_handle))
15377        } else {
15378            None
15379        }
15380    }
15381
15382    #[allow(irrefutable_let_patterns)]
15383    pub fn into_close_current_stream(
15384        self,
15385    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
15386        if let StreamProcessorRequest::CloseCurrentStream {
15387            stream_lifetime_ordinal,
15388            release_input_buffers,
15389            release_output_buffers,
15390            control_handle,
15391        } = self
15392        {
15393            Some((
15394                stream_lifetime_ordinal,
15395                release_input_buffers,
15396                release_output_buffers,
15397                control_handle,
15398            ))
15399        } else {
15400            None
15401        }
15402    }
15403
15404    #[allow(irrefutable_let_patterns)]
15405    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
15406        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
15407    }
15408
15409    #[allow(irrefutable_let_patterns)]
15410    pub fn into_recycle_output_packet(
15411        self,
15412    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
15413        if let StreamProcessorRequest::RecycleOutputPacket {
15414            available_output_packet,
15415            control_handle,
15416        } = self
15417        {
15418            Some((available_output_packet, control_handle))
15419        } else {
15420            None
15421        }
15422    }
15423
15424    #[allow(irrefutable_let_patterns)]
15425    pub fn into_queue_input_format_details(
15426        self,
15427    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
15428        if let StreamProcessorRequest::QueueInputFormatDetails {
15429            stream_lifetime_ordinal,
15430            format_details,
15431            control_handle,
15432        } = self
15433        {
15434            Some((stream_lifetime_ordinal, format_details, control_handle))
15435        } else {
15436            None
15437        }
15438    }
15439
15440    #[allow(irrefutable_let_patterns)]
15441    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
15442        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
15443            Some((packet, control_handle))
15444        } else {
15445            None
15446        }
15447    }
15448
15449    #[allow(irrefutable_let_patterns)]
15450    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
15451        if let StreamProcessorRequest::QueueInputEndOfStream {
15452            stream_lifetime_ordinal,
15453            control_handle,
15454        } = self
15455        {
15456            Some((stream_lifetime_ordinal, control_handle))
15457        } else {
15458            None
15459        }
15460    }
15461
15462    /// Name of the method defined in FIDL
15463    pub fn method_name(&self) -> &'static str {
15464        match *self {
15465            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
15466            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
15467                "set_input_buffer_partial_settings"
15468            }
15469            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
15470                "set_output_buffer_partial_settings"
15471            }
15472            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
15473                "complete_output_buffer_partial_settings"
15474            }
15475            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
15476                "flush_end_of_stream_and_close_stream"
15477            }
15478            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
15479            StreamProcessorRequest::Sync { .. } => "sync",
15480            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
15481            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
15482            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
15483            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
15484        }
15485    }
15486}
15487
15488#[derive(Debug, Clone)]
15489pub struct StreamProcessorControlHandle {
15490    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
15491}
15492
15493impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
15494    fn shutdown(&self) {
15495        self.inner.shutdown()
15496    }
15497
15498    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15499        self.inner.shutdown_with_epitaph(status)
15500    }
15501
15502    fn is_closed(&self) -> bool {
15503        self.inner.channel().is_closed()
15504    }
15505    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
15506        self.inner.channel().on_closed()
15507    }
15508
15509    #[cfg(target_os = "fuchsia")]
15510    fn signal_peer(
15511        &self,
15512        clear_mask: zx::Signals,
15513        set_mask: zx::Signals,
15514    ) -> Result<(), zx_status::Status> {
15515        use fidl::Peered;
15516        self.inner.channel().signal_peer(clear_mask, set_mask)
15517    }
15518}
15519
15520impl StreamProcessorControlHandle {
15521    pub fn send_on_stream_failed(
15522        &self,
15523        mut stream_lifetime_ordinal: u64,
15524        mut error: StreamError,
15525    ) -> Result<(), fidl::Error> {
15526        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
15527            (stream_lifetime_ordinal, error),
15528            0,
15529            0x77ccf70bb061cf8e,
15530            fidl::encoding::DynamicFlags::empty(),
15531        )
15532    }
15533
15534    pub fn send_on_input_constraints(
15535        &self,
15536        mut input_constraints: &StreamBufferConstraints,
15537    ) -> Result<(), fidl::Error> {
15538        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
15539            (input_constraints,),
15540            0,
15541            0x211da9966a8ca0,
15542            fidl::encoding::DynamicFlags::empty(),
15543        )
15544    }
15545
15546    pub fn send_on_output_constraints(
15547        &self,
15548        mut output_config: &StreamOutputConstraints,
15549    ) -> Result<(), fidl::Error> {
15550        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
15551            (output_config,),
15552            0,
15553            0x40d8234504c170f3,
15554            fidl::encoding::DynamicFlags::empty(),
15555        )
15556    }
15557
15558    pub fn send_on_output_format(
15559        &self,
15560        mut output_format: &StreamOutputFormat,
15561    ) -> Result<(), fidl::Error> {
15562        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
15563            (output_format,),
15564            0,
15565            0x131b77ae120360bc,
15566            fidl::encoding::DynamicFlags::empty(),
15567        )
15568    }
15569
15570    pub fn send_on_output_packet(
15571        &self,
15572        mut output_packet: &Packet,
15573        mut error_detected_before: bool,
15574        mut error_detected_during: bool,
15575    ) -> Result<(), fidl::Error> {
15576        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
15577            (output_packet, error_detected_before, error_detected_during),
15578            0,
15579            0x5c2029be1090ce93,
15580            fidl::encoding::DynamicFlags::empty(),
15581        )
15582    }
15583
15584    pub fn send_on_output_end_of_stream(
15585        &self,
15586        mut stream_lifetime_ordinal: u64,
15587        mut error_detected_before: bool,
15588    ) -> Result<(), fidl::Error> {
15589        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
15590            (stream_lifetime_ordinal, error_detected_before),
15591            0,
15592            0x3bb65d237cfa50e6,
15593            fidl::encoding::DynamicFlags::empty(),
15594        )
15595    }
15596
15597    pub fn send_on_free_input_packet(
15598        &self,
15599        mut free_input_packet: &PacketHeader,
15600    ) -> Result<(), fidl::Error> {
15601        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
15602            (free_input_packet,),
15603            0,
15604            0xeef799b28708bbd,
15605            fidl::encoding::DynamicFlags::empty(),
15606        )
15607    }
15608}
15609
15610#[must_use = "FIDL methods require a response to be sent"]
15611#[derive(Debug)]
15612pub struct StreamProcessorSyncResponder {
15613    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
15614    tx_id: u32,
15615}
15616
15617/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
15618/// if the responder is dropped without sending a response, so that the client
15619/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15620impl std::ops::Drop for StreamProcessorSyncResponder {
15621    fn drop(&mut self) {
15622        self.control_handle.shutdown();
15623        // Safety: drops once, never accessed again
15624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15625    }
15626}
15627
15628impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
15629    type ControlHandle = StreamProcessorControlHandle;
15630
15631    fn control_handle(&self) -> &StreamProcessorControlHandle {
15632        &self.control_handle
15633    }
15634
15635    fn drop_without_shutdown(mut self) {
15636        // Safety: drops once, never accessed again due to mem::forget
15637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15638        // Prevent Drop from running (which would shut down the channel)
15639        std::mem::forget(self);
15640    }
15641}
15642
15643impl StreamProcessorSyncResponder {
15644    /// Sends a response to the FIDL transaction.
15645    ///
15646    /// Sets the channel to shutdown if an error occurs.
15647    pub fn send(self) -> Result<(), fidl::Error> {
15648        let _result = self.send_raw();
15649        if _result.is_err() {
15650            self.control_handle.shutdown();
15651        }
15652        self.drop_without_shutdown();
15653        _result
15654    }
15655
15656    /// Similar to "send" but does not shutdown the channel if an error occurs.
15657    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15658        let _result = self.send_raw();
15659        self.drop_without_shutdown();
15660        _result
15661    }
15662
15663    fn send_raw(&self) -> Result<(), fidl::Error> {
15664        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15665            (),
15666            self.tx_id,
15667            0x4b3e44300b0ec6aa,
15668            fidl::encoding::DynamicFlags::empty(),
15669        )
15670    }
15671}
15672
15673#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15674pub struct StreamSinkMarker;
15675
15676impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
15677    type Proxy = StreamSinkProxy;
15678    type RequestStream = StreamSinkRequestStream;
15679    #[cfg(target_os = "fuchsia")]
15680    type SynchronousProxy = StreamSinkSynchronousProxy;
15681
15682    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
15683}
15684
15685pub trait StreamSinkProxyInterface: Send + Sync {
15686    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15687    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
15688    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
15689    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
15690    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15691    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
15692    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
15693}
15694#[derive(Debug)]
15695#[cfg(target_os = "fuchsia")]
15696pub struct StreamSinkSynchronousProxy {
15697    client: fidl::client::sync::Client,
15698}
15699
15700#[cfg(target_os = "fuchsia")]
15701impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
15702    type Proxy = StreamSinkProxy;
15703    type Protocol = StreamSinkMarker;
15704
15705    fn from_channel(inner: fidl::Channel) -> Self {
15706        Self::new(inner)
15707    }
15708
15709    fn into_channel(self) -> fidl::Channel {
15710        self.client.into_channel()
15711    }
15712
15713    fn as_channel(&self) -> &fidl::Channel {
15714        self.client.as_channel()
15715    }
15716}
15717
15718#[cfg(target_os = "fuchsia")]
15719impl StreamSinkSynchronousProxy {
15720    pub fn new(channel: fidl::Channel) -> Self {
15721        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15722        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
15723    }
15724
15725    pub fn into_channel(self) -> fidl::Channel {
15726        self.client.into_channel()
15727    }
15728
15729    /// Waits until an event arrives and returns it. It is safe for other
15730    /// threads to make concurrent requests while waiting for an event.
15731    pub fn wait_for_event(
15732        &self,
15733        deadline: zx::MonotonicInstant,
15734    ) -> Result<StreamSinkEvent, fidl::Error> {
15735        StreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
15736    }
15737
15738    /// Sends a packet to the service. The response is sent when the service is
15739    /// done with the associated payload memory.
15740    ///
15741    /// `packet` must be valid for the current buffer set, otherwise the service
15742    /// will close the connection.
15743    pub fn r#send_packet(
15744        &self,
15745        mut packet: &StreamPacket,
15746        ___deadline: zx::MonotonicInstant,
15747    ) -> Result<(), fidl::Error> {
15748        let _response =
15749            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
15750                (packet,),
15751                0x67cddd607442775f,
15752                fidl::encoding::DynamicFlags::empty(),
15753                ___deadline,
15754            )?;
15755        Ok(_response)
15756    }
15757
15758    /// Sends a packet to the service. This interface doesn't define how the
15759    /// client knows when the sink is done with the associated payload memory.
15760    /// The inheriting interface must define that.
15761    ///
15762    /// `packet` must be valid for the current buffer set, otherwise the service
15763    /// will close the connection.
15764    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15765        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15766            (packet,),
15767            0x8d9b8b413ceba9d,
15768            fidl::encoding::DynamicFlags::empty(),
15769        )
15770    }
15771
15772    /// Indicates the stream has ended. The precise semantics of this method are
15773    /// determined by the inheriting interface.
15774    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15775        self.client.send::<fidl::encoding::EmptyPayload>(
15776            (),
15777            0x6180fd6f7e793b71,
15778            fidl::encoding::DynamicFlags::empty(),
15779        )
15780    }
15781
15782    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15783    /// and not yet released. The response is sent after all packets have been
15784    /// released.
15785    pub fn r#discard_all_packets(
15786        &self,
15787        ___deadline: zx::MonotonicInstant,
15788    ) -> Result<(), fidl::Error> {
15789        let _response =
15790            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
15791                (),
15792                0x6f4dad7af2917665,
15793                fidl::encoding::DynamicFlags::empty(),
15794                ___deadline,
15795            )?;
15796        Ok(_response)
15797    }
15798
15799    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15800    /// and not yet released.
15801    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15802        self.client.send::<fidl::encoding::EmptyPayload>(
15803            (),
15804            0x50d36d0d23081bc4,
15805            fidl::encoding::DynamicFlags::empty(),
15806        )
15807    }
15808}
15809
15810#[cfg(target_os = "fuchsia")]
15811impl From<StreamSinkSynchronousProxy> for zx::NullableHandle {
15812    fn from(value: StreamSinkSynchronousProxy) -> Self {
15813        value.into_channel().into()
15814    }
15815}
15816
15817#[cfg(target_os = "fuchsia")]
15818impl From<fidl::Channel> for StreamSinkSynchronousProxy {
15819    fn from(value: fidl::Channel) -> Self {
15820        Self::new(value)
15821    }
15822}
15823
15824#[cfg(target_os = "fuchsia")]
15825impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
15826    type Protocol = StreamSinkMarker;
15827
15828    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
15829        Self::new(value.into_channel())
15830    }
15831}
15832
15833#[derive(Debug, Clone)]
15834pub struct StreamSinkProxy {
15835    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
15836}
15837
15838impl fidl::endpoints::Proxy for StreamSinkProxy {
15839    type Protocol = StreamSinkMarker;
15840
15841    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
15842        Self::new(inner)
15843    }
15844
15845    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
15846        self.client.into_channel().map_err(|client| Self { client })
15847    }
15848
15849    fn as_channel(&self) -> &::fidl::AsyncChannel {
15850        self.client.as_channel()
15851    }
15852}
15853
15854impl StreamSinkProxy {
15855    /// Create a new Proxy for fuchsia.media/StreamSink.
15856    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
15857        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15858        Self { client: fidl::client::Client::new(channel, protocol_name) }
15859    }
15860
15861    /// Get a Stream of events from the remote end of the protocol.
15862    ///
15863    /// # Panics
15864    ///
15865    /// Panics if the event stream was already taken.
15866    pub fn take_event_stream(&self) -> StreamSinkEventStream {
15867        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
15868    }
15869
15870    /// Sends a packet to the service. The response is sent when the service is
15871    /// done with the associated payload memory.
15872    ///
15873    /// `packet` must be valid for the current buffer set, otherwise the service
15874    /// will close the connection.
15875    pub fn r#send_packet(
15876        &self,
15877        mut packet: &StreamPacket,
15878    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15879        StreamSinkProxyInterface::r#send_packet(self, packet)
15880    }
15881
15882    /// Sends a packet to the service. This interface doesn't define how the
15883    /// client knows when the sink is done with the associated payload memory.
15884    /// The inheriting interface must define that.
15885    ///
15886    /// `packet` must be valid for the current buffer set, otherwise the service
15887    /// will close the connection.
15888    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15889        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
15890    }
15891
15892    /// Indicates the stream has ended. The precise semantics of this method are
15893    /// determined by the inheriting interface.
15894    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15895        StreamSinkProxyInterface::r#end_of_stream(self)
15896    }
15897
15898    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15899    /// and not yet released. The response is sent after all packets have been
15900    /// released.
15901    pub fn r#discard_all_packets(
15902        &self,
15903    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15904        StreamSinkProxyInterface::r#discard_all_packets(self)
15905    }
15906
15907    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15908    /// and not yet released.
15909    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15910        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
15911    }
15912}
15913
15914impl StreamSinkProxyInterface for StreamSinkProxy {
15915    type SendPacketResponseFut =
15916        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15917    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
15918        fn _decode(
15919            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15920        ) -> Result<(), fidl::Error> {
15921            let _response = fidl::client::decode_transaction_body::<
15922                fidl::encoding::EmptyPayload,
15923                fidl::encoding::DefaultFuchsiaResourceDialect,
15924                0x67cddd607442775f,
15925            >(_buf?)?;
15926            Ok(_response)
15927        }
15928        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
15929            (packet,),
15930            0x67cddd607442775f,
15931            fidl::encoding::DynamicFlags::empty(),
15932            _decode,
15933        )
15934    }
15935
15936    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15937        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15938            (packet,),
15939            0x8d9b8b413ceba9d,
15940            fidl::encoding::DynamicFlags::empty(),
15941        )
15942    }
15943
15944    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15945        self.client.send::<fidl::encoding::EmptyPayload>(
15946            (),
15947            0x6180fd6f7e793b71,
15948            fidl::encoding::DynamicFlags::empty(),
15949        )
15950    }
15951
15952    type DiscardAllPacketsResponseFut =
15953        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15954    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
15955        fn _decode(
15956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15957        ) -> Result<(), fidl::Error> {
15958            let _response = fidl::client::decode_transaction_body::<
15959                fidl::encoding::EmptyPayload,
15960                fidl::encoding::DefaultFuchsiaResourceDialect,
15961                0x6f4dad7af2917665,
15962            >(_buf?)?;
15963            Ok(_response)
15964        }
15965        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
15966            (),
15967            0x6f4dad7af2917665,
15968            fidl::encoding::DynamicFlags::empty(),
15969            _decode,
15970        )
15971    }
15972
15973    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15974        self.client.send::<fidl::encoding::EmptyPayload>(
15975            (),
15976            0x50d36d0d23081bc4,
15977            fidl::encoding::DynamicFlags::empty(),
15978        )
15979    }
15980}
15981
15982pub struct StreamSinkEventStream {
15983    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
15984}
15985
15986impl std::marker::Unpin for StreamSinkEventStream {}
15987
15988impl futures::stream::FusedStream for StreamSinkEventStream {
15989    fn is_terminated(&self) -> bool {
15990        self.event_receiver.is_terminated()
15991    }
15992}
15993
15994impl futures::Stream for StreamSinkEventStream {
15995    type Item = Result<StreamSinkEvent, fidl::Error>;
15996
15997    fn poll_next(
15998        mut self: std::pin::Pin<&mut Self>,
15999        cx: &mut std::task::Context<'_>,
16000    ) -> std::task::Poll<Option<Self::Item>> {
16001        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16002            &mut self.event_receiver,
16003            cx
16004        )?) {
16005            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
16006            None => std::task::Poll::Ready(None),
16007        }
16008    }
16009}
16010
16011#[derive(Debug)]
16012pub enum StreamSinkEvent {}
16013
16014impl StreamSinkEvent {
16015    /// Decodes a message buffer as a [`StreamSinkEvent`].
16016    fn decode(
16017        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16018    ) -> Result<StreamSinkEvent, fidl::Error> {
16019        let (bytes, _handles) = buf.split_mut();
16020        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16021        debug_assert_eq!(tx_header.tx_id, 0);
16022        match tx_header.ordinal {
16023            _ => Err(fidl::Error::UnknownOrdinal {
16024                ordinal: tx_header.ordinal,
16025                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16026            }),
16027        }
16028    }
16029}
16030
16031/// A Stream of incoming requests for fuchsia.media/StreamSink.
16032pub struct StreamSinkRequestStream {
16033    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16034    is_terminated: bool,
16035}
16036
16037impl std::marker::Unpin for StreamSinkRequestStream {}
16038
16039impl futures::stream::FusedStream for StreamSinkRequestStream {
16040    fn is_terminated(&self) -> bool {
16041        self.is_terminated
16042    }
16043}
16044
16045impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
16046    type Protocol = StreamSinkMarker;
16047    type ControlHandle = StreamSinkControlHandle;
16048
16049    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16050        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16051    }
16052
16053    fn control_handle(&self) -> Self::ControlHandle {
16054        StreamSinkControlHandle { inner: self.inner.clone() }
16055    }
16056
16057    fn into_inner(
16058        self,
16059    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16060    {
16061        (self.inner, self.is_terminated)
16062    }
16063
16064    fn from_inner(
16065        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16066        is_terminated: bool,
16067    ) -> Self {
16068        Self { inner, is_terminated }
16069    }
16070}
16071
16072impl futures::Stream for StreamSinkRequestStream {
16073    type Item = Result<StreamSinkRequest, fidl::Error>;
16074
16075    fn poll_next(
16076        mut self: std::pin::Pin<&mut Self>,
16077        cx: &mut std::task::Context<'_>,
16078    ) -> std::task::Poll<Option<Self::Item>> {
16079        let this = &mut *self;
16080        if this.inner.check_shutdown(cx) {
16081            this.is_terminated = true;
16082            return std::task::Poll::Ready(None);
16083        }
16084        if this.is_terminated {
16085            panic!("polled StreamSinkRequestStream after completion");
16086        }
16087        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16088            |bytes, handles| {
16089                match this.inner.channel().read_etc(cx, bytes, handles) {
16090                    std::task::Poll::Ready(Ok(())) => {}
16091                    std::task::Poll::Pending => return std::task::Poll::Pending,
16092                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16093                        this.is_terminated = true;
16094                        return std::task::Poll::Ready(None);
16095                    }
16096                    std::task::Poll::Ready(Err(e)) => {
16097                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16098                            e.into(),
16099                        ))));
16100                    }
16101                }
16102
16103                // A message has been received from the channel
16104                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16105
16106                std::task::Poll::Ready(Some(match header.ordinal {
16107                    0x67cddd607442775f => {
16108                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16109                        let mut req = fidl::new_empty!(
16110                            StreamSinkSendPacketRequest,
16111                            fidl::encoding::DefaultFuchsiaResourceDialect
16112                        );
16113                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16114                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16115                        Ok(StreamSinkRequest::SendPacket {
16116                            packet: req.packet,
16117
16118                            responder: StreamSinkSendPacketResponder {
16119                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16120                                tx_id: header.tx_id,
16121                            },
16122                        })
16123                    }
16124                    0x8d9b8b413ceba9d => {
16125                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16126                        let mut req = fidl::new_empty!(
16127                            StreamSinkSendPacketNoReplyRequest,
16128                            fidl::encoding::DefaultFuchsiaResourceDialect
16129                        );
16130                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
16131                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16132                        Ok(StreamSinkRequest::SendPacketNoReply {
16133                            packet: req.packet,
16134
16135                            control_handle,
16136                        })
16137                    }
16138                    0x6180fd6f7e793b71 => {
16139                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16140                        let mut req = fidl::new_empty!(
16141                            fidl::encoding::EmptyPayload,
16142                            fidl::encoding::DefaultFuchsiaResourceDialect
16143                        );
16144                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16145                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16146                        Ok(StreamSinkRequest::EndOfStream { control_handle })
16147                    }
16148                    0x6f4dad7af2917665 => {
16149                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16150                        let mut req = fidl::new_empty!(
16151                            fidl::encoding::EmptyPayload,
16152                            fidl::encoding::DefaultFuchsiaResourceDialect
16153                        );
16154                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16155                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16156                        Ok(StreamSinkRequest::DiscardAllPackets {
16157                            responder: StreamSinkDiscardAllPacketsResponder {
16158                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16159                                tx_id: header.tx_id,
16160                            },
16161                        })
16162                    }
16163                    0x50d36d0d23081bc4 => {
16164                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16165                        let mut req = fidl::new_empty!(
16166                            fidl::encoding::EmptyPayload,
16167                            fidl::encoding::DefaultFuchsiaResourceDialect
16168                        );
16169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16170                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16171                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
16172                    }
16173                    _ => Err(fidl::Error::UnknownOrdinal {
16174                        ordinal: header.ordinal,
16175                        protocol_name:
16176                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16177                    }),
16178                }))
16179            },
16180        )
16181    }
16182}
16183
16184/// Consumes a stream of packets. This interface is typically inherited along
16185/// with `StreamBufferSet` to enable the transport of elementary streams from
16186/// clients to services.
16187#[derive(Debug)]
16188pub enum StreamSinkRequest {
16189    /// Sends a packet to the service. The response is sent when the service is
16190    /// done with the associated payload memory.
16191    ///
16192    /// `packet` must be valid for the current buffer set, otherwise the service
16193    /// will close the connection.
16194    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
16195    /// Sends a packet to the service. This interface doesn't define how the
16196    /// client knows when the sink is done with the associated payload memory.
16197    /// The inheriting interface must define that.
16198    ///
16199    /// `packet` must be valid for the current buffer set, otherwise the service
16200    /// will close the connection.
16201    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
16202    /// Indicates the stream has ended. The precise semantics of this method are
16203    /// determined by the inheriting interface.
16204    EndOfStream { control_handle: StreamSinkControlHandle },
16205    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16206    /// and not yet released. The response is sent after all packets have been
16207    /// released.
16208    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
16209    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16210    /// and not yet released.
16211    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
16212}
16213
16214impl StreamSinkRequest {
16215    #[allow(irrefutable_let_patterns)]
16216    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
16217        if let StreamSinkRequest::SendPacket { packet, responder } = self {
16218            Some((packet, responder))
16219        } else {
16220            None
16221        }
16222    }
16223
16224    #[allow(irrefutable_let_patterns)]
16225    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
16226        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
16227            Some((packet, control_handle))
16228        } else {
16229            None
16230        }
16231    }
16232
16233    #[allow(irrefutable_let_patterns)]
16234    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
16235        if let StreamSinkRequest::EndOfStream { control_handle } = self {
16236            Some((control_handle))
16237        } else {
16238            None
16239        }
16240    }
16241
16242    #[allow(irrefutable_let_patterns)]
16243    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
16244        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
16245            Some((responder))
16246        } else {
16247            None
16248        }
16249    }
16250
16251    #[allow(irrefutable_let_patterns)]
16252    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
16253        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
16254            Some((control_handle))
16255        } else {
16256            None
16257        }
16258    }
16259
16260    /// Name of the method defined in FIDL
16261    pub fn method_name(&self) -> &'static str {
16262        match *self {
16263            StreamSinkRequest::SendPacket { .. } => "send_packet",
16264            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
16265            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
16266            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
16267            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16268        }
16269    }
16270}
16271
16272#[derive(Debug, Clone)]
16273pub struct StreamSinkControlHandle {
16274    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16275}
16276
16277impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
16278    fn shutdown(&self) {
16279        self.inner.shutdown()
16280    }
16281
16282    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16283        self.inner.shutdown_with_epitaph(status)
16284    }
16285
16286    fn is_closed(&self) -> bool {
16287        self.inner.channel().is_closed()
16288    }
16289    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16290        self.inner.channel().on_closed()
16291    }
16292
16293    #[cfg(target_os = "fuchsia")]
16294    fn signal_peer(
16295        &self,
16296        clear_mask: zx::Signals,
16297        set_mask: zx::Signals,
16298    ) -> Result<(), zx_status::Status> {
16299        use fidl::Peered;
16300        self.inner.channel().signal_peer(clear_mask, set_mask)
16301    }
16302}
16303
16304impl StreamSinkControlHandle {}
16305
16306#[must_use = "FIDL methods require a response to be sent"]
16307#[derive(Debug)]
16308pub struct StreamSinkSendPacketResponder {
16309    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16310    tx_id: u32,
16311}
16312
16313/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16314/// if the responder is dropped without sending a response, so that the client
16315/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16316impl std::ops::Drop for StreamSinkSendPacketResponder {
16317    fn drop(&mut self) {
16318        self.control_handle.shutdown();
16319        // Safety: drops once, never accessed again
16320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16321    }
16322}
16323
16324impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
16325    type ControlHandle = StreamSinkControlHandle;
16326
16327    fn control_handle(&self) -> &StreamSinkControlHandle {
16328        &self.control_handle
16329    }
16330
16331    fn drop_without_shutdown(mut self) {
16332        // Safety: drops once, never accessed again due to mem::forget
16333        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16334        // Prevent Drop from running (which would shut down the channel)
16335        std::mem::forget(self);
16336    }
16337}
16338
16339impl StreamSinkSendPacketResponder {
16340    /// Sends a response to the FIDL transaction.
16341    ///
16342    /// Sets the channel to shutdown if an error occurs.
16343    pub fn send(self) -> Result<(), fidl::Error> {
16344        let _result = self.send_raw();
16345        if _result.is_err() {
16346            self.control_handle.shutdown();
16347        }
16348        self.drop_without_shutdown();
16349        _result
16350    }
16351
16352    /// Similar to "send" but does not shutdown the channel if an error occurs.
16353    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16354        let _result = self.send_raw();
16355        self.drop_without_shutdown();
16356        _result
16357    }
16358
16359    fn send_raw(&self) -> Result<(), fidl::Error> {
16360        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16361            (),
16362            self.tx_id,
16363            0x67cddd607442775f,
16364            fidl::encoding::DynamicFlags::empty(),
16365        )
16366    }
16367}
16368
16369#[must_use = "FIDL methods require a response to be sent"]
16370#[derive(Debug)]
16371pub struct StreamSinkDiscardAllPacketsResponder {
16372    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16373    tx_id: u32,
16374}
16375
16376/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16377/// if the responder is dropped without sending a response, so that the client
16378/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16379impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
16380    fn drop(&mut self) {
16381        self.control_handle.shutdown();
16382        // Safety: drops once, never accessed again
16383        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16384    }
16385}
16386
16387impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
16388    type ControlHandle = StreamSinkControlHandle;
16389
16390    fn control_handle(&self) -> &StreamSinkControlHandle {
16391        &self.control_handle
16392    }
16393
16394    fn drop_without_shutdown(mut self) {
16395        // Safety: drops once, never accessed again due to mem::forget
16396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16397        // Prevent Drop from running (which would shut down the channel)
16398        std::mem::forget(self);
16399    }
16400}
16401
16402impl StreamSinkDiscardAllPacketsResponder {
16403    /// Sends a response to the FIDL transaction.
16404    ///
16405    /// Sets the channel to shutdown if an error occurs.
16406    pub fn send(self) -> Result<(), fidl::Error> {
16407        let _result = self.send_raw();
16408        if _result.is_err() {
16409            self.control_handle.shutdown();
16410        }
16411        self.drop_without_shutdown();
16412        _result
16413    }
16414
16415    /// Similar to "send" but does not shutdown the channel if an error occurs.
16416    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16417        let _result = self.send_raw();
16418        self.drop_without_shutdown();
16419        _result
16420    }
16421
16422    fn send_raw(&self) -> Result<(), fidl::Error> {
16423        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16424            (),
16425            self.tx_id,
16426            0x6f4dad7af2917665,
16427            fidl::encoding::DynamicFlags::empty(),
16428        )
16429    }
16430}
16431
16432#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16433pub struct StreamSourceMarker;
16434
16435impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
16436    type Proxy = StreamSourceProxy;
16437    type RequestStream = StreamSourceRequestStream;
16438    #[cfg(target_os = "fuchsia")]
16439    type SynchronousProxy = StreamSourceSynchronousProxy;
16440
16441    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
16442}
16443
16444pub trait StreamSourceProxyInterface: Send + Sync {
16445    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
16446    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16447    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
16448    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
16449}
16450#[derive(Debug)]
16451#[cfg(target_os = "fuchsia")]
16452pub struct StreamSourceSynchronousProxy {
16453    client: fidl::client::sync::Client,
16454}
16455
16456#[cfg(target_os = "fuchsia")]
16457impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
16458    type Proxy = StreamSourceProxy;
16459    type Protocol = StreamSourceMarker;
16460
16461    fn from_channel(inner: fidl::Channel) -> Self {
16462        Self::new(inner)
16463    }
16464
16465    fn into_channel(self) -> fidl::Channel {
16466        self.client.into_channel()
16467    }
16468
16469    fn as_channel(&self) -> &fidl::Channel {
16470        self.client.as_channel()
16471    }
16472}
16473
16474#[cfg(target_os = "fuchsia")]
16475impl StreamSourceSynchronousProxy {
16476    pub fn new(channel: fidl::Channel) -> Self {
16477        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16478        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
16479    }
16480
16481    pub fn into_channel(self) -> fidl::Channel {
16482        self.client.into_channel()
16483    }
16484
16485    /// Waits until an event arrives and returns it. It is safe for other
16486    /// threads to make concurrent requests while waiting for an event.
16487    pub fn wait_for_event(
16488        &self,
16489        deadline: zx::MonotonicInstant,
16490    ) -> Result<StreamSourceEvent, fidl::Error> {
16491        StreamSourceEvent::decode(self.client.wait_for_event(deadline)?)
16492    }
16493
16494    /// Releases payload memory associated with a packet previously delivered
16495    /// via `OnPacketProduced`.
16496    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16497        self.client.send::<StreamSourceReleasePacketRequest>(
16498            (packet,),
16499            0x7a7b57f0f7d9e4bb,
16500            fidl::encoding::DynamicFlags::empty(),
16501        )
16502    }
16503
16504    pub fn r#discard_all_packets(
16505        &self,
16506        ___deadline: zx::MonotonicInstant,
16507    ) -> Result<(), fidl::Error> {
16508        let _response =
16509            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
16510                (),
16511                0x27afd605e97b09d2,
16512                fidl::encoding::DynamicFlags::empty(),
16513                ___deadline,
16514            )?;
16515        Ok(_response)
16516    }
16517
16518    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16519        self.client.send::<fidl::encoding::EmptyPayload>(
16520            (),
16521            0x35f9d721e905b831,
16522            fidl::encoding::DynamicFlags::empty(),
16523        )
16524    }
16525}
16526
16527#[cfg(target_os = "fuchsia")]
16528impl From<StreamSourceSynchronousProxy> for zx::NullableHandle {
16529    fn from(value: StreamSourceSynchronousProxy) -> Self {
16530        value.into_channel().into()
16531    }
16532}
16533
16534#[cfg(target_os = "fuchsia")]
16535impl From<fidl::Channel> for StreamSourceSynchronousProxy {
16536    fn from(value: fidl::Channel) -> Self {
16537        Self::new(value)
16538    }
16539}
16540
16541#[cfg(target_os = "fuchsia")]
16542impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
16543    type Protocol = StreamSourceMarker;
16544
16545    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
16546        Self::new(value.into_channel())
16547    }
16548}
16549
16550#[derive(Debug, Clone)]
16551pub struct StreamSourceProxy {
16552    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
16553}
16554
16555impl fidl::endpoints::Proxy for StreamSourceProxy {
16556    type Protocol = StreamSourceMarker;
16557
16558    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
16559        Self::new(inner)
16560    }
16561
16562    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
16563        self.client.into_channel().map_err(|client| Self { client })
16564    }
16565
16566    fn as_channel(&self) -> &::fidl::AsyncChannel {
16567        self.client.as_channel()
16568    }
16569}
16570
16571impl StreamSourceProxy {
16572    /// Create a new Proxy for fuchsia.media/StreamSource.
16573    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
16574        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16575        Self { client: fidl::client::Client::new(channel, protocol_name) }
16576    }
16577
16578    /// Get a Stream of events from the remote end of the protocol.
16579    ///
16580    /// # Panics
16581    ///
16582    /// Panics if the event stream was already taken.
16583    pub fn take_event_stream(&self) -> StreamSourceEventStream {
16584        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
16585    }
16586
16587    /// Releases payload memory associated with a packet previously delivered
16588    /// via `OnPacketProduced`.
16589    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16590        StreamSourceProxyInterface::r#release_packet(self, packet)
16591    }
16592
16593    pub fn r#discard_all_packets(
16594        &self,
16595    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16596        StreamSourceProxyInterface::r#discard_all_packets(self)
16597    }
16598
16599    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16600        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
16601    }
16602}
16603
16604impl StreamSourceProxyInterface for StreamSourceProxy {
16605    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16606        self.client.send::<StreamSourceReleasePacketRequest>(
16607            (packet,),
16608            0x7a7b57f0f7d9e4bb,
16609            fidl::encoding::DynamicFlags::empty(),
16610        )
16611    }
16612
16613    type DiscardAllPacketsResponseFut =
16614        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16615    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16616        fn _decode(
16617            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16618        ) -> Result<(), fidl::Error> {
16619            let _response = fidl::client::decode_transaction_body::<
16620                fidl::encoding::EmptyPayload,
16621                fidl::encoding::DefaultFuchsiaResourceDialect,
16622                0x27afd605e97b09d2,
16623            >(_buf?)?;
16624            Ok(_response)
16625        }
16626        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16627            (),
16628            0x27afd605e97b09d2,
16629            fidl::encoding::DynamicFlags::empty(),
16630            _decode,
16631        )
16632    }
16633
16634    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16635        self.client.send::<fidl::encoding::EmptyPayload>(
16636            (),
16637            0x35f9d721e905b831,
16638            fidl::encoding::DynamicFlags::empty(),
16639        )
16640    }
16641}
16642
16643pub struct StreamSourceEventStream {
16644    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16645}
16646
16647impl std::marker::Unpin for StreamSourceEventStream {}
16648
16649impl futures::stream::FusedStream for StreamSourceEventStream {
16650    fn is_terminated(&self) -> bool {
16651        self.event_receiver.is_terminated()
16652    }
16653}
16654
16655impl futures::Stream for StreamSourceEventStream {
16656    type Item = Result<StreamSourceEvent, fidl::Error>;
16657
16658    fn poll_next(
16659        mut self: std::pin::Pin<&mut Self>,
16660        cx: &mut std::task::Context<'_>,
16661    ) -> std::task::Poll<Option<Self::Item>> {
16662        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16663            &mut self.event_receiver,
16664            cx
16665        )?) {
16666            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
16667            None => std::task::Poll::Ready(None),
16668        }
16669    }
16670}
16671
16672#[derive(Debug)]
16673pub enum StreamSourceEvent {
16674    OnPacketProduced { packet: StreamPacket },
16675    OnEndOfStream {},
16676}
16677
16678impl StreamSourceEvent {
16679    #[allow(irrefutable_let_patterns)]
16680    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
16681        if let StreamSourceEvent::OnPacketProduced { packet } = self {
16682            Some((packet))
16683        } else {
16684            None
16685        }
16686    }
16687    #[allow(irrefutable_let_patterns)]
16688    pub fn into_on_end_of_stream(self) -> Option<()> {
16689        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
16690    }
16691
16692    /// Decodes a message buffer as a [`StreamSourceEvent`].
16693    fn decode(
16694        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16695    ) -> Result<StreamSourceEvent, fidl::Error> {
16696        let (bytes, _handles) = buf.split_mut();
16697        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16698        debug_assert_eq!(tx_header.tx_id, 0);
16699        match tx_header.ordinal {
16700            0x6bbe69746a3c8bd9 => {
16701                let mut out = fidl::new_empty!(
16702                    StreamSourceOnPacketProducedRequest,
16703                    fidl::encoding::DefaultFuchsiaResourceDialect
16704                );
16705                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16706                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
16707            }
16708            0x550e69b41d03e2c2 => {
16709                let mut out = fidl::new_empty!(
16710                    fidl::encoding::EmptyPayload,
16711                    fidl::encoding::DefaultFuchsiaResourceDialect
16712                );
16713                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
16714                Ok((StreamSourceEvent::OnEndOfStream {}))
16715            }
16716            _ => Err(fidl::Error::UnknownOrdinal {
16717                ordinal: tx_header.ordinal,
16718                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16719            }),
16720        }
16721    }
16722}
16723
16724/// A Stream of incoming requests for fuchsia.media/StreamSource.
16725pub struct StreamSourceRequestStream {
16726    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16727    is_terminated: bool,
16728}
16729
16730impl std::marker::Unpin for StreamSourceRequestStream {}
16731
16732impl futures::stream::FusedStream for StreamSourceRequestStream {
16733    fn is_terminated(&self) -> bool {
16734        self.is_terminated
16735    }
16736}
16737
16738impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
16739    type Protocol = StreamSourceMarker;
16740    type ControlHandle = StreamSourceControlHandle;
16741
16742    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16743        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16744    }
16745
16746    fn control_handle(&self) -> Self::ControlHandle {
16747        StreamSourceControlHandle { inner: self.inner.clone() }
16748    }
16749
16750    fn into_inner(
16751        self,
16752    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16753    {
16754        (self.inner, self.is_terminated)
16755    }
16756
16757    fn from_inner(
16758        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16759        is_terminated: bool,
16760    ) -> Self {
16761        Self { inner, is_terminated }
16762    }
16763}
16764
16765impl futures::Stream for StreamSourceRequestStream {
16766    type Item = Result<StreamSourceRequest, fidl::Error>;
16767
16768    fn poll_next(
16769        mut self: std::pin::Pin<&mut Self>,
16770        cx: &mut std::task::Context<'_>,
16771    ) -> std::task::Poll<Option<Self::Item>> {
16772        let this = &mut *self;
16773        if this.inner.check_shutdown(cx) {
16774            this.is_terminated = true;
16775            return std::task::Poll::Ready(None);
16776        }
16777        if this.is_terminated {
16778            panic!("polled StreamSourceRequestStream after completion");
16779        }
16780        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16781            |bytes, handles| {
16782                match this.inner.channel().read_etc(cx, bytes, handles) {
16783                    std::task::Poll::Ready(Ok(())) => {}
16784                    std::task::Poll::Pending => return std::task::Poll::Pending,
16785                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16786                        this.is_terminated = true;
16787                        return std::task::Poll::Ready(None);
16788                    }
16789                    std::task::Poll::Ready(Err(e)) => {
16790                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16791                            e.into(),
16792                        ))));
16793                    }
16794                }
16795
16796                // A message has been received from the channel
16797                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16798
16799                std::task::Poll::Ready(Some(match header.ordinal {
16800                    0x7a7b57f0f7d9e4bb => {
16801                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16802                        let mut req = fidl::new_empty!(
16803                            StreamSourceReleasePacketRequest,
16804                            fidl::encoding::DefaultFuchsiaResourceDialect
16805                        );
16806                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
16807                        let control_handle =
16808                            StreamSourceControlHandle { inner: this.inner.clone() };
16809                        Ok(StreamSourceRequest::ReleasePacket {
16810                            packet: req.packet,
16811
16812                            control_handle,
16813                        })
16814                    }
16815                    0x27afd605e97b09d2 => {
16816                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16817                        let mut req = fidl::new_empty!(
16818                            fidl::encoding::EmptyPayload,
16819                            fidl::encoding::DefaultFuchsiaResourceDialect
16820                        );
16821                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16822                        let control_handle =
16823                            StreamSourceControlHandle { inner: this.inner.clone() };
16824                        Ok(StreamSourceRequest::DiscardAllPackets {
16825                            responder: StreamSourceDiscardAllPacketsResponder {
16826                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16827                                tx_id: header.tx_id,
16828                            },
16829                        })
16830                    }
16831                    0x35f9d721e905b831 => {
16832                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16833                        let mut req = fidl::new_empty!(
16834                            fidl::encoding::EmptyPayload,
16835                            fidl::encoding::DefaultFuchsiaResourceDialect
16836                        );
16837                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16838                        let control_handle =
16839                            StreamSourceControlHandle { inner: this.inner.clone() };
16840                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
16841                    }
16842                    _ => Err(fidl::Error::UnknownOrdinal {
16843                        ordinal: header.ordinal,
16844                        protocol_name:
16845                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16846                    }),
16847                }))
16848            },
16849        )
16850    }
16851}
16852
16853/// Produces a stream of packets. This interface is typically inherited along
16854/// with `StreamBufferSet` to enable the transport of elementary streams from
16855/// services to clients.
16856#[derive(Debug)]
16857pub enum StreamSourceRequest {
16858    /// Releases payload memory associated with a packet previously delivered
16859    /// via `OnPacketProduced`.
16860    ReleasePacket {
16861        packet: StreamPacket,
16862        control_handle: StreamSourceControlHandle,
16863    },
16864    DiscardAllPackets {
16865        responder: StreamSourceDiscardAllPacketsResponder,
16866    },
16867    DiscardAllPacketsNoReply {
16868        control_handle: StreamSourceControlHandle,
16869    },
16870}
16871
16872impl StreamSourceRequest {
16873    #[allow(irrefutable_let_patterns)]
16874    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
16875        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
16876            Some((packet, control_handle))
16877        } else {
16878            None
16879        }
16880    }
16881
16882    #[allow(irrefutable_let_patterns)]
16883    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
16884        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
16885            Some((responder))
16886        } else {
16887            None
16888        }
16889    }
16890
16891    #[allow(irrefutable_let_patterns)]
16892    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
16893        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
16894            Some((control_handle))
16895        } else {
16896            None
16897        }
16898    }
16899
16900    /// Name of the method defined in FIDL
16901    pub fn method_name(&self) -> &'static str {
16902        match *self {
16903            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
16904            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
16905            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16906        }
16907    }
16908}
16909
16910#[derive(Debug, Clone)]
16911pub struct StreamSourceControlHandle {
16912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16913}
16914
16915impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
16916    fn shutdown(&self) {
16917        self.inner.shutdown()
16918    }
16919
16920    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16921        self.inner.shutdown_with_epitaph(status)
16922    }
16923
16924    fn is_closed(&self) -> bool {
16925        self.inner.channel().is_closed()
16926    }
16927    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16928        self.inner.channel().on_closed()
16929    }
16930
16931    #[cfg(target_os = "fuchsia")]
16932    fn signal_peer(
16933        &self,
16934        clear_mask: zx::Signals,
16935        set_mask: zx::Signals,
16936    ) -> Result<(), zx_status::Status> {
16937        use fidl::Peered;
16938        self.inner.channel().signal_peer(clear_mask, set_mask)
16939    }
16940}
16941
16942impl StreamSourceControlHandle {
16943    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16944        self.inner.send::<StreamSourceOnPacketProducedRequest>(
16945            (packet,),
16946            0,
16947            0x6bbe69746a3c8bd9,
16948            fidl::encoding::DynamicFlags::empty(),
16949        )
16950    }
16951
16952    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
16953        self.inner.send::<fidl::encoding::EmptyPayload>(
16954            (),
16955            0,
16956            0x550e69b41d03e2c2,
16957            fidl::encoding::DynamicFlags::empty(),
16958        )
16959    }
16960}
16961
16962#[must_use = "FIDL methods require a response to be sent"]
16963#[derive(Debug)]
16964pub struct StreamSourceDiscardAllPacketsResponder {
16965    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
16966    tx_id: u32,
16967}
16968
16969/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
16970/// if the responder is dropped without sending a response, so that the client
16971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16972impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
16973    fn drop(&mut self) {
16974        self.control_handle.shutdown();
16975        // Safety: drops once, never accessed again
16976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16977    }
16978}
16979
16980impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
16981    type ControlHandle = StreamSourceControlHandle;
16982
16983    fn control_handle(&self) -> &StreamSourceControlHandle {
16984        &self.control_handle
16985    }
16986
16987    fn drop_without_shutdown(mut self) {
16988        // Safety: drops once, never accessed again due to mem::forget
16989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16990        // Prevent Drop from running (which would shut down the channel)
16991        std::mem::forget(self);
16992    }
16993}
16994
16995impl StreamSourceDiscardAllPacketsResponder {
16996    /// Sends a response to the FIDL transaction.
16997    ///
16998    /// Sets the channel to shutdown if an error occurs.
16999    pub fn send(self) -> Result<(), fidl::Error> {
17000        let _result = self.send_raw();
17001        if _result.is_err() {
17002            self.control_handle.shutdown();
17003        }
17004        self.drop_without_shutdown();
17005        _result
17006    }
17007
17008    /// Similar to "send" but does not shutdown the channel if an error occurs.
17009    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17010        let _result = self.send_raw();
17011        self.drop_without_shutdown();
17012        _result
17013    }
17014
17015    fn send_raw(&self) -> Result<(), fidl::Error> {
17016        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17017            (),
17018            self.tx_id,
17019            0x27afd605e97b09d2,
17020            fidl::encoding::DynamicFlags::empty(),
17021        )
17022    }
17023}
17024
17025#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17026pub struct Usage2AudioConsumerFactoryMarker;
17027
17028impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
17029    type Proxy = Usage2AudioConsumerFactoryProxy;
17030    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
17031    #[cfg(target_os = "fuchsia")]
17032    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
17033
17034    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
17035}
17036impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
17037
17038pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
17039    fn r#create_audio_consumer(
17040        &self,
17041        usage: AudioRenderUsage2,
17042        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17043    ) -> Result<(), fidl::Error>;
17044}
17045#[derive(Debug)]
17046#[cfg(target_os = "fuchsia")]
17047pub struct Usage2AudioConsumerFactorySynchronousProxy {
17048    client: fidl::client::sync::Client,
17049}
17050
17051#[cfg(target_os = "fuchsia")]
17052impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
17053    type Proxy = Usage2AudioConsumerFactoryProxy;
17054    type Protocol = Usage2AudioConsumerFactoryMarker;
17055
17056    fn from_channel(inner: fidl::Channel) -> Self {
17057        Self::new(inner)
17058    }
17059
17060    fn into_channel(self) -> fidl::Channel {
17061        self.client.into_channel()
17062    }
17063
17064    fn as_channel(&self) -> &fidl::Channel {
17065        self.client.as_channel()
17066    }
17067}
17068
17069#[cfg(target_os = "fuchsia")]
17070impl Usage2AudioConsumerFactorySynchronousProxy {
17071    pub fn new(channel: fidl::Channel) -> Self {
17072        let protocol_name =
17073            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17074        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17075    }
17076
17077    pub fn into_channel(self) -> fidl::Channel {
17078        self.client.into_channel()
17079    }
17080
17081    /// Waits until an event arrives and returns it. It is safe for other
17082    /// threads to make concurrent requests while waiting for an event.
17083    pub fn wait_for_event(
17084        &self,
17085        deadline: zx::MonotonicInstant,
17086    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17087        Usage2AudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17088    }
17089
17090    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17091    /// Audio submitted to such a consumer is always rendered locally.
17092    pub fn r#create_audio_consumer(
17093        &self,
17094        mut usage: AudioRenderUsage2,
17095        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17096    ) -> Result<(), fidl::Error> {
17097        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17098            (usage, audio_consumer_request),
17099            0x767722302a171873,
17100            fidl::encoding::DynamicFlags::FLEXIBLE,
17101        )
17102    }
17103}
17104
17105#[cfg(target_os = "fuchsia")]
17106impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17107    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
17108        value.into_channel().into()
17109    }
17110}
17111
17112#[cfg(target_os = "fuchsia")]
17113impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
17114    fn from(value: fidl::Channel) -> Self {
17115        Self::new(value)
17116    }
17117}
17118
17119#[cfg(target_os = "fuchsia")]
17120impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
17121    type Protocol = Usage2AudioConsumerFactoryMarker;
17122
17123    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
17124        Self::new(value.into_channel())
17125    }
17126}
17127
17128#[derive(Debug, Clone)]
17129pub struct Usage2AudioConsumerFactoryProxy {
17130    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17131}
17132
17133impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
17134    type Protocol = Usage2AudioConsumerFactoryMarker;
17135
17136    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17137        Self::new(inner)
17138    }
17139
17140    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17141        self.client.into_channel().map_err(|client| Self { client })
17142    }
17143
17144    fn as_channel(&self) -> &::fidl::AsyncChannel {
17145        self.client.as_channel()
17146    }
17147}
17148
17149impl Usage2AudioConsumerFactoryProxy {
17150    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
17151    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17152        let protocol_name =
17153            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17154        Self { client: fidl::client::Client::new(channel, protocol_name) }
17155    }
17156
17157    /// Get a Stream of events from the remote end of the protocol.
17158    ///
17159    /// # Panics
17160    ///
17161    /// Panics if the event stream was already taken.
17162    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
17163        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17164    }
17165
17166    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17167    /// Audio submitted to such a consumer is always rendered locally.
17168    pub 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        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17174            self,
17175            usage,
17176            audio_consumer_request,
17177        )
17178    }
17179}
17180
17181impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
17182    fn r#create_audio_consumer(
17183        &self,
17184        mut usage: AudioRenderUsage2,
17185        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17186    ) -> Result<(), fidl::Error> {
17187        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17188            (usage, audio_consumer_request),
17189            0x767722302a171873,
17190            fidl::encoding::DynamicFlags::FLEXIBLE,
17191        )
17192    }
17193}
17194
17195pub struct Usage2AudioConsumerFactoryEventStream {
17196    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17197}
17198
17199impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
17200
17201impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
17202    fn is_terminated(&self) -> bool {
17203        self.event_receiver.is_terminated()
17204    }
17205}
17206
17207impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
17208    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
17209
17210    fn poll_next(
17211        mut self: std::pin::Pin<&mut Self>,
17212        cx: &mut std::task::Context<'_>,
17213    ) -> std::task::Poll<Option<Self::Item>> {
17214        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17215            &mut self.event_receiver,
17216            cx
17217        )?) {
17218            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
17219            None => std::task::Poll::Ready(None),
17220        }
17221    }
17222}
17223
17224#[derive(Debug)]
17225pub enum Usage2AudioConsumerFactoryEvent {
17226    #[non_exhaustive]
17227    _UnknownEvent {
17228        /// Ordinal of the event that was sent.
17229        ordinal: u64,
17230    },
17231}
17232
17233impl Usage2AudioConsumerFactoryEvent {
17234    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
17235    fn decode(
17236        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17237    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17238        let (bytes, _handles) = buf.split_mut();
17239        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17240        debug_assert_eq!(tx_header.tx_id, 0);
17241        match tx_header.ordinal {
17242            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17243                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
17244                    ordinal: tx_header.ordinal,
17245                })
17246            }
17247            _ => Err(fidl::Error::UnknownOrdinal {
17248                ordinal: tx_header.ordinal,
17249                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17250            })
17251        }
17252    }
17253}
17254
17255/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
17256pub struct Usage2AudioConsumerFactoryRequestStream {
17257    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17258    is_terminated: bool,
17259}
17260
17261impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
17262
17263impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
17264    fn is_terminated(&self) -> bool {
17265        self.is_terminated
17266    }
17267}
17268
17269impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
17270    type Protocol = Usage2AudioConsumerFactoryMarker;
17271    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
17272
17273    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17274        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17275    }
17276
17277    fn control_handle(&self) -> Self::ControlHandle {
17278        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17279    }
17280
17281    fn into_inner(
17282        self,
17283    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17284    {
17285        (self.inner, self.is_terminated)
17286    }
17287
17288    fn from_inner(
17289        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17290        is_terminated: bool,
17291    ) -> Self {
17292        Self { inner, is_terminated }
17293    }
17294}
17295
17296impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
17297    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
17298
17299    fn poll_next(
17300        mut self: std::pin::Pin<&mut Self>,
17301        cx: &mut std::task::Context<'_>,
17302    ) -> std::task::Poll<Option<Self::Item>> {
17303        let this = &mut *self;
17304        if this.inner.check_shutdown(cx) {
17305            this.is_terminated = true;
17306            return std::task::Poll::Ready(None);
17307        }
17308        if this.is_terminated {
17309            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
17310        }
17311        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17312            |bytes, handles| {
17313                match this.inner.channel().read_etc(cx, bytes, handles) {
17314                    std::task::Poll::Ready(Ok(())) => {}
17315                    std::task::Poll::Pending => return std::task::Poll::Pending,
17316                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17317                        this.is_terminated = true;
17318                        return std::task::Poll::Ready(None);
17319                    }
17320                    std::task::Poll::Ready(Err(e)) => {
17321                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17322                            e.into(),
17323                        ))));
17324                    }
17325                }
17326
17327                // A message has been received from the channel
17328                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17329
17330                std::task::Poll::Ready(Some(match header.ordinal {
17331                0x767722302a171873 => {
17332                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17333                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17334                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17335                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
17336                        inner: this.inner.clone(),
17337                    };
17338                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17339audio_consumer_request: req.audio_consumer_request,
17340
17341                        control_handle,
17342                    })
17343                }
17344                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17345                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17346                        ordinal: header.ordinal,
17347                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17348                        method_type: fidl::MethodType::OneWay,
17349                    })
17350                }
17351                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17352                    this.inner.send_framework_err(
17353                        fidl::encoding::FrameworkErr::UnknownMethod,
17354                        header.tx_id,
17355                        header.ordinal,
17356                        header.dynamic_flags(),
17357                        (bytes, handles),
17358                    )?;
17359                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17360                        ordinal: header.ordinal,
17361                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17362                        method_type: fidl::MethodType::TwoWay,
17363                    })
17364                }
17365                _ => Err(fidl::Error::UnknownOrdinal {
17366                    ordinal: header.ordinal,
17367                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17368                }),
17369            }))
17370            },
17371        )
17372    }
17373}
17374
17375/// Interface for creating audio consumers for local rendering.
17376#[derive(Debug)]
17377pub enum Usage2AudioConsumerFactoryRequest {
17378    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17379    /// Audio submitted to such a consumer is always rendered locally.
17380    CreateAudioConsumer {
17381        usage: AudioRenderUsage2,
17382        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17383        control_handle: Usage2AudioConsumerFactoryControlHandle,
17384    },
17385    /// An interaction was received which does not match any known method.
17386    #[non_exhaustive]
17387    _UnknownMethod {
17388        /// Ordinal of the method that was called.
17389        ordinal: u64,
17390        control_handle: Usage2AudioConsumerFactoryControlHandle,
17391        method_type: fidl::MethodType,
17392    },
17393}
17394
17395impl Usage2AudioConsumerFactoryRequest {
17396    #[allow(irrefutable_let_patterns)]
17397    pub fn into_create_audio_consumer(
17398        self,
17399    ) -> Option<(
17400        AudioRenderUsage2,
17401        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17402        Usage2AudioConsumerFactoryControlHandle,
17403    )> {
17404        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
17405            usage,
17406            audio_consumer_request,
17407            control_handle,
17408        } = self
17409        {
17410            Some((usage, audio_consumer_request, control_handle))
17411        } else {
17412            None
17413        }
17414    }
17415
17416    /// Name of the method defined in FIDL
17417    pub fn method_name(&self) -> &'static str {
17418        match *self {
17419            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
17420                "create_audio_consumer"
17421            }
17422            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17423                method_type: fidl::MethodType::OneWay,
17424                ..
17425            } => "unknown one-way method",
17426            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17427                method_type: fidl::MethodType::TwoWay,
17428                ..
17429            } => "unknown two-way method",
17430        }
17431    }
17432}
17433
17434#[derive(Debug, Clone)]
17435pub struct Usage2AudioConsumerFactoryControlHandle {
17436    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17437}
17438
17439impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
17440    fn shutdown(&self) {
17441        self.inner.shutdown()
17442    }
17443
17444    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17445        self.inner.shutdown_with_epitaph(status)
17446    }
17447
17448    fn is_closed(&self) -> bool {
17449        self.inner.channel().is_closed()
17450    }
17451    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17452        self.inner.channel().on_closed()
17453    }
17454
17455    #[cfg(target_os = "fuchsia")]
17456    fn signal_peer(
17457        &self,
17458        clear_mask: zx::Signals,
17459        set_mask: zx::Signals,
17460    ) -> Result<(), zx_status::Status> {
17461        use fidl::Peered;
17462        self.inner.channel().signal_peer(clear_mask, set_mask)
17463    }
17464}
17465
17466impl Usage2AudioConsumerFactoryControlHandle {}
17467
17468#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17469pub struct UsageAudioConsumerFactoryMarker;
17470
17471impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
17472    type Proxy = UsageAudioConsumerFactoryProxy;
17473    type RequestStream = UsageAudioConsumerFactoryRequestStream;
17474    #[cfg(target_os = "fuchsia")]
17475    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
17476
17477    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
17478}
17479impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
17480
17481pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
17482    fn r#create_audio_consumer(
17483        &self,
17484        usage: AudioRenderUsage,
17485        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17486    ) -> Result<(), fidl::Error>;
17487}
17488#[derive(Debug)]
17489#[cfg(target_os = "fuchsia")]
17490pub struct UsageAudioConsumerFactorySynchronousProxy {
17491    client: fidl::client::sync::Client,
17492}
17493
17494#[cfg(target_os = "fuchsia")]
17495impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
17496    type Proxy = UsageAudioConsumerFactoryProxy;
17497    type Protocol = UsageAudioConsumerFactoryMarker;
17498
17499    fn from_channel(inner: fidl::Channel) -> Self {
17500        Self::new(inner)
17501    }
17502
17503    fn into_channel(self) -> fidl::Channel {
17504        self.client.into_channel()
17505    }
17506
17507    fn as_channel(&self) -> &fidl::Channel {
17508        self.client.as_channel()
17509    }
17510}
17511
17512#[cfg(target_os = "fuchsia")]
17513impl UsageAudioConsumerFactorySynchronousProxy {
17514    pub fn new(channel: fidl::Channel) -> Self {
17515        let protocol_name =
17516            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17517        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17518    }
17519
17520    pub fn into_channel(self) -> fidl::Channel {
17521        self.client.into_channel()
17522    }
17523
17524    /// Waits until an event arrives and returns it. It is safe for other
17525    /// threads to make concurrent requests while waiting for an event.
17526    pub fn wait_for_event(
17527        &self,
17528        deadline: zx::MonotonicInstant,
17529    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17530        UsageAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17531    }
17532
17533    pub fn r#create_audio_consumer(
17534        &self,
17535        mut usage: AudioRenderUsage,
17536        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17537    ) -> Result<(), fidl::Error> {
17538        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17539            (usage, audio_consumer_request),
17540            0x4d975ca9b8f625a3,
17541            fidl::encoding::DynamicFlags::empty(),
17542        )
17543    }
17544}
17545
17546#[cfg(target_os = "fuchsia")]
17547impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17548    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
17549        value.into_channel().into()
17550    }
17551}
17552
17553#[cfg(target_os = "fuchsia")]
17554impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
17555    fn from(value: fidl::Channel) -> Self {
17556        Self::new(value)
17557    }
17558}
17559
17560#[cfg(target_os = "fuchsia")]
17561impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
17562    type Protocol = UsageAudioConsumerFactoryMarker;
17563
17564    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
17565        Self::new(value.into_channel())
17566    }
17567}
17568
17569#[derive(Debug, Clone)]
17570pub struct UsageAudioConsumerFactoryProxy {
17571    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17572}
17573
17574impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
17575    type Protocol = UsageAudioConsumerFactoryMarker;
17576
17577    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17578        Self::new(inner)
17579    }
17580
17581    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17582        self.client.into_channel().map_err(|client| Self { client })
17583    }
17584
17585    fn as_channel(&self) -> &::fidl::AsyncChannel {
17586        self.client.as_channel()
17587    }
17588}
17589
17590impl UsageAudioConsumerFactoryProxy {
17591    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
17592    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17593        let protocol_name =
17594            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17595        Self { client: fidl::client::Client::new(channel, protocol_name) }
17596    }
17597
17598    /// Get a Stream of events from the remote end of the protocol.
17599    ///
17600    /// # Panics
17601    ///
17602    /// Panics if the event stream was already taken.
17603    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
17604        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17605    }
17606
17607    pub fn r#create_audio_consumer(
17608        &self,
17609        mut usage: AudioRenderUsage,
17610        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17611    ) -> Result<(), fidl::Error> {
17612        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17613            self,
17614            usage,
17615            audio_consumer_request,
17616        )
17617    }
17618}
17619
17620impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
17621    fn r#create_audio_consumer(
17622        &self,
17623        mut usage: AudioRenderUsage,
17624        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17625    ) -> Result<(), fidl::Error> {
17626        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17627            (usage, audio_consumer_request),
17628            0x4d975ca9b8f625a3,
17629            fidl::encoding::DynamicFlags::empty(),
17630        )
17631    }
17632}
17633
17634pub struct UsageAudioConsumerFactoryEventStream {
17635    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17636}
17637
17638impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
17639
17640impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
17641    fn is_terminated(&self) -> bool {
17642        self.event_receiver.is_terminated()
17643    }
17644}
17645
17646impl futures::Stream for UsageAudioConsumerFactoryEventStream {
17647    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
17648
17649    fn poll_next(
17650        mut self: std::pin::Pin<&mut Self>,
17651        cx: &mut std::task::Context<'_>,
17652    ) -> std::task::Poll<Option<Self::Item>> {
17653        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17654            &mut self.event_receiver,
17655            cx
17656        )?) {
17657            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
17658            None => std::task::Poll::Ready(None),
17659        }
17660    }
17661}
17662
17663#[derive(Debug)]
17664pub enum UsageAudioConsumerFactoryEvent {}
17665
17666impl UsageAudioConsumerFactoryEvent {
17667    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
17668    fn decode(
17669        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17670    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17671        let (bytes, _handles) = buf.split_mut();
17672        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17673        debug_assert_eq!(tx_header.tx_id, 0);
17674        match tx_header.ordinal {
17675            _ => Err(fidl::Error::UnknownOrdinal {
17676                ordinal: tx_header.ordinal,
17677                protocol_name:
17678                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17679            }),
17680        }
17681    }
17682}
17683
17684/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
17685pub struct UsageAudioConsumerFactoryRequestStream {
17686    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17687    is_terminated: bool,
17688}
17689
17690impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
17691
17692impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
17693    fn is_terminated(&self) -> bool {
17694        self.is_terminated
17695    }
17696}
17697
17698impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
17699    type Protocol = UsageAudioConsumerFactoryMarker;
17700    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
17701
17702    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17703        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17704    }
17705
17706    fn control_handle(&self) -> Self::ControlHandle {
17707        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17708    }
17709
17710    fn into_inner(
17711        self,
17712    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17713    {
17714        (self.inner, self.is_terminated)
17715    }
17716
17717    fn from_inner(
17718        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17719        is_terminated: bool,
17720    ) -> Self {
17721        Self { inner, is_terminated }
17722    }
17723}
17724
17725impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
17726    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
17727
17728    fn poll_next(
17729        mut self: std::pin::Pin<&mut Self>,
17730        cx: &mut std::task::Context<'_>,
17731    ) -> std::task::Poll<Option<Self::Item>> {
17732        let this = &mut *self;
17733        if this.inner.check_shutdown(cx) {
17734            this.is_terminated = true;
17735            return std::task::Poll::Ready(None);
17736        }
17737        if this.is_terminated {
17738            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
17739        }
17740        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17741            |bytes, handles| {
17742                match this.inner.channel().read_etc(cx, bytes, handles) {
17743                    std::task::Poll::Ready(Ok(())) => {}
17744                    std::task::Poll::Pending => return std::task::Poll::Pending,
17745                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17746                        this.is_terminated = true;
17747                        return std::task::Poll::Ready(None);
17748                    }
17749                    std::task::Poll::Ready(Err(e)) => {
17750                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17751                            e.into(),
17752                        ))));
17753                    }
17754                }
17755
17756                // A message has been received from the channel
17757                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17758
17759                std::task::Poll::Ready(Some(match header.ordinal {
17760                0x4d975ca9b8f625a3 => {
17761                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17762                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17763                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17764                    let control_handle = UsageAudioConsumerFactoryControlHandle {
17765                        inner: this.inner.clone(),
17766                    };
17767                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17768audio_consumer_request: req.audio_consumer_request,
17769
17770                        control_handle,
17771                    })
17772                }
17773                _ => Err(fidl::Error::UnknownOrdinal {
17774                    ordinal: header.ordinal,
17775                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17776                }),
17777            }))
17778            },
17779        )
17780    }
17781}
17782
17783/// Interface for creating audio consumers for local rendering.
17784#[derive(Debug)]
17785pub enum UsageAudioConsumerFactoryRequest {
17786    CreateAudioConsumer {
17787        usage: AudioRenderUsage,
17788        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17789        control_handle: UsageAudioConsumerFactoryControlHandle,
17790    },
17791}
17792
17793impl UsageAudioConsumerFactoryRequest {
17794    #[allow(irrefutable_let_patterns)]
17795    pub fn into_create_audio_consumer(
17796        self,
17797    ) -> Option<(
17798        AudioRenderUsage,
17799        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17800        UsageAudioConsumerFactoryControlHandle,
17801    )> {
17802        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
17803            usage,
17804            audio_consumer_request,
17805            control_handle,
17806        } = self
17807        {
17808            Some((usage, audio_consumer_request, control_handle))
17809        } else {
17810            None
17811        }
17812    }
17813
17814    /// Name of the method defined in FIDL
17815    pub fn method_name(&self) -> &'static str {
17816        match *self {
17817            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
17818        }
17819    }
17820}
17821
17822#[derive(Debug, Clone)]
17823pub struct UsageAudioConsumerFactoryControlHandle {
17824    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17825}
17826
17827impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
17828    fn shutdown(&self) {
17829        self.inner.shutdown()
17830    }
17831
17832    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17833        self.inner.shutdown_with_epitaph(status)
17834    }
17835
17836    fn is_closed(&self) -> bool {
17837        self.inner.channel().is_closed()
17838    }
17839    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17840        self.inner.channel().on_closed()
17841    }
17842
17843    #[cfg(target_os = "fuchsia")]
17844    fn signal_peer(
17845        &self,
17846        clear_mask: zx::Signals,
17847        set_mask: zx::Signals,
17848    ) -> Result<(), zx_status::Status> {
17849        use fidl::Peered;
17850        self.inner.channel().signal_peer(clear_mask, set_mask)
17851    }
17852}
17853
17854impl UsageAudioConsumerFactoryControlHandle {}
17855
17856#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17857pub struct UsageGainListenerMarker;
17858
17859impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
17860    type Proxy = UsageGainListenerProxy;
17861    type RequestStream = UsageGainListenerRequestStream;
17862    #[cfg(target_os = "fuchsia")]
17863    type SynchronousProxy = UsageGainListenerSynchronousProxy;
17864
17865    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
17866}
17867
17868pub trait UsageGainListenerProxyInterface: Send + Sync {
17869    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17870    fn r#on_gain_mute_changed(
17871        &self,
17872        muted: bool,
17873        gain_dbfs: f32,
17874    ) -> Self::OnGainMuteChangedResponseFut;
17875}
17876#[derive(Debug)]
17877#[cfg(target_os = "fuchsia")]
17878pub struct UsageGainListenerSynchronousProxy {
17879    client: fidl::client::sync::Client,
17880}
17881
17882#[cfg(target_os = "fuchsia")]
17883impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
17884    type Proxy = UsageGainListenerProxy;
17885    type Protocol = UsageGainListenerMarker;
17886
17887    fn from_channel(inner: fidl::Channel) -> Self {
17888        Self::new(inner)
17889    }
17890
17891    fn into_channel(self) -> fidl::Channel {
17892        self.client.into_channel()
17893    }
17894
17895    fn as_channel(&self) -> &fidl::Channel {
17896        self.client.as_channel()
17897    }
17898}
17899
17900#[cfg(target_os = "fuchsia")]
17901impl UsageGainListenerSynchronousProxy {
17902    pub fn new(channel: fidl::Channel) -> Self {
17903        let protocol_name =
17904            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17905        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17906    }
17907
17908    pub fn into_channel(self) -> fidl::Channel {
17909        self.client.into_channel()
17910    }
17911
17912    /// Waits until an event arrives and returns it. It is safe for other
17913    /// threads to make concurrent requests while waiting for an event.
17914    pub fn wait_for_event(
17915        &self,
17916        deadline: zx::MonotonicInstant,
17917    ) -> Result<UsageGainListenerEvent, fidl::Error> {
17918        UsageGainListenerEvent::decode(self.client.wait_for_event(deadline)?)
17919    }
17920
17921    /// Called immediately on connection and afterward any time
17922    /// the usage gain setting changes.
17923    ///
17924    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17925    /// events will eventually be disconnected.
17926    ///
17927    /// Note: This API does not have mute reporting implemented; `muted` is always false.
17928    pub fn r#on_gain_mute_changed(
17929        &self,
17930        mut muted: bool,
17931        mut gain_dbfs: f32,
17932        ___deadline: zx::MonotonicInstant,
17933    ) -> Result<(), fidl::Error> {
17934        let _response = self
17935            .client
17936            .send_query::<UsageGainListenerOnGainMuteChangedRequest, fidl::encoding::EmptyPayload>(
17937                (muted, gain_dbfs),
17938                0x681570258eac3a8d,
17939                fidl::encoding::DynamicFlags::empty(),
17940                ___deadline,
17941            )?;
17942        Ok(_response)
17943    }
17944}
17945
17946#[cfg(target_os = "fuchsia")]
17947impl From<UsageGainListenerSynchronousProxy> for zx::NullableHandle {
17948    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
17949        value.into_channel().into()
17950    }
17951}
17952
17953#[cfg(target_os = "fuchsia")]
17954impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
17955    fn from(value: fidl::Channel) -> Self {
17956        Self::new(value)
17957    }
17958}
17959
17960#[cfg(target_os = "fuchsia")]
17961impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
17962    type Protocol = UsageGainListenerMarker;
17963
17964    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
17965        Self::new(value.into_channel())
17966    }
17967}
17968
17969#[derive(Debug, Clone)]
17970pub struct UsageGainListenerProxy {
17971    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17972}
17973
17974impl fidl::endpoints::Proxy for UsageGainListenerProxy {
17975    type Protocol = UsageGainListenerMarker;
17976
17977    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17978        Self::new(inner)
17979    }
17980
17981    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17982        self.client.into_channel().map_err(|client| Self { client })
17983    }
17984
17985    fn as_channel(&self) -> &::fidl::AsyncChannel {
17986        self.client.as_channel()
17987    }
17988}
17989
17990impl UsageGainListenerProxy {
17991    /// Create a new Proxy for fuchsia.media/UsageGainListener.
17992    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17993        let protocol_name =
17994            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17995        Self { client: fidl::client::Client::new(channel, protocol_name) }
17996    }
17997
17998    /// Get a Stream of events from the remote end of the protocol.
17999    ///
18000    /// # Panics
18001    ///
18002    /// Panics if the event stream was already taken.
18003    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
18004        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
18005    }
18006
18007    /// Called immediately on connection and afterward any time
18008    /// the usage gain setting changes.
18009    ///
18010    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18011    /// events will eventually be disconnected.
18012    ///
18013    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18014    pub fn r#on_gain_mute_changed(
18015        &self,
18016        mut muted: bool,
18017        mut gain_dbfs: f32,
18018    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18019        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
18020    }
18021}
18022
18023impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
18024    type OnGainMuteChangedResponseFut =
18025        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18026    fn r#on_gain_mute_changed(
18027        &self,
18028        mut muted: bool,
18029        mut gain_dbfs: f32,
18030    ) -> Self::OnGainMuteChangedResponseFut {
18031        fn _decode(
18032            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18033        ) -> Result<(), fidl::Error> {
18034            let _response = fidl::client::decode_transaction_body::<
18035                fidl::encoding::EmptyPayload,
18036                fidl::encoding::DefaultFuchsiaResourceDialect,
18037                0x681570258eac3a8d,
18038            >(_buf?)?;
18039            Ok(_response)
18040        }
18041        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
18042            (muted, gain_dbfs),
18043            0x681570258eac3a8d,
18044            fidl::encoding::DynamicFlags::empty(),
18045            _decode,
18046        )
18047    }
18048}
18049
18050pub struct UsageGainListenerEventStream {
18051    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18052}
18053
18054impl std::marker::Unpin for UsageGainListenerEventStream {}
18055
18056impl futures::stream::FusedStream for UsageGainListenerEventStream {
18057    fn is_terminated(&self) -> bool {
18058        self.event_receiver.is_terminated()
18059    }
18060}
18061
18062impl futures::Stream for UsageGainListenerEventStream {
18063    type Item = Result<UsageGainListenerEvent, fidl::Error>;
18064
18065    fn poll_next(
18066        mut self: std::pin::Pin<&mut Self>,
18067        cx: &mut std::task::Context<'_>,
18068    ) -> std::task::Poll<Option<Self::Item>> {
18069        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18070            &mut self.event_receiver,
18071            cx
18072        )?) {
18073            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
18074            None => std::task::Poll::Ready(None),
18075        }
18076    }
18077}
18078
18079#[derive(Debug)]
18080pub enum UsageGainListenerEvent {}
18081
18082impl UsageGainListenerEvent {
18083    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
18084    fn decode(
18085        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18086    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18087        let (bytes, _handles) = buf.split_mut();
18088        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18089        debug_assert_eq!(tx_header.tx_id, 0);
18090        match tx_header.ordinal {
18091            _ => Err(fidl::Error::UnknownOrdinal {
18092                ordinal: tx_header.ordinal,
18093                protocol_name:
18094                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18095            }),
18096        }
18097    }
18098}
18099
18100/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
18101pub struct UsageGainListenerRequestStream {
18102    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18103    is_terminated: bool,
18104}
18105
18106impl std::marker::Unpin for UsageGainListenerRequestStream {}
18107
18108impl futures::stream::FusedStream for UsageGainListenerRequestStream {
18109    fn is_terminated(&self) -> bool {
18110        self.is_terminated
18111    }
18112}
18113
18114impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
18115    type Protocol = UsageGainListenerMarker;
18116    type ControlHandle = UsageGainListenerControlHandle;
18117
18118    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18119        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18120    }
18121
18122    fn control_handle(&self) -> Self::ControlHandle {
18123        UsageGainListenerControlHandle { inner: self.inner.clone() }
18124    }
18125
18126    fn into_inner(
18127        self,
18128    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18129    {
18130        (self.inner, self.is_terminated)
18131    }
18132
18133    fn from_inner(
18134        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18135        is_terminated: bool,
18136    ) -> Self {
18137        Self { inner, is_terminated }
18138    }
18139}
18140
18141impl futures::Stream for UsageGainListenerRequestStream {
18142    type Item = Result<UsageGainListenerRequest, fidl::Error>;
18143
18144    fn poll_next(
18145        mut self: std::pin::Pin<&mut Self>,
18146        cx: &mut std::task::Context<'_>,
18147    ) -> std::task::Poll<Option<Self::Item>> {
18148        let this = &mut *self;
18149        if this.inner.check_shutdown(cx) {
18150            this.is_terminated = true;
18151            return std::task::Poll::Ready(None);
18152        }
18153        if this.is_terminated {
18154            panic!("polled UsageGainListenerRequestStream after completion");
18155        }
18156        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18157            |bytes, handles| {
18158                match this.inner.channel().read_etc(cx, bytes, handles) {
18159                    std::task::Poll::Ready(Ok(())) => {}
18160                    std::task::Poll::Pending => return std::task::Poll::Pending,
18161                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18162                        this.is_terminated = true;
18163                        return std::task::Poll::Ready(None);
18164                    }
18165                    std::task::Poll::Ready(Err(e)) => {
18166                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18167                            e.into(),
18168                        ))));
18169                    }
18170                }
18171
18172                // A message has been received from the channel
18173                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18174
18175                std::task::Poll::Ready(Some(match header.ordinal {
18176                    0x681570258eac3a8d => {
18177                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18178                        let mut req = fidl::new_empty!(
18179                            UsageGainListenerOnGainMuteChangedRequest,
18180                            fidl::encoding::DefaultFuchsiaResourceDialect
18181                        );
18182                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
18183                        let control_handle =
18184                            UsageGainListenerControlHandle { inner: this.inner.clone() };
18185                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
18186                            muted: req.muted,
18187                            gain_dbfs: req.gain_dbfs,
18188
18189                            responder: UsageGainListenerOnGainMuteChangedResponder {
18190                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18191                                tx_id: header.tx_id,
18192                            },
18193                        })
18194                    }
18195                    _ => Err(fidl::Error::UnknownOrdinal {
18196                        ordinal: header.ordinal,
18197                        protocol_name:
18198                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18199                    }),
18200                }))
18201            },
18202        )
18203    }
18204}
18205
18206/// A protocol for watching changes to usage gain settings.
18207///
18208/// The channel will close when the device is not present.
18209#[derive(Debug)]
18210pub enum UsageGainListenerRequest {
18211    /// Called immediately on connection and afterward any time
18212    /// the usage gain setting changes.
18213    ///
18214    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18215    /// events will eventually be disconnected.
18216    ///
18217    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18218    OnGainMuteChanged {
18219        muted: bool,
18220        gain_dbfs: f32,
18221        responder: UsageGainListenerOnGainMuteChangedResponder,
18222    },
18223}
18224
18225impl UsageGainListenerRequest {
18226    #[allow(irrefutable_let_patterns)]
18227    pub fn into_on_gain_mute_changed(
18228        self,
18229    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
18230        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
18231            Some((muted, gain_dbfs, responder))
18232        } else {
18233            None
18234        }
18235    }
18236
18237    /// Name of the method defined in FIDL
18238    pub fn method_name(&self) -> &'static str {
18239        match *self {
18240            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
18241        }
18242    }
18243}
18244
18245#[derive(Debug, Clone)]
18246pub struct UsageGainListenerControlHandle {
18247    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18248}
18249
18250impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
18251    fn shutdown(&self) {
18252        self.inner.shutdown()
18253    }
18254
18255    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18256        self.inner.shutdown_with_epitaph(status)
18257    }
18258
18259    fn is_closed(&self) -> bool {
18260        self.inner.channel().is_closed()
18261    }
18262    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18263        self.inner.channel().on_closed()
18264    }
18265
18266    #[cfg(target_os = "fuchsia")]
18267    fn signal_peer(
18268        &self,
18269        clear_mask: zx::Signals,
18270        set_mask: zx::Signals,
18271    ) -> Result<(), zx_status::Status> {
18272        use fidl::Peered;
18273        self.inner.channel().signal_peer(clear_mask, set_mask)
18274    }
18275}
18276
18277impl UsageGainListenerControlHandle {}
18278
18279#[must_use = "FIDL methods require a response to be sent"]
18280#[derive(Debug)]
18281pub struct UsageGainListenerOnGainMuteChangedResponder {
18282    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
18283    tx_id: u32,
18284}
18285
18286/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
18287/// if the responder is dropped without sending a response, so that the client
18288/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18289impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
18290    fn drop(&mut self) {
18291        self.control_handle.shutdown();
18292        // Safety: drops once, never accessed again
18293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18294    }
18295}
18296
18297impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
18298    type ControlHandle = UsageGainListenerControlHandle;
18299
18300    fn control_handle(&self) -> &UsageGainListenerControlHandle {
18301        &self.control_handle
18302    }
18303
18304    fn drop_without_shutdown(mut self) {
18305        // Safety: drops once, never accessed again due to mem::forget
18306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18307        // Prevent Drop from running (which would shut down the channel)
18308        std::mem::forget(self);
18309    }
18310}
18311
18312impl UsageGainListenerOnGainMuteChangedResponder {
18313    /// Sends a response to the FIDL transaction.
18314    ///
18315    /// Sets the channel to shutdown if an error occurs.
18316    pub fn send(self) -> Result<(), fidl::Error> {
18317        let _result = self.send_raw();
18318        if _result.is_err() {
18319            self.control_handle.shutdown();
18320        }
18321        self.drop_without_shutdown();
18322        _result
18323    }
18324
18325    /// Similar to "send" but does not shutdown the channel if an error occurs.
18326    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18327        let _result = self.send_raw();
18328        self.drop_without_shutdown();
18329        _result
18330    }
18331
18332    fn send_raw(&self) -> Result<(), fidl::Error> {
18333        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18334            (),
18335            self.tx_id,
18336            0x681570258eac3a8d,
18337            fidl::encoding::DynamicFlags::empty(),
18338        )
18339    }
18340}
18341
18342#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18343pub struct UsageGainReporterMarker;
18344
18345impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
18346    type Proxy = UsageGainReporterProxy;
18347    type RequestStream = UsageGainReporterRequestStream;
18348    #[cfg(target_os = "fuchsia")]
18349    type SynchronousProxy = UsageGainReporterSynchronousProxy;
18350
18351    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
18352}
18353impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
18354
18355pub trait UsageGainReporterProxyInterface: Send + Sync {
18356    fn r#register_listener(
18357        &self,
18358        device_unique_id: &str,
18359        usage: &Usage,
18360        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18361    ) -> Result<(), fidl::Error>;
18362    fn r#register_listener2(
18363        &self,
18364        device_unique_id: &str,
18365        usage: &Usage2,
18366        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18367    ) -> Result<(), fidl::Error>;
18368}
18369#[derive(Debug)]
18370#[cfg(target_os = "fuchsia")]
18371pub struct UsageGainReporterSynchronousProxy {
18372    client: fidl::client::sync::Client,
18373}
18374
18375#[cfg(target_os = "fuchsia")]
18376impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
18377    type Proxy = UsageGainReporterProxy;
18378    type Protocol = UsageGainReporterMarker;
18379
18380    fn from_channel(inner: fidl::Channel) -> Self {
18381        Self::new(inner)
18382    }
18383
18384    fn into_channel(self) -> fidl::Channel {
18385        self.client.into_channel()
18386    }
18387
18388    fn as_channel(&self) -> &fidl::Channel {
18389        self.client.as_channel()
18390    }
18391}
18392
18393#[cfg(target_os = "fuchsia")]
18394impl UsageGainReporterSynchronousProxy {
18395    pub fn new(channel: fidl::Channel) -> Self {
18396        let protocol_name =
18397            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18398        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
18399    }
18400
18401    pub fn into_channel(self) -> fidl::Channel {
18402        self.client.into_channel()
18403    }
18404
18405    /// Waits until an event arrives and returns it. It is safe for other
18406    /// threads to make concurrent requests while waiting for an event.
18407    pub fn wait_for_event(
18408        &self,
18409        deadline: zx::MonotonicInstant,
18410    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18411        UsageGainReporterEvent::decode(self.client.wait_for_event(deadline)?)
18412    }
18413
18414    /// Connects a listener to a stream of usage gain setting changes
18415    /// for `usage` on the device identified by `device_token`. Usage
18416    /// Gain is not set directly by any client; it is a translation of
18417    /// the usage volume setting for each device, summed with active
18418    /// muting/ducking gain adjustments.
18419    ///
18420    /// Devices may map the same volume level to different dbfs, so
18421    /// a `device_unique_id` is needed to identify the device.
18422    ///
18423    /// `AudioDeviceEnumerator` provides programmatic access to devices
18424    /// and their unique ids if it is necessary for a client to select
18425    /// an id at runtime.
18426    pub fn r#register_listener(
18427        &self,
18428        mut device_unique_id: &str,
18429        mut usage: &Usage,
18430        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18431    ) -> Result<(), fidl::Error> {
18432        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18433            (device_unique_id, usage, usage_gain_listener),
18434            0x767107c168c226af,
18435            fidl::encoding::DynamicFlags::empty(),
18436        )
18437    }
18438
18439    /// Connects a listener to a stream of usage gain setting changes
18440    /// for `usage` on the device identified by `device_token`. Usage
18441    /// Gain is not set directly by any client; it is a translation of
18442    /// the usage volume setting for each device, summed with active
18443    /// muting/ducking gain adjustments.
18444    ///
18445    /// Devices may map the same volume level to different dbfs, so
18446    /// a `device_unique_id` is needed to identify the device.
18447    ///
18448    /// `AudioDeviceEnumerator` provides programmatic access to devices
18449    /// and their unique ids if it is necessary for a client to select
18450    /// an id at runtime.
18451    pub fn r#register_listener2(
18452        &self,
18453        mut device_unique_id: &str,
18454        mut usage: &Usage2,
18455        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18456    ) -> Result<(), fidl::Error> {
18457        self.client.send::<UsageGainReporterRegisterListener2Request>(
18458            (device_unique_id, usage, usage_gain_listener),
18459            0x760a8e1c5873629c,
18460            fidl::encoding::DynamicFlags::FLEXIBLE,
18461        )
18462    }
18463}
18464
18465#[cfg(target_os = "fuchsia")]
18466impl From<UsageGainReporterSynchronousProxy> for zx::NullableHandle {
18467    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
18468        value.into_channel().into()
18469    }
18470}
18471
18472#[cfg(target_os = "fuchsia")]
18473impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
18474    fn from(value: fidl::Channel) -> Self {
18475        Self::new(value)
18476    }
18477}
18478
18479#[cfg(target_os = "fuchsia")]
18480impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
18481    type Protocol = UsageGainReporterMarker;
18482
18483    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
18484        Self::new(value.into_channel())
18485    }
18486}
18487
18488#[derive(Debug, Clone)]
18489pub struct UsageGainReporterProxy {
18490    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18491}
18492
18493impl fidl::endpoints::Proxy for UsageGainReporterProxy {
18494    type Protocol = UsageGainReporterMarker;
18495
18496    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18497        Self::new(inner)
18498    }
18499
18500    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18501        self.client.into_channel().map_err(|client| Self { client })
18502    }
18503
18504    fn as_channel(&self) -> &::fidl::AsyncChannel {
18505        self.client.as_channel()
18506    }
18507}
18508
18509impl UsageGainReporterProxy {
18510    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
18511    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18512        let protocol_name =
18513            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18514        Self { client: fidl::client::Client::new(channel, protocol_name) }
18515    }
18516
18517    /// Get a Stream of events from the remote end of the protocol.
18518    ///
18519    /// # Panics
18520    ///
18521    /// Panics if the event stream was already taken.
18522    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
18523        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
18524    }
18525
18526    /// Connects a listener to a stream of usage gain setting changes
18527    /// for `usage` on the device identified by `device_token`. Usage
18528    /// Gain is not set directly by any client; it is a translation of
18529    /// the usage volume setting for each device, summed with active
18530    /// muting/ducking gain adjustments.
18531    ///
18532    /// Devices may map the same volume level to different dbfs, so
18533    /// a `device_unique_id` is needed to identify the device.
18534    ///
18535    /// `AudioDeviceEnumerator` provides programmatic access to devices
18536    /// and their unique ids if it is necessary for a client to select
18537    /// an id at runtime.
18538    pub fn r#register_listener(
18539        &self,
18540        mut device_unique_id: &str,
18541        mut usage: &Usage,
18542        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18543    ) -> Result<(), fidl::Error> {
18544        UsageGainReporterProxyInterface::r#register_listener(
18545            self,
18546            device_unique_id,
18547            usage,
18548            usage_gain_listener,
18549        )
18550    }
18551
18552    /// Connects a listener to a stream of usage gain setting changes
18553    /// for `usage` on the device identified by `device_token`. Usage
18554    /// Gain is not set directly by any client; it is a translation of
18555    /// the usage volume setting for each device, summed with active
18556    /// muting/ducking gain adjustments.
18557    ///
18558    /// Devices may map the same volume level to different dbfs, so
18559    /// a `device_unique_id` is needed to identify the device.
18560    ///
18561    /// `AudioDeviceEnumerator` provides programmatic access to devices
18562    /// and their unique ids if it is necessary for a client to select
18563    /// an id at runtime.
18564    pub fn r#register_listener2(
18565        &self,
18566        mut device_unique_id: &str,
18567        mut usage: &Usage2,
18568        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18569    ) -> Result<(), fidl::Error> {
18570        UsageGainReporterProxyInterface::r#register_listener2(
18571            self,
18572            device_unique_id,
18573            usage,
18574            usage_gain_listener,
18575        )
18576    }
18577}
18578
18579impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
18580    fn r#register_listener(
18581        &self,
18582        mut device_unique_id: &str,
18583        mut usage: &Usage,
18584        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18585    ) -> Result<(), fidl::Error> {
18586        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18587            (device_unique_id, usage, usage_gain_listener),
18588            0x767107c168c226af,
18589            fidl::encoding::DynamicFlags::empty(),
18590        )
18591    }
18592
18593    fn r#register_listener2(
18594        &self,
18595        mut device_unique_id: &str,
18596        mut usage: &Usage2,
18597        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18598    ) -> Result<(), fidl::Error> {
18599        self.client.send::<UsageGainReporterRegisterListener2Request>(
18600            (device_unique_id, usage, usage_gain_listener),
18601            0x760a8e1c5873629c,
18602            fidl::encoding::DynamicFlags::FLEXIBLE,
18603        )
18604    }
18605}
18606
18607pub struct UsageGainReporterEventStream {
18608    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18609}
18610
18611impl std::marker::Unpin for UsageGainReporterEventStream {}
18612
18613impl futures::stream::FusedStream for UsageGainReporterEventStream {
18614    fn is_terminated(&self) -> bool {
18615        self.event_receiver.is_terminated()
18616    }
18617}
18618
18619impl futures::Stream for UsageGainReporterEventStream {
18620    type Item = Result<UsageGainReporterEvent, fidl::Error>;
18621
18622    fn poll_next(
18623        mut self: std::pin::Pin<&mut Self>,
18624        cx: &mut std::task::Context<'_>,
18625    ) -> std::task::Poll<Option<Self::Item>> {
18626        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18627            &mut self.event_receiver,
18628            cx
18629        )?) {
18630            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
18631            None => std::task::Poll::Ready(None),
18632        }
18633    }
18634}
18635
18636#[derive(Debug)]
18637pub enum UsageGainReporterEvent {
18638    #[non_exhaustive]
18639    _UnknownEvent {
18640        /// Ordinal of the event that was sent.
18641        ordinal: u64,
18642    },
18643}
18644
18645impl UsageGainReporterEvent {
18646    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
18647    fn decode(
18648        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18649    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18650        let (bytes, _handles) = buf.split_mut();
18651        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18652        debug_assert_eq!(tx_header.tx_id, 0);
18653        match tx_header.ordinal {
18654            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
18655                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
18656            }
18657            _ => Err(fidl::Error::UnknownOrdinal {
18658                ordinal: tx_header.ordinal,
18659                protocol_name:
18660                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18661            }),
18662        }
18663    }
18664}
18665
18666/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
18667pub struct UsageGainReporterRequestStream {
18668    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18669    is_terminated: bool,
18670}
18671
18672impl std::marker::Unpin for UsageGainReporterRequestStream {}
18673
18674impl futures::stream::FusedStream for UsageGainReporterRequestStream {
18675    fn is_terminated(&self) -> bool {
18676        self.is_terminated
18677    }
18678}
18679
18680impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
18681    type Protocol = UsageGainReporterMarker;
18682    type ControlHandle = UsageGainReporterControlHandle;
18683
18684    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18685        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18686    }
18687
18688    fn control_handle(&self) -> Self::ControlHandle {
18689        UsageGainReporterControlHandle { inner: self.inner.clone() }
18690    }
18691
18692    fn into_inner(
18693        self,
18694    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18695    {
18696        (self.inner, self.is_terminated)
18697    }
18698
18699    fn from_inner(
18700        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18701        is_terminated: bool,
18702    ) -> Self {
18703        Self { inner, is_terminated }
18704    }
18705}
18706
18707impl futures::Stream for UsageGainReporterRequestStream {
18708    type Item = Result<UsageGainReporterRequest, fidl::Error>;
18709
18710    fn poll_next(
18711        mut self: std::pin::Pin<&mut Self>,
18712        cx: &mut std::task::Context<'_>,
18713    ) -> std::task::Poll<Option<Self::Item>> {
18714        let this = &mut *self;
18715        if this.inner.check_shutdown(cx) {
18716            this.is_terminated = true;
18717            return std::task::Poll::Ready(None);
18718        }
18719        if this.is_terminated {
18720            panic!("polled UsageGainReporterRequestStream after completion");
18721        }
18722        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18723            |bytes, handles| {
18724                match this.inner.channel().read_etc(cx, bytes, handles) {
18725                    std::task::Poll::Ready(Ok(())) => {}
18726                    std::task::Poll::Pending => return std::task::Poll::Pending,
18727                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18728                        this.is_terminated = true;
18729                        return std::task::Poll::Ready(None);
18730                    }
18731                    std::task::Poll::Ready(Err(e)) => {
18732                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18733                            e.into(),
18734                        ))));
18735                    }
18736                }
18737
18738                // A message has been received from the channel
18739                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18740
18741                std::task::Poll::Ready(Some(match header.ordinal {
18742                    0x767107c168c226af => {
18743                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18744                        let mut req = fidl::new_empty!(
18745                            UsageGainReporterRegisterListenerRequest,
18746                            fidl::encoding::DefaultFuchsiaResourceDialect
18747                        );
18748                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
18749                        let control_handle =
18750                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18751                        Ok(UsageGainReporterRequest::RegisterListener {
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                    0x760a8e1c5873629c => {
18760                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18761                        let mut req = fidl::new_empty!(
18762                            UsageGainReporterRegisterListener2Request,
18763                            fidl::encoding::DefaultFuchsiaResourceDialect
18764                        );
18765                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
18766                        let control_handle =
18767                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18768                        Ok(UsageGainReporterRequest::RegisterListener2 {
18769                            device_unique_id: req.device_unique_id,
18770                            usage: req.usage,
18771                            usage_gain_listener: req.usage_gain_listener,
18772
18773                            control_handle,
18774                        })
18775                    }
18776                    _ if header.tx_id == 0
18777                        && header
18778                            .dynamic_flags()
18779                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18780                    {
18781                        Ok(UsageGainReporterRequest::_UnknownMethod {
18782                            ordinal: header.ordinal,
18783                            control_handle: UsageGainReporterControlHandle {
18784                                inner: this.inner.clone(),
18785                            },
18786                            method_type: fidl::MethodType::OneWay,
18787                        })
18788                    }
18789                    _ if header
18790                        .dynamic_flags()
18791                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18792                    {
18793                        this.inner.send_framework_err(
18794                            fidl::encoding::FrameworkErr::UnknownMethod,
18795                            header.tx_id,
18796                            header.ordinal,
18797                            header.dynamic_flags(),
18798                            (bytes, handles),
18799                        )?;
18800                        Ok(UsageGainReporterRequest::_UnknownMethod {
18801                            ordinal: header.ordinal,
18802                            control_handle: UsageGainReporterControlHandle {
18803                                inner: this.inner.clone(),
18804                            },
18805                            method_type: fidl::MethodType::TwoWay,
18806                        })
18807                    }
18808                    _ => Err(fidl::Error::UnknownOrdinal {
18809                        ordinal: header.ordinal,
18810                        protocol_name:
18811                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18812                    }),
18813                }))
18814            },
18815        )
18816    }
18817}
18818
18819/// A protocol for setting up watchers of usage gain.
18820#[derive(Debug)]
18821pub enum UsageGainReporterRequest {
18822    /// Connects a listener to a stream of usage gain setting changes
18823    /// for `usage` on the device identified by `device_token`. Usage
18824    /// Gain is not set directly by any client; it is a translation of
18825    /// the usage volume setting for each device, summed with active
18826    /// muting/ducking gain adjustments.
18827    ///
18828    /// Devices may map the same volume level to different dbfs, so
18829    /// a `device_unique_id` is needed to identify the device.
18830    ///
18831    /// `AudioDeviceEnumerator` provides programmatic access to devices
18832    /// and their unique ids if it is necessary for a client to select
18833    /// an id at runtime.
18834    RegisterListener {
18835        device_unique_id: String,
18836        usage: Usage,
18837        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18838        control_handle: UsageGainReporterControlHandle,
18839    },
18840    /// Connects a listener to a stream of usage gain setting changes
18841    /// for `usage` on the device identified by `device_token`. Usage
18842    /// Gain is not set directly by any client; it is a translation of
18843    /// the usage volume setting for each device, summed with active
18844    /// muting/ducking gain adjustments.
18845    ///
18846    /// Devices may map the same volume level to different dbfs, so
18847    /// a `device_unique_id` is needed to identify the device.
18848    ///
18849    /// `AudioDeviceEnumerator` provides programmatic access to devices
18850    /// and their unique ids if it is necessary for a client to select
18851    /// an id at runtime.
18852    RegisterListener2 {
18853        device_unique_id: String,
18854        usage: Usage2,
18855        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18856        control_handle: UsageGainReporterControlHandle,
18857    },
18858    /// An interaction was received which does not match any known method.
18859    #[non_exhaustive]
18860    _UnknownMethod {
18861        /// Ordinal of the method that was called.
18862        ordinal: u64,
18863        control_handle: UsageGainReporterControlHandle,
18864        method_type: fidl::MethodType,
18865    },
18866}
18867
18868impl UsageGainReporterRequest {
18869    #[allow(irrefutable_let_patterns)]
18870    pub fn into_register_listener(
18871        self,
18872    ) -> Option<(
18873        String,
18874        Usage,
18875        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18876        UsageGainReporterControlHandle,
18877    )> {
18878        if let UsageGainReporterRequest::RegisterListener {
18879            device_unique_id,
18880            usage,
18881            usage_gain_listener,
18882            control_handle,
18883        } = self
18884        {
18885            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18886        } else {
18887            None
18888        }
18889    }
18890
18891    #[allow(irrefutable_let_patterns)]
18892    pub fn into_register_listener2(
18893        self,
18894    ) -> Option<(
18895        String,
18896        Usage2,
18897        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18898        UsageGainReporterControlHandle,
18899    )> {
18900        if let UsageGainReporterRequest::RegisterListener2 {
18901            device_unique_id,
18902            usage,
18903            usage_gain_listener,
18904            control_handle,
18905        } = self
18906        {
18907            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18908        } else {
18909            None
18910        }
18911    }
18912
18913    /// Name of the method defined in FIDL
18914    pub fn method_name(&self) -> &'static str {
18915        match *self {
18916            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
18917            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
18918            UsageGainReporterRequest::_UnknownMethod {
18919                method_type: fidl::MethodType::OneWay,
18920                ..
18921            } => "unknown one-way method",
18922            UsageGainReporterRequest::_UnknownMethod {
18923                method_type: fidl::MethodType::TwoWay,
18924                ..
18925            } => "unknown two-way method",
18926        }
18927    }
18928}
18929
18930#[derive(Debug, Clone)]
18931pub struct UsageGainReporterControlHandle {
18932    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18933}
18934
18935impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
18936    fn shutdown(&self) {
18937        self.inner.shutdown()
18938    }
18939
18940    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18941        self.inner.shutdown_with_epitaph(status)
18942    }
18943
18944    fn is_closed(&self) -> bool {
18945        self.inner.channel().is_closed()
18946    }
18947    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18948        self.inner.channel().on_closed()
18949    }
18950
18951    #[cfg(target_os = "fuchsia")]
18952    fn signal_peer(
18953        &self,
18954        clear_mask: zx::Signals,
18955        set_mask: zx::Signals,
18956    ) -> Result<(), zx_status::Status> {
18957        use fidl::Peered;
18958        self.inner.channel().signal_peer(clear_mask, set_mask)
18959    }
18960}
18961
18962impl UsageGainReporterControlHandle {}
18963
18964#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18965pub struct UsageReporterMarker;
18966
18967impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
18968    type Proxy = UsageReporterProxy;
18969    type RequestStream = UsageReporterRequestStream;
18970    #[cfg(target_os = "fuchsia")]
18971    type SynchronousProxy = UsageReporterSynchronousProxy;
18972
18973    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
18974}
18975impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
18976
18977pub trait UsageReporterProxyInterface: Send + Sync {
18978    fn r#watch(
18979        &self,
18980        usage: &Usage,
18981        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
18982    ) -> Result<(), fidl::Error>;
18983    fn r#watch2(
18984        &self,
18985        usage: &Usage2,
18986        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
18987    ) -> Result<(), fidl::Error>;
18988}
18989#[derive(Debug)]
18990#[cfg(target_os = "fuchsia")]
18991pub struct UsageReporterSynchronousProxy {
18992    client: fidl::client::sync::Client,
18993}
18994
18995#[cfg(target_os = "fuchsia")]
18996impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
18997    type Proxy = UsageReporterProxy;
18998    type Protocol = UsageReporterMarker;
18999
19000    fn from_channel(inner: fidl::Channel) -> Self {
19001        Self::new(inner)
19002    }
19003
19004    fn into_channel(self) -> fidl::Channel {
19005        self.client.into_channel()
19006    }
19007
19008    fn as_channel(&self) -> &fidl::Channel {
19009        self.client.as_channel()
19010    }
19011}
19012
19013#[cfg(target_os = "fuchsia")]
19014impl UsageReporterSynchronousProxy {
19015    pub fn new(channel: fidl::Channel) -> Self {
19016        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19017        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19018    }
19019
19020    pub fn into_channel(self) -> fidl::Channel {
19021        self.client.into_channel()
19022    }
19023
19024    /// Waits until an event arrives and returns it. It is safe for other
19025    /// threads to make concurrent requests while waiting for an event.
19026    pub fn wait_for_event(
19027        &self,
19028        deadline: zx::MonotonicInstant,
19029    ) -> Result<UsageReporterEvent, fidl::Error> {
19030        UsageReporterEvent::decode(self.client.wait_for_event(deadline)?)
19031    }
19032
19033    pub fn r#watch(
19034        &self,
19035        mut usage: &Usage,
19036        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19037    ) -> Result<(), fidl::Error> {
19038        self.client.send::<UsageReporterWatchRequest>(
19039            (usage, usage_watcher),
19040            0x769e6fb17075c959,
19041            fidl::encoding::DynamicFlags::empty(),
19042        )
19043    }
19044
19045    pub fn r#watch2(
19046        &self,
19047        mut usage: &Usage2,
19048        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19049    ) -> Result<(), fidl::Error> {
19050        self.client.send::<UsageReporterWatch2Request>(
19051            (usage, usage_watcher),
19052            0x4a43c4c82f5d8ce8,
19053            fidl::encoding::DynamicFlags::FLEXIBLE,
19054        )
19055    }
19056}
19057
19058#[cfg(target_os = "fuchsia")]
19059impl From<UsageReporterSynchronousProxy> for zx::NullableHandle {
19060    fn from(value: UsageReporterSynchronousProxy) -> Self {
19061        value.into_channel().into()
19062    }
19063}
19064
19065#[cfg(target_os = "fuchsia")]
19066impl From<fidl::Channel> for UsageReporterSynchronousProxy {
19067    fn from(value: fidl::Channel) -> Self {
19068        Self::new(value)
19069    }
19070}
19071
19072#[cfg(target_os = "fuchsia")]
19073impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
19074    type Protocol = UsageReporterMarker;
19075
19076    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
19077        Self::new(value.into_channel())
19078    }
19079}
19080
19081#[derive(Debug, Clone)]
19082pub struct UsageReporterProxy {
19083    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19084}
19085
19086impl fidl::endpoints::Proxy for UsageReporterProxy {
19087    type Protocol = UsageReporterMarker;
19088
19089    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19090        Self::new(inner)
19091    }
19092
19093    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19094        self.client.into_channel().map_err(|client| Self { client })
19095    }
19096
19097    fn as_channel(&self) -> &::fidl::AsyncChannel {
19098        self.client.as_channel()
19099    }
19100}
19101
19102impl UsageReporterProxy {
19103    /// Create a new Proxy for fuchsia.media/UsageReporter.
19104    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19105        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19106        Self { client: fidl::client::Client::new(channel, protocol_name) }
19107    }
19108
19109    /// Get a Stream of events from the remote end of the protocol.
19110    ///
19111    /// # Panics
19112    ///
19113    /// Panics if the event stream was already taken.
19114    pub fn take_event_stream(&self) -> UsageReporterEventStream {
19115        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
19116    }
19117
19118    pub fn r#watch(
19119        &self,
19120        mut usage: &Usage,
19121        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19122    ) -> Result<(), fidl::Error> {
19123        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
19124    }
19125
19126    pub fn r#watch2(
19127        &self,
19128        mut usage: &Usage2,
19129        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19130    ) -> Result<(), fidl::Error> {
19131        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
19132    }
19133}
19134
19135impl UsageReporterProxyInterface for UsageReporterProxy {
19136    fn r#watch(
19137        &self,
19138        mut usage: &Usage,
19139        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19140    ) -> Result<(), fidl::Error> {
19141        self.client.send::<UsageReporterWatchRequest>(
19142            (usage, usage_watcher),
19143            0x769e6fb17075c959,
19144            fidl::encoding::DynamicFlags::empty(),
19145        )
19146    }
19147
19148    fn r#watch2(
19149        &self,
19150        mut usage: &Usage2,
19151        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19152    ) -> Result<(), fidl::Error> {
19153        self.client.send::<UsageReporterWatch2Request>(
19154            (usage, usage_watcher),
19155            0x4a43c4c82f5d8ce8,
19156            fidl::encoding::DynamicFlags::FLEXIBLE,
19157        )
19158    }
19159}
19160
19161pub struct UsageReporterEventStream {
19162    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19163}
19164
19165impl std::marker::Unpin for UsageReporterEventStream {}
19166
19167impl futures::stream::FusedStream for UsageReporterEventStream {
19168    fn is_terminated(&self) -> bool {
19169        self.event_receiver.is_terminated()
19170    }
19171}
19172
19173impl futures::Stream for UsageReporterEventStream {
19174    type Item = Result<UsageReporterEvent, fidl::Error>;
19175
19176    fn poll_next(
19177        mut self: std::pin::Pin<&mut Self>,
19178        cx: &mut std::task::Context<'_>,
19179    ) -> std::task::Poll<Option<Self::Item>> {
19180        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19181            &mut self.event_receiver,
19182            cx
19183        )?) {
19184            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
19185            None => std::task::Poll::Ready(None),
19186        }
19187    }
19188}
19189
19190#[derive(Debug)]
19191pub enum UsageReporterEvent {
19192    #[non_exhaustive]
19193    _UnknownEvent {
19194        /// Ordinal of the event that was sent.
19195        ordinal: u64,
19196    },
19197}
19198
19199impl UsageReporterEvent {
19200    /// Decodes a message buffer as a [`UsageReporterEvent`].
19201    fn decode(
19202        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19203    ) -> Result<UsageReporterEvent, fidl::Error> {
19204        let (bytes, _handles) = buf.split_mut();
19205        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19206        debug_assert_eq!(tx_header.tx_id, 0);
19207        match tx_header.ordinal {
19208            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19209                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
19210            }
19211            _ => Err(fidl::Error::UnknownOrdinal {
19212                ordinal: tx_header.ordinal,
19213                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19214            }),
19215        }
19216    }
19217}
19218
19219/// A Stream of incoming requests for fuchsia.media/UsageReporter.
19220pub struct UsageReporterRequestStream {
19221    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19222    is_terminated: bool,
19223}
19224
19225impl std::marker::Unpin for UsageReporterRequestStream {}
19226
19227impl futures::stream::FusedStream for UsageReporterRequestStream {
19228    fn is_terminated(&self) -> bool {
19229        self.is_terminated
19230    }
19231}
19232
19233impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
19234    type Protocol = UsageReporterMarker;
19235    type ControlHandle = UsageReporterControlHandle;
19236
19237    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19238        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19239    }
19240
19241    fn control_handle(&self) -> Self::ControlHandle {
19242        UsageReporterControlHandle { inner: self.inner.clone() }
19243    }
19244
19245    fn into_inner(
19246        self,
19247    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19248    {
19249        (self.inner, self.is_terminated)
19250    }
19251
19252    fn from_inner(
19253        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19254        is_terminated: bool,
19255    ) -> Self {
19256        Self { inner, is_terminated }
19257    }
19258}
19259
19260impl futures::Stream for UsageReporterRequestStream {
19261    type Item = Result<UsageReporterRequest, fidl::Error>;
19262
19263    fn poll_next(
19264        mut self: std::pin::Pin<&mut Self>,
19265        cx: &mut std::task::Context<'_>,
19266    ) -> std::task::Poll<Option<Self::Item>> {
19267        let this = &mut *self;
19268        if this.inner.check_shutdown(cx) {
19269            this.is_terminated = true;
19270            return std::task::Poll::Ready(None);
19271        }
19272        if this.is_terminated {
19273            panic!("polled UsageReporterRequestStream after completion");
19274        }
19275        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19276            |bytes, handles| {
19277                match this.inner.channel().read_etc(cx, bytes, handles) {
19278                    std::task::Poll::Ready(Ok(())) => {}
19279                    std::task::Poll::Pending => return std::task::Poll::Pending,
19280                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19281                        this.is_terminated = true;
19282                        return std::task::Poll::Ready(None);
19283                    }
19284                    std::task::Poll::Ready(Err(e)) => {
19285                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19286                            e.into(),
19287                        ))));
19288                    }
19289                }
19290
19291                // A message has been received from the channel
19292                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19293
19294                std::task::Poll::Ready(Some(match header.ordinal {
19295                    0x769e6fb17075c959 => {
19296                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19297                        let mut req = fidl::new_empty!(
19298                            UsageReporterWatchRequest,
19299                            fidl::encoding::DefaultFuchsiaResourceDialect
19300                        );
19301                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
19302                        let control_handle =
19303                            UsageReporterControlHandle { inner: this.inner.clone() };
19304                        Ok(UsageReporterRequest::Watch {
19305                            usage: req.usage,
19306                            usage_watcher: req.usage_watcher,
19307
19308                            control_handle,
19309                        })
19310                    }
19311                    0x4a43c4c82f5d8ce8 => {
19312                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19313                        let mut req = fidl::new_empty!(
19314                            UsageReporterWatch2Request,
19315                            fidl::encoding::DefaultFuchsiaResourceDialect
19316                        );
19317                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
19318                        let control_handle =
19319                            UsageReporterControlHandle { inner: this.inner.clone() };
19320                        Ok(UsageReporterRequest::Watch2 {
19321                            usage: req.usage,
19322                            usage_watcher: req.usage_watcher,
19323
19324                            control_handle,
19325                        })
19326                    }
19327                    _ if header.tx_id == 0
19328                        && header
19329                            .dynamic_flags()
19330                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19331                    {
19332                        Ok(UsageReporterRequest::_UnknownMethod {
19333                            ordinal: header.ordinal,
19334                            control_handle: UsageReporterControlHandle {
19335                                inner: this.inner.clone(),
19336                            },
19337                            method_type: fidl::MethodType::OneWay,
19338                        })
19339                    }
19340                    _ if header
19341                        .dynamic_flags()
19342                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19343                    {
19344                        this.inner.send_framework_err(
19345                            fidl::encoding::FrameworkErr::UnknownMethod,
19346                            header.tx_id,
19347                            header.ordinal,
19348                            header.dynamic_flags(),
19349                            (bytes, handles),
19350                        )?;
19351                        Ok(UsageReporterRequest::_UnknownMethod {
19352                            ordinal: header.ordinal,
19353                            control_handle: UsageReporterControlHandle {
19354                                inner: this.inner.clone(),
19355                            },
19356                            method_type: fidl::MethodType::TwoWay,
19357                        })
19358                    }
19359                    _ => Err(fidl::Error::UnknownOrdinal {
19360                        ordinal: header.ordinal,
19361                        protocol_name:
19362                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19363                    }),
19364                }))
19365            },
19366        )
19367    }
19368}
19369
19370/// A protocol for setting up watchers of audio usages.
19371#[derive(Debug)]
19372pub enum UsageReporterRequest {
19373    Watch {
19374        usage: Usage,
19375        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19376        control_handle: UsageReporterControlHandle,
19377    },
19378    Watch2 {
19379        usage: Usage2,
19380        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19381        control_handle: UsageReporterControlHandle,
19382    },
19383    /// An interaction was received which does not match any known method.
19384    #[non_exhaustive]
19385    _UnknownMethod {
19386        /// Ordinal of the method that was called.
19387        ordinal: u64,
19388        control_handle: UsageReporterControlHandle,
19389        method_type: fidl::MethodType,
19390    },
19391}
19392
19393impl UsageReporterRequest {
19394    #[allow(irrefutable_let_patterns)]
19395    pub fn into_watch(
19396        self,
19397    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
19398    {
19399        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
19400            Some((usage, usage_watcher, control_handle))
19401        } else {
19402            None
19403        }
19404    }
19405
19406    #[allow(irrefutable_let_patterns)]
19407    pub fn into_watch2(
19408        self,
19409    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
19410    {
19411        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
19412            Some((usage, usage_watcher, control_handle))
19413        } else {
19414            None
19415        }
19416    }
19417
19418    /// Name of the method defined in FIDL
19419    pub fn method_name(&self) -> &'static str {
19420        match *self {
19421            UsageReporterRequest::Watch { .. } => "watch",
19422            UsageReporterRequest::Watch2 { .. } => "watch2",
19423            UsageReporterRequest::_UnknownMethod {
19424                method_type: fidl::MethodType::OneWay, ..
19425            } => "unknown one-way method",
19426            UsageReporterRequest::_UnknownMethod {
19427                method_type: fidl::MethodType::TwoWay, ..
19428            } => "unknown two-way method",
19429        }
19430    }
19431}
19432
19433#[derive(Debug, Clone)]
19434pub struct UsageReporterControlHandle {
19435    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19436}
19437
19438impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
19439    fn shutdown(&self) {
19440        self.inner.shutdown()
19441    }
19442
19443    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19444        self.inner.shutdown_with_epitaph(status)
19445    }
19446
19447    fn is_closed(&self) -> bool {
19448        self.inner.channel().is_closed()
19449    }
19450    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19451        self.inner.channel().on_closed()
19452    }
19453
19454    #[cfg(target_os = "fuchsia")]
19455    fn signal_peer(
19456        &self,
19457        clear_mask: zx::Signals,
19458        set_mask: zx::Signals,
19459    ) -> Result<(), zx_status::Status> {
19460        use fidl::Peered;
19461        self.inner.channel().signal_peer(clear_mask, set_mask)
19462    }
19463}
19464
19465impl UsageReporterControlHandle {}
19466
19467#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19468pub struct UsageWatcherMarker;
19469
19470impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
19471    type Proxy = UsageWatcherProxy;
19472    type RequestStream = UsageWatcherRequestStream;
19473    #[cfg(target_os = "fuchsia")]
19474    type SynchronousProxy = UsageWatcherSynchronousProxy;
19475
19476    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
19477}
19478
19479pub trait UsageWatcherProxyInterface: Send + Sync {
19480    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19481    fn r#on_state_changed(
19482        &self,
19483        usage: &Usage,
19484        state: &UsageState,
19485    ) -> Self::OnStateChangedResponseFut;
19486}
19487#[derive(Debug)]
19488#[cfg(target_os = "fuchsia")]
19489pub struct UsageWatcherSynchronousProxy {
19490    client: fidl::client::sync::Client,
19491}
19492
19493#[cfg(target_os = "fuchsia")]
19494impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
19495    type Proxy = UsageWatcherProxy;
19496    type Protocol = UsageWatcherMarker;
19497
19498    fn from_channel(inner: fidl::Channel) -> Self {
19499        Self::new(inner)
19500    }
19501
19502    fn into_channel(self) -> fidl::Channel {
19503        self.client.into_channel()
19504    }
19505
19506    fn as_channel(&self) -> &fidl::Channel {
19507        self.client.as_channel()
19508    }
19509}
19510
19511#[cfg(target_os = "fuchsia")]
19512impl UsageWatcherSynchronousProxy {
19513    pub fn new(channel: fidl::Channel) -> Self {
19514        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19515        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19516    }
19517
19518    pub fn into_channel(self) -> fidl::Channel {
19519        self.client.into_channel()
19520    }
19521
19522    /// Waits until an event arrives and returns it. It is safe for other
19523    /// threads to make concurrent requests while waiting for an event.
19524    pub fn wait_for_event(
19525        &self,
19526        deadline: zx::MonotonicInstant,
19527    ) -> Result<UsageWatcherEvent, fidl::Error> {
19528        UsageWatcherEvent::decode(self.client.wait_for_event(deadline)?)
19529    }
19530
19531    /// Called on first connection and whenever the watched usage changes. The provided
19532    /// usage will always be the bound usage; it is provided so that an implementation of
19533    /// this protocol may be bound to more than one usage.
19534    ///
19535    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19536    /// events will eventually be disconnected.
19537    pub fn r#on_state_changed(
19538        &self,
19539        mut usage: &Usage,
19540        mut state: &UsageState,
19541        ___deadline: zx::MonotonicInstant,
19542    ) -> Result<(), fidl::Error> {
19543        let _response = self
19544            .client
19545            .send_query::<UsageWatcherOnStateChangedRequest, fidl::encoding::EmptyPayload>(
19546                (usage, state),
19547                0x5b955c5768ec75c5,
19548                fidl::encoding::DynamicFlags::empty(),
19549                ___deadline,
19550            )?;
19551        Ok(_response)
19552    }
19553}
19554
19555#[cfg(target_os = "fuchsia")]
19556impl From<UsageWatcherSynchronousProxy> for zx::NullableHandle {
19557    fn from(value: UsageWatcherSynchronousProxy) -> Self {
19558        value.into_channel().into()
19559    }
19560}
19561
19562#[cfg(target_os = "fuchsia")]
19563impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
19564    fn from(value: fidl::Channel) -> Self {
19565        Self::new(value)
19566    }
19567}
19568
19569#[cfg(target_os = "fuchsia")]
19570impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
19571    type Protocol = UsageWatcherMarker;
19572
19573    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
19574        Self::new(value.into_channel())
19575    }
19576}
19577
19578#[derive(Debug, Clone)]
19579pub struct UsageWatcherProxy {
19580    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19581}
19582
19583impl fidl::endpoints::Proxy for UsageWatcherProxy {
19584    type Protocol = UsageWatcherMarker;
19585
19586    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19587        Self::new(inner)
19588    }
19589
19590    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19591        self.client.into_channel().map_err(|client| Self { client })
19592    }
19593
19594    fn as_channel(&self) -> &::fidl::AsyncChannel {
19595        self.client.as_channel()
19596    }
19597}
19598
19599impl UsageWatcherProxy {
19600    /// Create a new Proxy for fuchsia.media/UsageWatcher.
19601    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19602        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19603        Self { client: fidl::client::Client::new(channel, protocol_name) }
19604    }
19605
19606    /// Get a Stream of events from the remote end of the protocol.
19607    ///
19608    /// # Panics
19609    ///
19610    /// Panics if the event stream was already taken.
19611    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
19612        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
19613    }
19614
19615    /// Called on first connection and whenever the watched usage changes. The provided
19616    /// usage will always be the bound usage; it is provided so that an implementation of
19617    /// this protocol may be bound to more than one usage.
19618    ///
19619    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19620    /// events will eventually be disconnected.
19621    pub fn r#on_state_changed(
19622        &self,
19623        mut usage: &Usage,
19624        mut state: &UsageState,
19625    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
19626        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
19627    }
19628}
19629
19630impl UsageWatcherProxyInterface for UsageWatcherProxy {
19631    type OnStateChangedResponseFut =
19632        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
19633    fn r#on_state_changed(
19634        &self,
19635        mut usage: &Usage,
19636        mut state: &UsageState,
19637    ) -> Self::OnStateChangedResponseFut {
19638        fn _decode(
19639            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
19640        ) -> Result<(), fidl::Error> {
19641            let _response = fidl::client::decode_transaction_body::<
19642                fidl::encoding::EmptyPayload,
19643                fidl::encoding::DefaultFuchsiaResourceDialect,
19644                0x5b955c5768ec75c5,
19645            >(_buf?)?;
19646            Ok(_response)
19647        }
19648        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
19649            (usage, state),
19650            0x5b955c5768ec75c5,
19651            fidl::encoding::DynamicFlags::empty(),
19652            _decode,
19653        )
19654    }
19655}
19656
19657pub struct UsageWatcherEventStream {
19658    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19659}
19660
19661impl std::marker::Unpin for UsageWatcherEventStream {}
19662
19663impl futures::stream::FusedStream for UsageWatcherEventStream {
19664    fn is_terminated(&self) -> bool {
19665        self.event_receiver.is_terminated()
19666    }
19667}
19668
19669impl futures::Stream for UsageWatcherEventStream {
19670    type Item = Result<UsageWatcherEvent, fidl::Error>;
19671
19672    fn poll_next(
19673        mut self: std::pin::Pin<&mut Self>,
19674        cx: &mut std::task::Context<'_>,
19675    ) -> std::task::Poll<Option<Self::Item>> {
19676        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19677            &mut self.event_receiver,
19678            cx
19679        )?) {
19680            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
19681            None => std::task::Poll::Ready(None),
19682        }
19683    }
19684}
19685
19686#[derive(Debug)]
19687pub enum UsageWatcherEvent {}
19688
19689impl UsageWatcherEvent {
19690    /// Decodes a message buffer as a [`UsageWatcherEvent`].
19691    fn decode(
19692        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19693    ) -> Result<UsageWatcherEvent, fidl::Error> {
19694        let (bytes, _handles) = buf.split_mut();
19695        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19696        debug_assert_eq!(tx_header.tx_id, 0);
19697        match tx_header.ordinal {
19698            _ => Err(fidl::Error::UnknownOrdinal {
19699                ordinal: tx_header.ordinal,
19700                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19701            }),
19702        }
19703    }
19704}
19705
19706/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
19707pub struct UsageWatcherRequestStream {
19708    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19709    is_terminated: bool,
19710}
19711
19712impl std::marker::Unpin for UsageWatcherRequestStream {}
19713
19714impl futures::stream::FusedStream for UsageWatcherRequestStream {
19715    fn is_terminated(&self) -> bool {
19716        self.is_terminated
19717    }
19718}
19719
19720impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
19721    type Protocol = UsageWatcherMarker;
19722    type ControlHandle = UsageWatcherControlHandle;
19723
19724    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19725        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19726    }
19727
19728    fn control_handle(&self) -> Self::ControlHandle {
19729        UsageWatcherControlHandle { inner: self.inner.clone() }
19730    }
19731
19732    fn into_inner(
19733        self,
19734    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19735    {
19736        (self.inner, self.is_terminated)
19737    }
19738
19739    fn from_inner(
19740        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19741        is_terminated: bool,
19742    ) -> Self {
19743        Self { inner, is_terminated }
19744    }
19745}
19746
19747impl futures::Stream for UsageWatcherRequestStream {
19748    type Item = Result<UsageWatcherRequest, fidl::Error>;
19749
19750    fn poll_next(
19751        mut self: std::pin::Pin<&mut Self>,
19752        cx: &mut std::task::Context<'_>,
19753    ) -> std::task::Poll<Option<Self::Item>> {
19754        let this = &mut *self;
19755        if this.inner.check_shutdown(cx) {
19756            this.is_terminated = true;
19757            return std::task::Poll::Ready(None);
19758        }
19759        if this.is_terminated {
19760            panic!("polled UsageWatcherRequestStream after completion");
19761        }
19762        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19763            |bytes, handles| {
19764                match this.inner.channel().read_etc(cx, bytes, handles) {
19765                    std::task::Poll::Ready(Ok(())) => {}
19766                    std::task::Poll::Pending => return std::task::Poll::Pending,
19767                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19768                        this.is_terminated = true;
19769                        return std::task::Poll::Ready(None);
19770                    }
19771                    std::task::Poll::Ready(Err(e)) => {
19772                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19773                            e.into(),
19774                        ))));
19775                    }
19776                }
19777
19778                // A message has been received from the channel
19779                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19780
19781                std::task::Poll::Ready(Some(match header.ordinal {
19782                    0x5b955c5768ec75c5 => {
19783                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19784                        let mut req = fidl::new_empty!(
19785                            UsageWatcherOnStateChangedRequest,
19786                            fidl::encoding::DefaultFuchsiaResourceDialect
19787                        );
19788                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
19789                        let control_handle =
19790                            UsageWatcherControlHandle { inner: this.inner.clone() };
19791                        Ok(UsageWatcherRequest::OnStateChanged {
19792                            usage: req.usage,
19793                            state: req.state,
19794
19795                            responder: UsageWatcherOnStateChangedResponder {
19796                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19797                                tx_id: header.tx_id,
19798                            },
19799                        })
19800                    }
19801                    _ => Err(fidl::Error::UnknownOrdinal {
19802                        ordinal: header.ordinal,
19803                        protocol_name:
19804                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19805                    }),
19806                }))
19807            },
19808        )
19809    }
19810}
19811
19812/// A protocol for listening to changes to the policy state of an audio usage.
19813///
19814/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
19815#[derive(Debug)]
19816pub enum UsageWatcherRequest {
19817    /// Called on first connection and whenever the watched usage changes. The provided
19818    /// usage will always be the bound usage; it is provided so that an implementation of
19819    /// this protocol may be bound to more than one usage.
19820    ///
19821    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19822    /// events will eventually be disconnected.
19823    OnStateChanged {
19824        usage: Usage,
19825        state: UsageState,
19826        responder: UsageWatcherOnStateChangedResponder,
19827    },
19828}
19829
19830impl UsageWatcherRequest {
19831    #[allow(irrefutable_let_patterns)]
19832    pub fn into_on_state_changed(
19833        self,
19834    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
19835        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
19836            Some((usage, state, responder))
19837        } else {
19838            None
19839        }
19840    }
19841
19842    /// Name of the method defined in FIDL
19843    pub fn method_name(&self) -> &'static str {
19844        match *self {
19845            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
19846        }
19847    }
19848}
19849
19850#[derive(Debug, Clone)]
19851pub struct UsageWatcherControlHandle {
19852    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19853}
19854
19855impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
19856    fn shutdown(&self) {
19857        self.inner.shutdown()
19858    }
19859
19860    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19861        self.inner.shutdown_with_epitaph(status)
19862    }
19863
19864    fn is_closed(&self) -> bool {
19865        self.inner.channel().is_closed()
19866    }
19867    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19868        self.inner.channel().on_closed()
19869    }
19870
19871    #[cfg(target_os = "fuchsia")]
19872    fn signal_peer(
19873        &self,
19874        clear_mask: zx::Signals,
19875        set_mask: zx::Signals,
19876    ) -> Result<(), zx_status::Status> {
19877        use fidl::Peered;
19878        self.inner.channel().signal_peer(clear_mask, set_mask)
19879    }
19880}
19881
19882impl UsageWatcherControlHandle {}
19883
19884#[must_use = "FIDL methods require a response to be sent"]
19885#[derive(Debug)]
19886pub struct UsageWatcherOnStateChangedResponder {
19887    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
19888    tx_id: u32,
19889}
19890
19891/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
19892/// if the responder is dropped without sending a response, so that the client
19893/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19894impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
19895    fn drop(&mut self) {
19896        self.control_handle.shutdown();
19897        // Safety: drops once, never accessed again
19898        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19899    }
19900}
19901
19902impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
19903    type ControlHandle = UsageWatcherControlHandle;
19904
19905    fn control_handle(&self) -> &UsageWatcherControlHandle {
19906        &self.control_handle
19907    }
19908
19909    fn drop_without_shutdown(mut self) {
19910        // Safety: drops once, never accessed again due to mem::forget
19911        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19912        // Prevent Drop from running (which would shut down the channel)
19913        std::mem::forget(self);
19914    }
19915}
19916
19917impl UsageWatcherOnStateChangedResponder {
19918    /// Sends a response to the FIDL transaction.
19919    ///
19920    /// Sets the channel to shutdown if an error occurs.
19921    pub fn send(self) -> Result<(), fidl::Error> {
19922        let _result = self.send_raw();
19923        if _result.is_err() {
19924            self.control_handle.shutdown();
19925        }
19926        self.drop_without_shutdown();
19927        _result
19928    }
19929
19930    /// Similar to "send" but does not shutdown the channel if an error occurs.
19931    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
19932        let _result = self.send_raw();
19933        self.drop_without_shutdown();
19934        _result
19935    }
19936
19937    fn send_raw(&self) -> Result<(), fidl::Error> {
19938        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
19939            (),
19940            self.tx_id,
19941            0x5b955c5768ec75c5,
19942            fidl::encoding::DynamicFlags::empty(),
19943        )
19944    }
19945}
19946
19947#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19948pub struct UsageWatcher2Marker;
19949
19950impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
19951    type Proxy = UsageWatcher2Proxy;
19952    type RequestStream = UsageWatcher2RequestStream;
19953    #[cfg(target_os = "fuchsia")]
19954    type SynchronousProxy = UsageWatcher2SynchronousProxy;
19955
19956    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
19957}
19958
19959pub trait UsageWatcher2ProxyInterface: Send + Sync {
19960    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19961    fn r#on_state_changed(
19962        &self,
19963        usage: &Usage2,
19964        state: &UsageState,
19965    ) -> Self::OnStateChangedResponseFut;
19966}
19967#[derive(Debug)]
19968#[cfg(target_os = "fuchsia")]
19969pub struct UsageWatcher2SynchronousProxy {
19970    client: fidl::client::sync::Client,
19971}
19972
19973#[cfg(target_os = "fuchsia")]
19974impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
19975    type Proxy = UsageWatcher2Proxy;
19976    type Protocol = UsageWatcher2Marker;
19977
19978    fn from_channel(inner: fidl::Channel) -> Self {
19979        Self::new(inner)
19980    }
19981
19982    fn into_channel(self) -> fidl::Channel {
19983        self.client.into_channel()
19984    }
19985
19986    fn as_channel(&self) -> &fidl::Channel {
19987        self.client.as_channel()
19988    }
19989}
19990
19991#[cfg(target_os = "fuchsia")]
19992impl UsageWatcher2SynchronousProxy {
19993    pub fn new(channel: fidl::Channel) -> Self {
19994        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19995        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19996    }
19997
19998    pub fn into_channel(self) -> fidl::Channel {
19999        self.client.into_channel()
20000    }
20001
20002    /// Waits until an event arrives and returns it. It is safe for other
20003    /// threads to make concurrent requests while waiting for an event.
20004    pub fn wait_for_event(
20005        &self,
20006        deadline: zx::MonotonicInstant,
20007    ) -> Result<UsageWatcher2Event, fidl::Error> {
20008        UsageWatcher2Event::decode(self.client.wait_for_event(deadline)?)
20009    }
20010
20011    /// Called on first connection and whenever the watched usage changes. The provided
20012    /// usage will always be the bound usage; it is provided so that an implementation of
20013    /// this protocol may be bound to more than one usage.
20014    ///
20015    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20016    /// events will eventually be disconnected.
20017    pub fn r#on_state_changed(
20018        &self,
20019        mut usage: &Usage2,
20020        mut state: &UsageState,
20021        ___deadline: zx::MonotonicInstant,
20022    ) -> Result<(), fidl::Error> {
20023        let _response = self
20024            .client
20025            .send_query::<UsageWatcher2OnStateChangedRequest, fidl::encoding::EmptyPayload>(
20026                (usage, state),
20027                0xca31a8b13c324d4,
20028                fidl::encoding::DynamicFlags::empty(),
20029                ___deadline,
20030            )?;
20031        Ok(_response)
20032    }
20033}
20034
20035#[cfg(target_os = "fuchsia")]
20036impl From<UsageWatcher2SynchronousProxy> for zx::NullableHandle {
20037    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
20038        value.into_channel().into()
20039    }
20040}
20041
20042#[cfg(target_os = "fuchsia")]
20043impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
20044    fn from(value: fidl::Channel) -> Self {
20045        Self::new(value)
20046    }
20047}
20048
20049#[cfg(target_os = "fuchsia")]
20050impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
20051    type Protocol = UsageWatcher2Marker;
20052
20053    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
20054        Self::new(value.into_channel())
20055    }
20056}
20057
20058#[derive(Debug, Clone)]
20059pub struct UsageWatcher2Proxy {
20060    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20061}
20062
20063impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
20064    type Protocol = UsageWatcher2Marker;
20065
20066    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20067        Self::new(inner)
20068    }
20069
20070    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20071        self.client.into_channel().map_err(|client| Self { client })
20072    }
20073
20074    fn as_channel(&self) -> &::fidl::AsyncChannel {
20075        self.client.as_channel()
20076    }
20077}
20078
20079impl UsageWatcher2Proxy {
20080    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
20081    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20082        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20083        Self { client: fidl::client::Client::new(channel, protocol_name) }
20084    }
20085
20086    /// Get a Stream of events from the remote end of the protocol.
20087    ///
20088    /// # Panics
20089    ///
20090    /// Panics if the event stream was already taken.
20091    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
20092        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
20093    }
20094
20095    /// Called on first connection and whenever the watched usage changes. The provided
20096    /// usage will always be the bound usage; it is provided so that an implementation of
20097    /// this protocol may be bound to more than one usage.
20098    ///
20099    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20100    /// events will eventually be disconnected.
20101    pub fn r#on_state_changed(
20102        &self,
20103        mut usage: &Usage2,
20104        mut state: &UsageState,
20105    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20106        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
20107    }
20108}
20109
20110impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
20111    type OnStateChangedResponseFut =
20112        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20113    fn r#on_state_changed(
20114        &self,
20115        mut usage: &Usage2,
20116        mut state: &UsageState,
20117    ) -> Self::OnStateChangedResponseFut {
20118        fn _decode(
20119            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20120        ) -> Result<(), fidl::Error> {
20121            let _response = fidl::client::decode_transaction_body::<
20122                fidl::encoding::EmptyPayload,
20123                fidl::encoding::DefaultFuchsiaResourceDialect,
20124                0xca31a8b13c324d4,
20125            >(_buf?)?;
20126            Ok(_response)
20127        }
20128        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
20129            (usage, state),
20130            0xca31a8b13c324d4,
20131            fidl::encoding::DynamicFlags::empty(),
20132            _decode,
20133        )
20134    }
20135}
20136
20137pub struct UsageWatcher2EventStream {
20138    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20139}
20140
20141impl std::marker::Unpin for UsageWatcher2EventStream {}
20142
20143impl futures::stream::FusedStream for UsageWatcher2EventStream {
20144    fn is_terminated(&self) -> bool {
20145        self.event_receiver.is_terminated()
20146    }
20147}
20148
20149impl futures::Stream for UsageWatcher2EventStream {
20150    type Item = Result<UsageWatcher2Event, fidl::Error>;
20151
20152    fn poll_next(
20153        mut self: std::pin::Pin<&mut Self>,
20154        cx: &mut std::task::Context<'_>,
20155    ) -> std::task::Poll<Option<Self::Item>> {
20156        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20157            &mut self.event_receiver,
20158            cx
20159        )?) {
20160            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
20161            None => std::task::Poll::Ready(None),
20162        }
20163    }
20164}
20165
20166#[derive(Debug)]
20167pub enum UsageWatcher2Event {}
20168
20169impl UsageWatcher2Event {
20170    /// Decodes a message buffer as a [`UsageWatcher2Event`].
20171    fn decode(
20172        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20173    ) -> Result<UsageWatcher2Event, fidl::Error> {
20174        let (bytes, _handles) = buf.split_mut();
20175        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20176        debug_assert_eq!(tx_header.tx_id, 0);
20177        match tx_header.ordinal {
20178            _ => Err(fidl::Error::UnknownOrdinal {
20179                ordinal: tx_header.ordinal,
20180                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20181            }),
20182        }
20183    }
20184}
20185
20186/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
20187pub struct UsageWatcher2RequestStream {
20188    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20189    is_terminated: bool,
20190}
20191
20192impl std::marker::Unpin for UsageWatcher2RequestStream {}
20193
20194impl futures::stream::FusedStream for UsageWatcher2RequestStream {
20195    fn is_terminated(&self) -> bool {
20196        self.is_terminated
20197    }
20198}
20199
20200impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
20201    type Protocol = UsageWatcher2Marker;
20202    type ControlHandle = UsageWatcher2ControlHandle;
20203
20204    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20205        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20206    }
20207
20208    fn control_handle(&self) -> Self::ControlHandle {
20209        UsageWatcher2ControlHandle { inner: self.inner.clone() }
20210    }
20211
20212    fn into_inner(
20213        self,
20214    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20215    {
20216        (self.inner, self.is_terminated)
20217    }
20218
20219    fn from_inner(
20220        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20221        is_terminated: bool,
20222    ) -> Self {
20223        Self { inner, is_terminated }
20224    }
20225}
20226
20227impl futures::Stream for UsageWatcher2RequestStream {
20228    type Item = Result<UsageWatcher2Request, fidl::Error>;
20229
20230    fn poll_next(
20231        mut self: std::pin::Pin<&mut Self>,
20232        cx: &mut std::task::Context<'_>,
20233    ) -> std::task::Poll<Option<Self::Item>> {
20234        let this = &mut *self;
20235        if this.inner.check_shutdown(cx) {
20236            this.is_terminated = true;
20237            return std::task::Poll::Ready(None);
20238        }
20239        if this.is_terminated {
20240            panic!("polled UsageWatcher2RequestStream after completion");
20241        }
20242        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20243            |bytes, handles| {
20244                match this.inner.channel().read_etc(cx, bytes, handles) {
20245                    std::task::Poll::Ready(Ok(())) => {}
20246                    std::task::Poll::Pending => return std::task::Poll::Pending,
20247                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20248                        this.is_terminated = true;
20249                        return std::task::Poll::Ready(None);
20250                    }
20251                    std::task::Poll::Ready(Err(e)) => {
20252                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20253                            e.into(),
20254                        ))));
20255                    }
20256                }
20257
20258                // A message has been received from the channel
20259                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20260
20261                std::task::Poll::Ready(Some(match header.ordinal {
20262                    0xca31a8b13c324d4 => {
20263                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20264                        let mut req = fidl::new_empty!(
20265                            UsageWatcher2OnStateChangedRequest,
20266                            fidl::encoding::DefaultFuchsiaResourceDialect
20267                        );
20268                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20269                        let control_handle =
20270                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
20271                        Ok(UsageWatcher2Request::OnStateChanged {
20272                            usage: req.usage,
20273                            state: req.state,
20274
20275                            responder: UsageWatcher2OnStateChangedResponder {
20276                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20277                                tx_id: header.tx_id,
20278                            },
20279                        })
20280                    }
20281                    _ => Err(fidl::Error::UnknownOrdinal {
20282                        ordinal: header.ordinal,
20283                        protocol_name:
20284                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20285                    }),
20286                }))
20287            },
20288        )
20289    }
20290}
20291
20292#[derive(Debug)]
20293pub enum UsageWatcher2Request {
20294    /// Called on first connection and whenever the watched usage changes. The provided
20295    /// usage will always be the bound usage; it is provided so that an implementation of
20296    /// this protocol may be bound to more than one usage.
20297    ///
20298    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20299    /// events will eventually be disconnected.
20300    OnStateChanged {
20301        usage: Usage2,
20302        state: UsageState,
20303        responder: UsageWatcher2OnStateChangedResponder,
20304    },
20305}
20306
20307impl UsageWatcher2Request {
20308    #[allow(irrefutable_let_patterns)]
20309    pub fn into_on_state_changed(
20310        self,
20311    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
20312        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
20313            Some((usage, state, responder))
20314        } else {
20315            None
20316        }
20317    }
20318
20319    /// Name of the method defined in FIDL
20320    pub fn method_name(&self) -> &'static str {
20321        match *self {
20322            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
20323        }
20324    }
20325}
20326
20327#[derive(Debug, Clone)]
20328pub struct UsageWatcher2ControlHandle {
20329    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20330}
20331
20332impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
20333    fn shutdown(&self) {
20334        self.inner.shutdown()
20335    }
20336
20337    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20338        self.inner.shutdown_with_epitaph(status)
20339    }
20340
20341    fn is_closed(&self) -> bool {
20342        self.inner.channel().is_closed()
20343    }
20344    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20345        self.inner.channel().on_closed()
20346    }
20347
20348    #[cfg(target_os = "fuchsia")]
20349    fn signal_peer(
20350        &self,
20351        clear_mask: zx::Signals,
20352        set_mask: zx::Signals,
20353    ) -> Result<(), zx_status::Status> {
20354        use fidl::Peered;
20355        self.inner.channel().signal_peer(clear_mask, set_mask)
20356    }
20357}
20358
20359impl UsageWatcher2ControlHandle {}
20360
20361#[must_use = "FIDL methods require a response to be sent"]
20362#[derive(Debug)]
20363pub struct UsageWatcher2OnStateChangedResponder {
20364    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
20365    tx_id: u32,
20366}
20367
20368/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
20369/// if the responder is dropped without sending a response, so that the client
20370/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20371impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
20372    fn drop(&mut self) {
20373        self.control_handle.shutdown();
20374        // Safety: drops once, never accessed again
20375        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20376    }
20377}
20378
20379impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
20380    type ControlHandle = UsageWatcher2ControlHandle;
20381
20382    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
20383        &self.control_handle
20384    }
20385
20386    fn drop_without_shutdown(mut self) {
20387        // Safety: drops once, never accessed again due to mem::forget
20388        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20389        // Prevent Drop from running (which would shut down the channel)
20390        std::mem::forget(self);
20391    }
20392}
20393
20394impl UsageWatcher2OnStateChangedResponder {
20395    /// Sends a response to the FIDL transaction.
20396    ///
20397    /// Sets the channel to shutdown if an error occurs.
20398    pub fn send(self) -> Result<(), fidl::Error> {
20399        let _result = self.send_raw();
20400        if _result.is_err() {
20401            self.control_handle.shutdown();
20402        }
20403        self.drop_without_shutdown();
20404        _result
20405    }
20406
20407    /// Similar to "send" but does not shutdown the channel if an error occurs.
20408    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20409        let _result = self.send_raw();
20410        self.drop_without_shutdown();
20411        _result
20412    }
20413
20414    fn send_raw(&self) -> Result<(), fidl::Error> {
20415        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20416            (),
20417            self.tx_id,
20418            0xca31a8b13c324d4,
20419            fidl::encoding::DynamicFlags::empty(),
20420        )
20421    }
20422}
20423
20424mod internal {
20425    use super::*;
20426
20427    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
20428        type Borrowed<'a> = &'a mut Self;
20429        fn take_or_borrow<'a>(
20430            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20431        ) -> Self::Borrowed<'a> {
20432            value
20433        }
20434    }
20435
20436    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
20437        type Owned = Self;
20438
20439        #[inline(always)]
20440        fn inline_align(_context: fidl::encoding::Context) -> usize {
20441            4
20442        }
20443
20444        #[inline(always)]
20445        fn inline_size(_context: fidl::encoding::Context) -> usize {
20446            4
20447        }
20448    }
20449
20450    unsafe impl
20451        fidl::encoding::Encode<
20452            AudioCapturerBindGainControlRequest,
20453            fidl::encoding::DefaultFuchsiaResourceDialect,
20454        > for &mut AudioCapturerBindGainControlRequest
20455    {
20456        #[inline]
20457        unsafe fn encode(
20458            self,
20459            encoder: &mut fidl::encoding::Encoder<
20460                '_,
20461                fidl::encoding::DefaultFuchsiaResourceDialect,
20462            >,
20463            offset: usize,
20464            _depth: fidl::encoding::Depth,
20465        ) -> fidl::Result<()> {
20466            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20467            // Delegate to tuple encoding.
20468            fidl::encoding::Encode::<
20469                AudioCapturerBindGainControlRequest,
20470                fidl::encoding::DefaultFuchsiaResourceDialect,
20471            >::encode(
20472                (<fidl::encoding::Endpoint<
20473                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20474                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20475                    &mut self.gain_control_request,
20476                ),),
20477                encoder,
20478                offset,
20479                _depth,
20480            )
20481        }
20482    }
20483    unsafe impl<
20484        T0: fidl::encoding::Encode<
20485                fidl::encoding::Endpoint<
20486                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20487                >,
20488                fidl::encoding::DefaultFuchsiaResourceDialect,
20489            >,
20490    >
20491        fidl::encoding::Encode<
20492            AudioCapturerBindGainControlRequest,
20493            fidl::encoding::DefaultFuchsiaResourceDialect,
20494        > for (T0,)
20495    {
20496        #[inline]
20497        unsafe fn encode(
20498            self,
20499            encoder: &mut fidl::encoding::Encoder<
20500                '_,
20501                fidl::encoding::DefaultFuchsiaResourceDialect,
20502            >,
20503            offset: usize,
20504            depth: fidl::encoding::Depth,
20505        ) -> fidl::Result<()> {
20506            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20507            // Zero out padding regions. There's no need to apply masks
20508            // because the unmasked parts will be overwritten by fields.
20509            // Write the fields.
20510            self.0.encode(encoder, offset + 0, depth)?;
20511            Ok(())
20512        }
20513    }
20514
20515    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20516        for AudioCapturerBindGainControlRequest
20517    {
20518        #[inline(always)]
20519        fn new_empty() -> Self {
20520            Self {
20521                gain_control_request: fidl::new_empty!(
20522                    fidl::encoding::Endpoint<
20523                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20524                    >,
20525                    fidl::encoding::DefaultFuchsiaResourceDialect
20526                ),
20527            }
20528        }
20529
20530        #[inline]
20531        unsafe fn decode(
20532            &mut self,
20533            decoder: &mut fidl::encoding::Decoder<
20534                '_,
20535                fidl::encoding::DefaultFuchsiaResourceDialect,
20536            >,
20537            offset: usize,
20538            _depth: fidl::encoding::Depth,
20539        ) -> fidl::Result<()> {
20540            decoder.debug_check_bounds::<Self>(offset);
20541            // Verify that padding bytes are zero.
20542            fidl::decode!(
20543                fidl::encoding::Endpoint<
20544                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20545                >,
20546                fidl::encoding::DefaultFuchsiaResourceDialect,
20547                &mut self.gain_control_request,
20548                decoder,
20549                offset + 0,
20550                _depth
20551            )?;
20552            Ok(())
20553        }
20554    }
20555
20556    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
20557        type Borrowed<'a> = &'a mut Self;
20558        fn take_or_borrow<'a>(
20559            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20560        ) -> Self::Borrowed<'a> {
20561            value
20562        }
20563    }
20564
20565    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
20566        type Owned = Self;
20567
20568        #[inline(always)]
20569        fn inline_align(_context: fidl::encoding::Context) -> usize {
20570            4
20571        }
20572
20573        #[inline(always)]
20574        fn inline_size(_context: fidl::encoding::Context) -> usize {
20575            4
20576        }
20577    }
20578
20579    unsafe impl
20580        fidl::encoding::Encode<
20581            AudioCapturerGetReferenceClockResponse,
20582            fidl::encoding::DefaultFuchsiaResourceDialect,
20583        > for &mut AudioCapturerGetReferenceClockResponse
20584    {
20585        #[inline]
20586        unsafe fn encode(
20587            self,
20588            encoder: &mut fidl::encoding::Encoder<
20589                '_,
20590                fidl::encoding::DefaultFuchsiaResourceDialect,
20591            >,
20592            offset: usize,
20593            _depth: fidl::encoding::Depth,
20594        ) -> fidl::Result<()> {
20595            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20596            // Delegate to tuple encoding.
20597            fidl::encoding::Encode::<
20598                AudioCapturerGetReferenceClockResponse,
20599                fidl::encoding::DefaultFuchsiaResourceDialect,
20600            >::encode(
20601                (<fidl::encoding::HandleType<
20602                    fidl::Clock,
20603                    { fidl::ObjectType::CLOCK.into_raw() },
20604                    2147483648,
20605                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20606                    &mut self.reference_clock,
20607                ),),
20608                encoder,
20609                offset,
20610                _depth,
20611            )
20612        }
20613    }
20614    unsafe impl<
20615        T0: fidl::encoding::Encode<
20616                fidl::encoding::HandleType<
20617                    fidl::Clock,
20618                    { fidl::ObjectType::CLOCK.into_raw() },
20619                    2147483648,
20620                >,
20621                fidl::encoding::DefaultFuchsiaResourceDialect,
20622            >,
20623    >
20624        fidl::encoding::Encode<
20625            AudioCapturerGetReferenceClockResponse,
20626            fidl::encoding::DefaultFuchsiaResourceDialect,
20627        > for (T0,)
20628    {
20629        #[inline]
20630        unsafe fn encode(
20631            self,
20632            encoder: &mut fidl::encoding::Encoder<
20633                '_,
20634                fidl::encoding::DefaultFuchsiaResourceDialect,
20635            >,
20636            offset: usize,
20637            depth: fidl::encoding::Depth,
20638        ) -> fidl::Result<()> {
20639            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20640            // Zero out padding regions. There's no need to apply masks
20641            // because the unmasked parts will be overwritten by fields.
20642            // Write the fields.
20643            self.0.encode(encoder, offset + 0, depth)?;
20644            Ok(())
20645        }
20646    }
20647
20648    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20649        for AudioCapturerGetReferenceClockResponse
20650    {
20651        #[inline(always)]
20652        fn new_empty() -> Self {
20653            Self {
20654                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
20655            }
20656        }
20657
20658        #[inline]
20659        unsafe fn decode(
20660            &mut self,
20661            decoder: &mut fidl::encoding::Decoder<
20662                '_,
20663                fidl::encoding::DefaultFuchsiaResourceDialect,
20664            >,
20665            offset: usize,
20666            _depth: fidl::encoding::Depth,
20667        ) -> fidl::Result<()> {
20668            decoder.debug_check_bounds::<Self>(offset);
20669            // Verify that padding bytes are zero.
20670            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20671            Ok(())
20672        }
20673    }
20674
20675    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
20676        type Borrowed<'a> = &'a mut Self;
20677        fn take_or_borrow<'a>(
20678            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20679        ) -> Self::Borrowed<'a> {
20680            value
20681        }
20682    }
20683
20684    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
20685        type Owned = Self;
20686
20687        #[inline(always)]
20688        fn inline_align(_context: fidl::encoding::Context) -> usize {
20689            4
20690        }
20691
20692        #[inline(always)]
20693        fn inline_size(_context: fidl::encoding::Context) -> usize {
20694            4
20695        }
20696    }
20697
20698    unsafe impl
20699        fidl::encoding::Encode<
20700            AudioCapturerSetReferenceClockRequest,
20701            fidl::encoding::DefaultFuchsiaResourceDialect,
20702        > for &mut AudioCapturerSetReferenceClockRequest
20703    {
20704        #[inline]
20705        unsafe fn encode(
20706            self,
20707            encoder: &mut fidl::encoding::Encoder<
20708                '_,
20709                fidl::encoding::DefaultFuchsiaResourceDialect,
20710            >,
20711            offset: usize,
20712            _depth: fidl::encoding::Depth,
20713        ) -> fidl::Result<()> {
20714            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20715            // Delegate to tuple encoding.
20716            fidl::encoding::Encode::<
20717                AudioCapturerSetReferenceClockRequest,
20718                fidl::encoding::DefaultFuchsiaResourceDialect,
20719            >::encode(
20720                (<fidl::encoding::Optional<
20721                    fidl::encoding::HandleType<
20722                        fidl::Clock,
20723                        { fidl::ObjectType::CLOCK.into_raw() },
20724                        2147483648,
20725                    >,
20726                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20727                    &mut self.reference_clock,
20728                ),),
20729                encoder,
20730                offset,
20731                _depth,
20732            )
20733        }
20734    }
20735    unsafe impl<
20736        T0: fidl::encoding::Encode<
20737                fidl::encoding::Optional<
20738                    fidl::encoding::HandleType<
20739                        fidl::Clock,
20740                        { fidl::ObjectType::CLOCK.into_raw() },
20741                        2147483648,
20742                    >,
20743                >,
20744                fidl::encoding::DefaultFuchsiaResourceDialect,
20745            >,
20746    >
20747        fidl::encoding::Encode<
20748            AudioCapturerSetReferenceClockRequest,
20749            fidl::encoding::DefaultFuchsiaResourceDialect,
20750        > for (T0,)
20751    {
20752        #[inline]
20753        unsafe fn encode(
20754            self,
20755            encoder: &mut fidl::encoding::Encoder<
20756                '_,
20757                fidl::encoding::DefaultFuchsiaResourceDialect,
20758            >,
20759            offset: usize,
20760            depth: fidl::encoding::Depth,
20761        ) -> fidl::Result<()> {
20762            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20763            // Zero out padding regions. There's no need to apply masks
20764            // because the unmasked parts will be overwritten by fields.
20765            // Write the fields.
20766            self.0.encode(encoder, offset + 0, depth)?;
20767            Ok(())
20768        }
20769    }
20770
20771    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20772        for AudioCapturerSetReferenceClockRequest
20773    {
20774        #[inline(always)]
20775        fn new_empty() -> Self {
20776            Self {
20777                reference_clock: fidl::new_empty!(
20778                    fidl::encoding::Optional<
20779                        fidl::encoding::HandleType<
20780                            fidl::Clock,
20781                            { fidl::ObjectType::CLOCK.into_raw() },
20782                            2147483648,
20783                        >,
20784                    >,
20785                    fidl::encoding::DefaultFuchsiaResourceDialect
20786                ),
20787            }
20788        }
20789
20790        #[inline]
20791        unsafe fn decode(
20792            &mut self,
20793            decoder: &mut fidl::encoding::Decoder<
20794                '_,
20795                fidl::encoding::DefaultFuchsiaResourceDialect,
20796            >,
20797            offset: usize,
20798            _depth: fidl::encoding::Depth,
20799        ) -> fidl::Result<()> {
20800            decoder.debug_check_bounds::<Self>(offset);
20801            // Verify that padding bytes are zero.
20802            fidl::decode!(
20803                fidl::encoding::Optional<
20804                    fidl::encoding::HandleType<
20805                        fidl::Clock,
20806                        { fidl::ObjectType::CLOCK.into_raw() },
20807                        2147483648,
20808                    >,
20809                >,
20810                fidl::encoding::DefaultFuchsiaResourceDialect,
20811                &mut self.reference_clock,
20812                decoder,
20813                offset + 0,
20814                _depth
20815            )?;
20816            Ok(())
20817        }
20818    }
20819
20820    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
20821        type Borrowed<'a> = &'a mut Self;
20822        fn take_or_borrow<'a>(
20823            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20824        ) -> Self::Borrowed<'a> {
20825            value
20826        }
20827    }
20828
20829    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
20830        type Owned = Self;
20831
20832        #[inline(always)]
20833        fn inline_align(_context: fidl::encoding::Context) -> usize {
20834            4
20835        }
20836
20837        #[inline(always)]
20838        fn inline_size(_context: fidl::encoding::Context) -> usize {
20839            4
20840        }
20841    }
20842
20843    unsafe impl
20844        fidl::encoding::Encode<
20845            AudioConsumerBindVolumeControlRequest,
20846            fidl::encoding::DefaultFuchsiaResourceDialect,
20847        > for &mut AudioConsumerBindVolumeControlRequest
20848    {
20849        #[inline]
20850        unsafe fn encode(
20851            self,
20852            encoder: &mut fidl::encoding::Encoder<
20853                '_,
20854                fidl::encoding::DefaultFuchsiaResourceDialect,
20855            >,
20856            offset: usize,
20857            _depth: fidl::encoding::Depth,
20858        ) -> fidl::Result<()> {
20859            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20860            // Delegate to tuple encoding.
20861            fidl::encoding::Encode::<
20862                AudioConsumerBindVolumeControlRequest,
20863                fidl::encoding::DefaultFuchsiaResourceDialect,
20864            >::encode(
20865                (<fidl::encoding::Endpoint<
20866                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20867                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20868                    &mut self.volume_control_request,
20869                ),),
20870                encoder,
20871                offset,
20872                _depth,
20873            )
20874        }
20875    }
20876    unsafe impl<
20877        T0: fidl::encoding::Encode<
20878                fidl::encoding::Endpoint<
20879                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20880                >,
20881                fidl::encoding::DefaultFuchsiaResourceDialect,
20882            >,
20883    >
20884        fidl::encoding::Encode<
20885            AudioConsumerBindVolumeControlRequest,
20886            fidl::encoding::DefaultFuchsiaResourceDialect,
20887        > for (T0,)
20888    {
20889        #[inline]
20890        unsafe fn encode(
20891            self,
20892            encoder: &mut fidl::encoding::Encoder<
20893                '_,
20894                fidl::encoding::DefaultFuchsiaResourceDialect,
20895            >,
20896            offset: usize,
20897            depth: fidl::encoding::Depth,
20898        ) -> fidl::Result<()> {
20899            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20900            // Zero out padding regions. There's no need to apply masks
20901            // because the unmasked parts will be overwritten by fields.
20902            // Write the fields.
20903            self.0.encode(encoder, offset + 0, depth)?;
20904            Ok(())
20905        }
20906    }
20907
20908    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20909        for AudioConsumerBindVolumeControlRequest
20910    {
20911        #[inline(always)]
20912        fn new_empty() -> Self {
20913            Self {
20914                volume_control_request: fidl::new_empty!(
20915                    fidl::encoding::Endpoint<
20916                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20917                    >,
20918                    fidl::encoding::DefaultFuchsiaResourceDialect
20919                ),
20920            }
20921        }
20922
20923        #[inline]
20924        unsafe fn decode(
20925            &mut self,
20926            decoder: &mut fidl::encoding::Decoder<
20927                '_,
20928                fidl::encoding::DefaultFuchsiaResourceDialect,
20929            >,
20930            offset: usize,
20931            _depth: fidl::encoding::Depth,
20932        ) -> fidl::Result<()> {
20933            decoder.debug_check_bounds::<Self>(offset);
20934            // Verify that padding bytes are zero.
20935            fidl::decode!(
20936                fidl::encoding::Endpoint<
20937                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20938                >,
20939                fidl::encoding::DefaultFuchsiaResourceDialect,
20940                &mut self.volume_control_request,
20941                decoder,
20942                offset + 0,
20943                _depth
20944            )?;
20945            Ok(())
20946        }
20947    }
20948
20949    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
20950        type Borrowed<'a> = &'a mut Self;
20951        fn take_or_borrow<'a>(
20952            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20953        ) -> Self::Borrowed<'a> {
20954            value
20955        }
20956    }
20957
20958    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
20959        type Owned = Self;
20960
20961        #[inline(always)]
20962        fn inline_align(_context: fidl::encoding::Context) -> usize {
20963            8
20964        }
20965
20966        #[inline(always)]
20967        fn inline_size(_context: fidl::encoding::Context) -> usize {
20968            48
20969        }
20970    }
20971
20972    unsafe impl
20973        fidl::encoding::Encode<
20974            AudioConsumerCreateStreamSinkRequest,
20975            fidl::encoding::DefaultFuchsiaResourceDialect,
20976        > for &mut AudioConsumerCreateStreamSinkRequest
20977    {
20978        #[inline]
20979        unsafe fn encode(
20980            self,
20981            encoder: &mut fidl::encoding::Encoder<
20982                '_,
20983                fidl::encoding::DefaultFuchsiaResourceDialect,
20984            >,
20985            offset: usize,
20986            _depth: fidl::encoding::Depth,
20987        ) -> fidl::Result<()> {
20988            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
20989            // Delegate to tuple encoding.
20990            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
20991                (
20992                    <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),
20993                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
20994                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
20995                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
20996                ),
20997                encoder, offset, _depth
20998            )
20999        }
21000    }
21001    unsafe impl<
21002        T0: fidl::encoding::Encode<
21003                fidl::encoding::Vector<
21004                    fidl::encoding::HandleType<
21005                        fidl::Vmo,
21006                        { fidl::ObjectType::VMO.into_raw() },
21007                        2147483648,
21008                    >,
21009                    16,
21010                >,
21011                fidl::encoding::DefaultFuchsiaResourceDialect,
21012            >,
21013        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21014        T2: fidl::encoding::Encode<
21015                fidl::encoding::Boxed<Compression>,
21016                fidl::encoding::DefaultFuchsiaResourceDialect,
21017            >,
21018        T3: fidl::encoding::Encode<
21019                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21020                fidl::encoding::DefaultFuchsiaResourceDialect,
21021            >,
21022    >
21023        fidl::encoding::Encode<
21024            AudioConsumerCreateStreamSinkRequest,
21025            fidl::encoding::DefaultFuchsiaResourceDialect,
21026        > for (T0, T1, T2, T3)
21027    {
21028        #[inline]
21029        unsafe fn encode(
21030            self,
21031            encoder: &mut fidl::encoding::Encoder<
21032                '_,
21033                fidl::encoding::DefaultFuchsiaResourceDialect,
21034            >,
21035            offset: usize,
21036            depth: fidl::encoding::Depth,
21037        ) -> fidl::Result<()> {
21038            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21039            // Zero out padding regions. There's no need to apply masks
21040            // because the unmasked parts will be overwritten by fields.
21041            unsafe {
21042                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
21043                (ptr as *mut u64).write_unaligned(0);
21044            }
21045            unsafe {
21046                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
21047                (ptr as *mut u64).write_unaligned(0);
21048            }
21049            // Write the fields.
21050            self.0.encode(encoder, offset + 0, depth)?;
21051            self.1.encode(encoder, offset + 16, depth)?;
21052            self.2.encode(encoder, offset + 32, depth)?;
21053            self.3.encode(encoder, offset + 40, depth)?;
21054            Ok(())
21055        }
21056    }
21057
21058    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21059        for AudioConsumerCreateStreamSinkRequest
21060    {
21061        #[inline(always)]
21062        fn new_empty() -> Self {
21063            Self {
21064                buffers: fidl::new_empty!(
21065                    fidl::encoding::Vector<
21066                        fidl::encoding::HandleType<
21067                            fidl::Vmo,
21068                            { fidl::ObjectType::VMO.into_raw() },
21069                            2147483648,
21070                        >,
21071                        16,
21072                    >,
21073                    fidl::encoding::DefaultFuchsiaResourceDialect
21074                ),
21075                stream_type: fidl::new_empty!(
21076                    AudioStreamType,
21077                    fidl::encoding::DefaultFuchsiaResourceDialect
21078                ),
21079                compression: fidl::new_empty!(
21080                    fidl::encoding::Boxed<Compression>,
21081                    fidl::encoding::DefaultFuchsiaResourceDialect
21082                ),
21083                stream_sink_request: fidl::new_empty!(
21084                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21085                    fidl::encoding::DefaultFuchsiaResourceDialect
21086                ),
21087            }
21088        }
21089
21090        #[inline]
21091        unsafe fn decode(
21092            &mut self,
21093            decoder: &mut fidl::encoding::Decoder<
21094                '_,
21095                fidl::encoding::DefaultFuchsiaResourceDialect,
21096            >,
21097            offset: usize,
21098            _depth: fidl::encoding::Depth,
21099        ) -> fidl::Result<()> {
21100            decoder.debug_check_bounds::<Self>(offset);
21101            // Verify that padding bytes are zero.
21102            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
21103            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21104            let mask = 0xffffffff00000000u64;
21105            let maskedval = padval & mask;
21106            if maskedval != 0 {
21107                return Err(fidl::Error::NonZeroPadding {
21108                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
21109                });
21110            }
21111            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
21112            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21113            let mask = 0xffffffff00000000u64;
21114            let maskedval = padval & mask;
21115            if maskedval != 0 {
21116                return Err(fidl::Error::NonZeroPadding {
21117                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
21118                });
21119            }
21120            fidl::decode!(
21121                fidl::encoding::Vector<
21122                    fidl::encoding::HandleType<
21123                        fidl::Vmo,
21124                        { fidl::ObjectType::VMO.into_raw() },
21125                        2147483648,
21126                    >,
21127                    16,
21128                >,
21129                fidl::encoding::DefaultFuchsiaResourceDialect,
21130                &mut self.buffers,
21131                decoder,
21132                offset + 0,
21133                _depth
21134            )?;
21135            fidl::decode!(
21136                AudioStreamType,
21137                fidl::encoding::DefaultFuchsiaResourceDialect,
21138                &mut self.stream_type,
21139                decoder,
21140                offset + 16,
21141                _depth
21142            )?;
21143            fidl::decode!(
21144                fidl::encoding::Boxed<Compression>,
21145                fidl::encoding::DefaultFuchsiaResourceDialect,
21146                &mut self.compression,
21147                decoder,
21148                offset + 32,
21149                _depth
21150            )?;
21151            fidl::decode!(
21152                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21153                fidl::encoding::DefaultFuchsiaResourceDialect,
21154                &mut self.stream_sink_request,
21155                decoder,
21156                offset + 40,
21157                _depth
21158            )?;
21159            Ok(())
21160        }
21161    }
21162
21163    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
21164        type Borrowed<'a> = &'a mut Self;
21165        fn take_or_borrow<'a>(
21166            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21167        ) -> Self::Borrowed<'a> {
21168            value
21169        }
21170    }
21171
21172    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
21173        type Owned = Self;
21174
21175        #[inline(always)]
21176        fn inline_align(_context: fidl::encoding::Context) -> usize {
21177            8
21178        }
21179
21180        #[inline(always)]
21181        fn inline_size(_context: fidl::encoding::Context) -> usize {
21182            24
21183        }
21184    }
21185
21186    unsafe impl
21187        fidl::encoding::Encode<
21188            AudioCoreBindUsageVolumeControl2Request,
21189            fidl::encoding::DefaultFuchsiaResourceDialect,
21190        > for &mut AudioCoreBindUsageVolumeControl2Request
21191    {
21192        #[inline]
21193        unsafe fn encode(
21194            self,
21195            encoder: &mut fidl::encoding::Encoder<
21196                '_,
21197                fidl::encoding::DefaultFuchsiaResourceDialect,
21198            >,
21199            offset: usize,
21200            _depth: fidl::encoding::Depth,
21201        ) -> fidl::Result<()> {
21202            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21203            // Delegate to tuple encoding.
21204            fidl::encoding::Encode::<
21205                AudioCoreBindUsageVolumeControl2Request,
21206                fidl::encoding::DefaultFuchsiaResourceDialect,
21207            >::encode(
21208                (
21209                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21210                    <fidl::encoding::Endpoint<
21211                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21212                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21213                        &mut self.volume_control,
21214                    ),
21215                ),
21216                encoder,
21217                offset,
21218                _depth,
21219            )
21220        }
21221    }
21222    unsafe impl<
21223        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
21224        T1: fidl::encoding::Encode<
21225                fidl::encoding::Endpoint<
21226                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21227                >,
21228                fidl::encoding::DefaultFuchsiaResourceDialect,
21229            >,
21230    >
21231        fidl::encoding::Encode<
21232            AudioCoreBindUsageVolumeControl2Request,
21233            fidl::encoding::DefaultFuchsiaResourceDialect,
21234        > for (T0, T1)
21235    {
21236        #[inline]
21237        unsafe fn encode(
21238            self,
21239            encoder: &mut fidl::encoding::Encoder<
21240                '_,
21241                fidl::encoding::DefaultFuchsiaResourceDialect,
21242            >,
21243            offset: usize,
21244            depth: fidl::encoding::Depth,
21245        ) -> fidl::Result<()> {
21246            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21247            // Zero out padding regions. There's no need to apply masks
21248            // because the unmasked parts will be overwritten by fields.
21249            unsafe {
21250                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21251                (ptr as *mut u64).write_unaligned(0);
21252            }
21253            // Write the fields.
21254            self.0.encode(encoder, offset + 0, depth)?;
21255            self.1.encode(encoder, offset + 16, depth)?;
21256            Ok(())
21257        }
21258    }
21259
21260    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21261        for AudioCoreBindUsageVolumeControl2Request
21262    {
21263        #[inline(always)]
21264        fn new_empty() -> Self {
21265            Self {
21266                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
21267                volume_control: fidl::new_empty!(
21268                    fidl::encoding::Endpoint<
21269                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21270                    >,
21271                    fidl::encoding::DefaultFuchsiaResourceDialect
21272                ),
21273            }
21274        }
21275
21276        #[inline]
21277        unsafe fn decode(
21278            &mut self,
21279            decoder: &mut fidl::encoding::Decoder<
21280                '_,
21281                fidl::encoding::DefaultFuchsiaResourceDialect,
21282            >,
21283            offset: usize,
21284            _depth: fidl::encoding::Depth,
21285        ) -> fidl::Result<()> {
21286            decoder.debug_check_bounds::<Self>(offset);
21287            // Verify that padding bytes are zero.
21288            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21289            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21290            let mask = 0xffffffff00000000u64;
21291            let maskedval = padval & mask;
21292            if maskedval != 0 {
21293                return Err(fidl::Error::NonZeroPadding {
21294                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21295                });
21296            }
21297            fidl::decode!(
21298                Usage2,
21299                fidl::encoding::DefaultFuchsiaResourceDialect,
21300                &mut self.usage,
21301                decoder,
21302                offset + 0,
21303                _depth
21304            )?;
21305            fidl::decode!(
21306                fidl::encoding::Endpoint<
21307                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21308                >,
21309                fidl::encoding::DefaultFuchsiaResourceDialect,
21310                &mut self.volume_control,
21311                decoder,
21312                offset + 16,
21313                _depth
21314            )?;
21315            Ok(())
21316        }
21317    }
21318
21319    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
21320        type Borrowed<'a> = &'a mut Self;
21321        fn take_or_borrow<'a>(
21322            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21323        ) -> Self::Borrowed<'a> {
21324            value
21325        }
21326    }
21327
21328    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
21329        type Owned = Self;
21330
21331        #[inline(always)]
21332        fn inline_align(_context: fidl::encoding::Context) -> usize {
21333            8
21334        }
21335
21336        #[inline(always)]
21337        fn inline_size(_context: fidl::encoding::Context) -> usize {
21338            24
21339        }
21340    }
21341
21342    unsafe impl
21343        fidl::encoding::Encode<
21344            AudioCoreBindUsageVolumeControlRequest,
21345            fidl::encoding::DefaultFuchsiaResourceDialect,
21346        > for &mut AudioCoreBindUsageVolumeControlRequest
21347    {
21348        #[inline]
21349        unsafe fn encode(
21350            self,
21351            encoder: &mut fidl::encoding::Encoder<
21352                '_,
21353                fidl::encoding::DefaultFuchsiaResourceDialect,
21354            >,
21355            offset: usize,
21356            _depth: fidl::encoding::Depth,
21357        ) -> fidl::Result<()> {
21358            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21359            // Delegate to tuple encoding.
21360            fidl::encoding::Encode::<
21361                AudioCoreBindUsageVolumeControlRequest,
21362                fidl::encoding::DefaultFuchsiaResourceDialect,
21363            >::encode(
21364                (
21365                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21366                    <fidl::encoding::Endpoint<
21367                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21368                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21369                        &mut self.volume_control,
21370                    ),
21371                ),
21372                encoder,
21373                offset,
21374                _depth,
21375            )
21376        }
21377    }
21378    unsafe impl<
21379        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
21380        T1: fidl::encoding::Encode<
21381                fidl::encoding::Endpoint<
21382                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21383                >,
21384                fidl::encoding::DefaultFuchsiaResourceDialect,
21385            >,
21386    >
21387        fidl::encoding::Encode<
21388            AudioCoreBindUsageVolumeControlRequest,
21389            fidl::encoding::DefaultFuchsiaResourceDialect,
21390        > for (T0, T1)
21391    {
21392        #[inline]
21393        unsafe fn encode(
21394            self,
21395            encoder: &mut fidl::encoding::Encoder<
21396                '_,
21397                fidl::encoding::DefaultFuchsiaResourceDialect,
21398            >,
21399            offset: usize,
21400            depth: fidl::encoding::Depth,
21401        ) -> fidl::Result<()> {
21402            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21403            // Zero out padding regions. There's no need to apply masks
21404            // because the unmasked parts will be overwritten by fields.
21405            unsafe {
21406                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21407                (ptr as *mut u64).write_unaligned(0);
21408            }
21409            // Write the fields.
21410            self.0.encode(encoder, offset + 0, depth)?;
21411            self.1.encode(encoder, offset + 16, depth)?;
21412            Ok(())
21413        }
21414    }
21415
21416    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21417        for AudioCoreBindUsageVolumeControlRequest
21418    {
21419        #[inline(always)]
21420        fn new_empty() -> Self {
21421            Self {
21422                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
21423                volume_control: fidl::new_empty!(
21424                    fidl::encoding::Endpoint<
21425                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21426                    >,
21427                    fidl::encoding::DefaultFuchsiaResourceDialect
21428                ),
21429            }
21430        }
21431
21432        #[inline]
21433        unsafe fn decode(
21434            &mut self,
21435            decoder: &mut fidl::encoding::Decoder<
21436                '_,
21437                fidl::encoding::DefaultFuchsiaResourceDialect,
21438            >,
21439            offset: usize,
21440            _depth: fidl::encoding::Depth,
21441        ) -> fidl::Result<()> {
21442            decoder.debug_check_bounds::<Self>(offset);
21443            // Verify that padding bytes are zero.
21444            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21445            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21446            let mask = 0xffffffff00000000u64;
21447            let maskedval = padval & mask;
21448            if maskedval != 0 {
21449                return Err(fidl::Error::NonZeroPadding {
21450                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21451                });
21452            }
21453            fidl::decode!(
21454                Usage,
21455                fidl::encoding::DefaultFuchsiaResourceDialect,
21456                &mut self.usage,
21457                decoder,
21458                offset + 0,
21459                _depth
21460            )?;
21461            fidl::decode!(
21462                fidl::encoding::Endpoint<
21463                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21464                >,
21465                fidl::encoding::DefaultFuchsiaResourceDialect,
21466                &mut self.volume_control,
21467                decoder,
21468                offset + 16,
21469                _depth
21470            )?;
21471            Ok(())
21472        }
21473    }
21474
21475    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
21476        type Borrowed<'a> = &'a mut Self;
21477        fn take_or_borrow<'a>(
21478            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21479        ) -> Self::Borrowed<'a> {
21480            value
21481        }
21482    }
21483
21484    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
21485        type Owned = Self;
21486
21487        #[inline(always)]
21488        fn inline_align(_context: fidl::encoding::Context) -> usize {
21489            4
21490        }
21491
21492        #[inline(always)]
21493        fn inline_size(_context: fidl::encoding::Context) -> usize {
21494            8
21495        }
21496    }
21497
21498    unsafe impl
21499        fidl::encoding::Encode<
21500            AudioCoreCreateAudioCapturerRequest,
21501            fidl::encoding::DefaultFuchsiaResourceDialect,
21502        > for &mut AudioCoreCreateAudioCapturerRequest
21503    {
21504        #[inline]
21505        unsafe fn encode(
21506            self,
21507            encoder: &mut fidl::encoding::Encoder<
21508                '_,
21509                fidl::encoding::DefaultFuchsiaResourceDialect,
21510            >,
21511            offset: usize,
21512            _depth: fidl::encoding::Depth,
21513        ) -> fidl::Result<()> {
21514            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21515            // Delegate to tuple encoding.
21516            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21517                (
21518                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21519                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
21520                ),
21521                encoder, offset, _depth
21522            )
21523        }
21524    }
21525    unsafe impl<
21526        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21527        T1: fidl::encoding::Encode<
21528                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21529                fidl::encoding::DefaultFuchsiaResourceDialect,
21530            >,
21531    >
21532        fidl::encoding::Encode<
21533            AudioCoreCreateAudioCapturerRequest,
21534            fidl::encoding::DefaultFuchsiaResourceDialect,
21535        > for (T0, T1)
21536    {
21537        #[inline]
21538        unsafe fn encode(
21539            self,
21540            encoder: &mut fidl::encoding::Encoder<
21541                '_,
21542                fidl::encoding::DefaultFuchsiaResourceDialect,
21543            >,
21544            offset: usize,
21545            depth: fidl::encoding::Depth,
21546        ) -> fidl::Result<()> {
21547            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21548            // Zero out padding regions. There's no need to apply masks
21549            // because the unmasked parts will be overwritten by fields.
21550            unsafe {
21551                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
21552                (ptr as *mut u32).write_unaligned(0);
21553            }
21554            // Write the fields.
21555            self.0.encode(encoder, offset + 0, depth)?;
21556            self.1.encode(encoder, offset + 4, depth)?;
21557            Ok(())
21558        }
21559    }
21560
21561    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21562        for AudioCoreCreateAudioCapturerRequest
21563    {
21564        #[inline(always)]
21565        fn new_empty() -> Self {
21566            Self {
21567                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21568                audio_in_request: fidl::new_empty!(
21569                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21570                    fidl::encoding::DefaultFuchsiaResourceDialect
21571                ),
21572            }
21573        }
21574
21575        #[inline]
21576        unsafe fn decode(
21577            &mut self,
21578            decoder: &mut fidl::encoding::Decoder<
21579                '_,
21580                fidl::encoding::DefaultFuchsiaResourceDialect,
21581            >,
21582            offset: usize,
21583            _depth: fidl::encoding::Depth,
21584        ) -> fidl::Result<()> {
21585            decoder.debug_check_bounds::<Self>(offset);
21586            // Verify that padding bytes are zero.
21587            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
21588            let padval = unsafe { (ptr as *const u32).read_unaligned() };
21589            let mask = 0xffffff00u32;
21590            let maskedval = padval & mask;
21591            if maskedval != 0 {
21592                return Err(fidl::Error::NonZeroPadding {
21593                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
21594                });
21595            }
21596            fidl::decode!(
21597                bool,
21598                fidl::encoding::DefaultFuchsiaResourceDialect,
21599                &mut self.loopback,
21600                decoder,
21601                offset + 0,
21602                _depth
21603            )?;
21604            fidl::decode!(
21605                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21606                fidl::encoding::DefaultFuchsiaResourceDialect,
21607                &mut self.audio_in_request,
21608                decoder,
21609                offset + 4,
21610                _depth
21611            )?;
21612            Ok(())
21613        }
21614    }
21615
21616    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21617        type Borrowed<'a> = &'a mut Self;
21618        fn take_or_borrow<'a>(
21619            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21620        ) -> Self::Borrowed<'a> {
21621            value
21622        }
21623    }
21624
21625    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21626        type Owned = Self;
21627
21628        #[inline(always)]
21629        fn inline_align(_context: fidl::encoding::Context) -> usize {
21630            8
21631        }
21632
21633        #[inline(always)]
21634        fn inline_size(_context: fidl::encoding::Context) -> usize {
21635            40
21636        }
21637    }
21638
21639    unsafe impl
21640        fidl::encoding::Encode<
21641            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21642            fidl::encoding::DefaultFuchsiaResourceDialect,
21643        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
21644    {
21645        #[inline]
21646        unsafe fn encode(
21647            self,
21648            encoder: &mut fidl::encoding::Encoder<
21649                '_,
21650                fidl::encoding::DefaultFuchsiaResourceDialect,
21651            >,
21652            offset: usize,
21653            _depth: fidl::encoding::Depth,
21654        ) -> fidl::Result<()> {
21655            encoder
21656                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21657            // Delegate to tuple encoding.
21658            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21659                (
21660                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21661                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
21662                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21663                ),
21664                encoder, offset, _depth
21665            )
21666        }
21667    }
21668    unsafe impl<
21669        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21670        T1: fidl::encoding::Encode<
21671                AudioCapturerConfiguration,
21672                fidl::encoding::DefaultFuchsiaResourceDialect,
21673            >,
21674        T2: fidl::encoding::Encode<
21675                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21676                fidl::encoding::DefaultFuchsiaResourceDialect,
21677            >,
21678    >
21679        fidl::encoding::Encode<
21680            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21681            fidl::encoding::DefaultFuchsiaResourceDialect,
21682        > for (T0, T1, T2)
21683    {
21684        #[inline]
21685        unsafe fn encode(
21686            self,
21687            encoder: &mut fidl::encoding::Encoder<
21688                '_,
21689                fidl::encoding::DefaultFuchsiaResourceDialect,
21690            >,
21691            offset: usize,
21692            depth: fidl::encoding::Depth,
21693        ) -> fidl::Result<()> {
21694            encoder
21695                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21696            // Zero out padding regions. There's no need to apply masks
21697            // because the unmasked parts will be overwritten by fields.
21698            unsafe {
21699                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
21700                (ptr as *mut u64).write_unaligned(0);
21701            }
21702            unsafe {
21703                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21704                (ptr as *mut u64).write_unaligned(0);
21705            }
21706            // Write the fields.
21707            self.0.encode(encoder, offset + 0, depth)?;
21708            self.1.encode(encoder, offset + 16, depth)?;
21709            self.2.encode(encoder, offset + 32, depth)?;
21710            Ok(())
21711        }
21712    }
21713
21714    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21715        for AudioCoreCreateAudioCapturerWithConfigurationRequest
21716    {
21717        #[inline(always)]
21718        fn new_empty() -> Self {
21719            Self {
21720                stream_type: fidl::new_empty!(
21721                    AudioStreamType,
21722                    fidl::encoding::DefaultFuchsiaResourceDialect
21723                ),
21724                configuration: fidl::new_empty!(
21725                    AudioCapturerConfiguration,
21726                    fidl::encoding::DefaultFuchsiaResourceDialect
21727                ),
21728                audio_capturer_request: fidl::new_empty!(
21729                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21730                    fidl::encoding::DefaultFuchsiaResourceDialect
21731                ),
21732            }
21733        }
21734
21735        #[inline]
21736        unsafe fn decode(
21737            &mut self,
21738            decoder: &mut fidl::encoding::Decoder<
21739                '_,
21740                fidl::encoding::DefaultFuchsiaResourceDialect,
21741            >,
21742            offset: usize,
21743            _depth: fidl::encoding::Depth,
21744        ) -> fidl::Result<()> {
21745            decoder.debug_check_bounds::<Self>(offset);
21746            // Verify that padding bytes are zero.
21747            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21748            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21749            let mask = 0xffffffff00000000u64;
21750            let maskedval = padval & mask;
21751            if maskedval != 0 {
21752                return Err(fidl::Error::NonZeroPadding {
21753                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21754                });
21755            }
21756            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21757            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21758            let mask = 0xffffffff00000000u64;
21759            let maskedval = padval & mask;
21760            if maskedval != 0 {
21761                return Err(fidl::Error::NonZeroPadding {
21762                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21763                });
21764            }
21765            fidl::decode!(
21766                AudioStreamType,
21767                fidl::encoding::DefaultFuchsiaResourceDialect,
21768                &mut self.stream_type,
21769                decoder,
21770                offset + 0,
21771                _depth
21772            )?;
21773            fidl::decode!(
21774                AudioCapturerConfiguration,
21775                fidl::encoding::DefaultFuchsiaResourceDialect,
21776                &mut self.configuration,
21777                decoder,
21778                offset + 16,
21779                _depth
21780            )?;
21781            fidl::decode!(
21782                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21783                fidl::encoding::DefaultFuchsiaResourceDialect,
21784                &mut self.audio_capturer_request,
21785                decoder,
21786                offset + 32,
21787                _depth
21788            )?;
21789            Ok(())
21790        }
21791    }
21792
21793    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
21794        type Borrowed<'a> = &'a mut Self;
21795        fn take_or_borrow<'a>(
21796            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21797        ) -> Self::Borrowed<'a> {
21798            value
21799        }
21800    }
21801
21802    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
21803        type Owned = Self;
21804
21805        #[inline(always)]
21806        fn inline_align(_context: fidl::encoding::Context) -> usize {
21807            4
21808        }
21809
21810        #[inline(always)]
21811        fn inline_size(_context: fidl::encoding::Context) -> usize {
21812            4
21813        }
21814    }
21815
21816    unsafe impl
21817        fidl::encoding::Encode<
21818            AudioCoreCreateAudioRendererRequest,
21819            fidl::encoding::DefaultFuchsiaResourceDialect,
21820        > for &mut AudioCoreCreateAudioRendererRequest
21821    {
21822        #[inline]
21823        unsafe fn encode(
21824            self,
21825            encoder: &mut fidl::encoding::Encoder<
21826                '_,
21827                fidl::encoding::DefaultFuchsiaResourceDialect,
21828            >,
21829            offset: usize,
21830            _depth: fidl::encoding::Depth,
21831        ) -> fidl::Result<()> {
21832            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21833            // Delegate to tuple encoding.
21834            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21835                (
21836                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
21837                ),
21838                encoder, offset, _depth
21839            )
21840        }
21841    }
21842    unsafe impl<
21843        T0: fidl::encoding::Encode<
21844                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21845                fidl::encoding::DefaultFuchsiaResourceDialect,
21846            >,
21847    >
21848        fidl::encoding::Encode<
21849            AudioCoreCreateAudioRendererRequest,
21850            fidl::encoding::DefaultFuchsiaResourceDialect,
21851        > for (T0,)
21852    {
21853        #[inline]
21854        unsafe fn encode(
21855            self,
21856            encoder: &mut fidl::encoding::Encoder<
21857                '_,
21858                fidl::encoding::DefaultFuchsiaResourceDialect,
21859            >,
21860            offset: usize,
21861            depth: fidl::encoding::Depth,
21862        ) -> fidl::Result<()> {
21863            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21864            // Zero out padding regions. There's no need to apply masks
21865            // because the unmasked parts will be overwritten by fields.
21866            // Write the fields.
21867            self.0.encode(encoder, offset + 0, depth)?;
21868            Ok(())
21869        }
21870    }
21871
21872    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21873        for AudioCoreCreateAudioRendererRequest
21874    {
21875        #[inline(always)]
21876        fn new_empty() -> Self {
21877            Self {
21878                audio_out_request: fidl::new_empty!(
21879                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21880                    fidl::encoding::DefaultFuchsiaResourceDialect
21881                ),
21882            }
21883        }
21884
21885        #[inline]
21886        unsafe fn decode(
21887            &mut self,
21888            decoder: &mut fidl::encoding::Decoder<
21889                '_,
21890                fidl::encoding::DefaultFuchsiaResourceDialect,
21891            >,
21892            offset: usize,
21893            _depth: fidl::encoding::Depth,
21894        ) -> fidl::Result<()> {
21895            decoder.debug_check_bounds::<Self>(offset);
21896            // Verify that padding bytes are zero.
21897            fidl::decode!(
21898                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21899                fidl::encoding::DefaultFuchsiaResourceDialect,
21900                &mut self.audio_out_request,
21901                decoder,
21902                offset + 0,
21903                _depth
21904            )?;
21905            Ok(())
21906        }
21907    }
21908
21909    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
21910        type Borrowed<'a> = &'a mut Self;
21911        fn take_or_borrow<'a>(
21912            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21913        ) -> Self::Borrowed<'a> {
21914            value
21915        }
21916    }
21917
21918    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
21919        type Owned = Self;
21920
21921        #[inline(always)]
21922        fn inline_align(_context: fidl::encoding::Context) -> usize {
21923            4
21924        }
21925
21926        #[inline(always)]
21927        fn inline_size(_context: fidl::encoding::Context) -> usize {
21928            8
21929        }
21930    }
21931
21932    unsafe impl
21933        fidl::encoding::Encode<
21934            AudioCreateAudioCapturerRequest,
21935            fidl::encoding::DefaultFuchsiaResourceDialect,
21936        > for &mut AudioCreateAudioCapturerRequest
21937    {
21938        #[inline]
21939        unsafe fn encode(
21940            self,
21941            encoder: &mut fidl::encoding::Encoder<
21942                '_,
21943                fidl::encoding::DefaultFuchsiaResourceDialect,
21944            >,
21945            offset: usize,
21946            _depth: fidl::encoding::Depth,
21947        ) -> fidl::Result<()> {
21948            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
21949            // Delegate to tuple encoding.
21950            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21951                (
21952                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21953                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21954                ),
21955                encoder, offset, _depth
21956            )
21957        }
21958    }
21959    unsafe impl<
21960        T0: fidl::encoding::Encode<
21961                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21962                fidl::encoding::DefaultFuchsiaResourceDialect,
21963            >,
21964        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21965    >
21966        fidl::encoding::Encode<
21967            AudioCreateAudioCapturerRequest,
21968            fidl::encoding::DefaultFuchsiaResourceDialect,
21969        > for (T0, T1)
21970    {
21971        #[inline]
21972        unsafe fn encode(
21973            self,
21974            encoder: &mut fidl::encoding::Encoder<
21975                '_,
21976                fidl::encoding::DefaultFuchsiaResourceDialect,
21977            >,
21978            offset: usize,
21979            depth: fidl::encoding::Depth,
21980        ) -> fidl::Result<()> {
21981            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
21982            // Zero out padding regions. There's no need to apply masks
21983            // because the unmasked parts will be overwritten by fields.
21984            unsafe {
21985                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
21986                (ptr as *mut u32).write_unaligned(0);
21987            }
21988            // Write the fields.
21989            self.0.encode(encoder, offset + 0, depth)?;
21990            self.1.encode(encoder, offset + 4, depth)?;
21991            Ok(())
21992        }
21993    }
21994
21995    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21996        for AudioCreateAudioCapturerRequest
21997    {
21998        #[inline(always)]
21999        fn new_empty() -> Self {
22000            Self {
22001                audio_capturer_request: fidl::new_empty!(
22002                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22003                    fidl::encoding::DefaultFuchsiaResourceDialect
22004                ),
22005                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22006            }
22007        }
22008
22009        #[inline]
22010        unsafe fn decode(
22011            &mut self,
22012            decoder: &mut fidl::encoding::Decoder<
22013                '_,
22014                fidl::encoding::DefaultFuchsiaResourceDialect,
22015            >,
22016            offset: usize,
22017            _depth: fidl::encoding::Depth,
22018        ) -> fidl::Result<()> {
22019            decoder.debug_check_bounds::<Self>(offset);
22020            // Verify that padding bytes are zero.
22021            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
22022            let padval = unsafe { (ptr as *const u32).read_unaligned() };
22023            let mask = 0xffffff00u32;
22024            let maskedval = padval & mask;
22025            if maskedval != 0 {
22026                return Err(fidl::Error::NonZeroPadding {
22027                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
22028                });
22029            }
22030            fidl::decode!(
22031                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22032                fidl::encoding::DefaultFuchsiaResourceDialect,
22033                &mut self.audio_capturer_request,
22034                decoder,
22035                offset + 0,
22036                _depth
22037            )?;
22038            fidl::decode!(
22039                bool,
22040                fidl::encoding::DefaultFuchsiaResourceDialect,
22041                &mut self.loopback,
22042                decoder,
22043                offset + 4,
22044                _depth
22045            )?;
22046            Ok(())
22047        }
22048    }
22049
22050    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
22051        type Borrowed<'a> = &'a mut Self;
22052        fn take_or_borrow<'a>(
22053            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22054        ) -> Self::Borrowed<'a> {
22055            value
22056        }
22057    }
22058
22059    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
22060        type Owned = Self;
22061
22062        #[inline(always)]
22063        fn inline_align(_context: fidl::encoding::Context) -> usize {
22064            4
22065        }
22066
22067        #[inline(always)]
22068        fn inline_size(_context: fidl::encoding::Context) -> usize {
22069            4
22070        }
22071    }
22072
22073    unsafe impl
22074        fidl::encoding::Encode<
22075            AudioCreateAudioRendererRequest,
22076            fidl::encoding::DefaultFuchsiaResourceDialect,
22077        > for &mut AudioCreateAudioRendererRequest
22078    {
22079        #[inline]
22080        unsafe fn encode(
22081            self,
22082            encoder: &mut fidl::encoding::Encoder<
22083                '_,
22084                fidl::encoding::DefaultFuchsiaResourceDialect,
22085            >,
22086            offset: usize,
22087            _depth: fidl::encoding::Depth,
22088        ) -> fidl::Result<()> {
22089            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22090            // Delegate to tuple encoding.
22091            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22092                (
22093                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
22094                ),
22095                encoder, offset, _depth
22096            )
22097        }
22098    }
22099    unsafe impl<
22100        T0: fidl::encoding::Encode<
22101                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22102                fidl::encoding::DefaultFuchsiaResourceDialect,
22103            >,
22104    >
22105        fidl::encoding::Encode<
22106            AudioCreateAudioRendererRequest,
22107            fidl::encoding::DefaultFuchsiaResourceDialect,
22108        > for (T0,)
22109    {
22110        #[inline]
22111        unsafe fn encode(
22112            self,
22113            encoder: &mut fidl::encoding::Encoder<
22114                '_,
22115                fidl::encoding::DefaultFuchsiaResourceDialect,
22116            >,
22117            offset: usize,
22118            depth: fidl::encoding::Depth,
22119        ) -> fidl::Result<()> {
22120            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22121            // Zero out padding regions. There's no need to apply masks
22122            // because the unmasked parts will be overwritten by fields.
22123            // Write the fields.
22124            self.0.encode(encoder, offset + 0, depth)?;
22125            Ok(())
22126        }
22127    }
22128
22129    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22130        for AudioCreateAudioRendererRequest
22131    {
22132        #[inline(always)]
22133        fn new_empty() -> Self {
22134            Self {
22135                audio_renderer_request: fidl::new_empty!(
22136                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22137                    fidl::encoding::DefaultFuchsiaResourceDialect
22138                ),
22139            }
22140        }
22141
22142        #[inline]
22143        unsafe fn decode(
22144            &mut self,
22145            decoder: &mut fidl::encoding::Decoder<
22146                '_,
22147                fidl::encoding::DefaultFuchsiaResourceDialect,
22148            >,
22149            offset: usize,
22150            _depth: fidl::encoding::Depth,
22151        ) -> fidl::Result<()> {
22152            decoder.debug_check_bounds::<Self>(offset);
22153            // Verify that padding bytes are zero.
22154            fidl::decode!(
22155                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22156                fidl::encoding::DefaultFuchsiaResourceDialect,
22157                &mut self.audio_renderer_request,
22158                decoder,
22159                offset + 0,
22160                _depth
22161            )?;
22162            Ok(())
22163        }
22164    }
22165
22166    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22167        type Borrowed<'a> = &'a mut Self;
22168        fn take_or_borrow<'a>(
22169            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22170        ) -> Self::Borrowed<'a> {
22171            value
22172        }
22173    }
22174
22175    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22176        type Owned = Self;
22177
22178        #[inline(always)]
22179        fn inline_align(_context: fidl::encoding::Context) -> usize {
22180            8
22181        }
22182
22183        #[inline(always)]
22184        fn inline_size(_context: fidl::encoding::Context) -> usize {
22185            24
22186        }
22187    }
22188
22189    unsafe impl
22190        fidl::encoding::Encode<
22191            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22192            fidl::encoding::DefaultFuchsiaResourceDialect,
22193        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
22194    {
22195        #[inline]
22196        unsafe fn encode(
22197            self,
22198            encoder: &mut fidl::encoding::Encoder<
22199                '_,
22200                fidl::encoding::DefaultFuchsiaResourceDialect,
22201            >,
22202            offset: usize,
22203            _depth: fidl::encoding::Depth,
22204        ) -> fidl::Result<()> {
22205            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22206            // Delegate to tuple encoding.
22207            fidl::encoding::Encode::<
22208                AudioDeviceEnumeratorAddDeviceByChannelRequest,
22209                fidl::encoding::DefaultFuchsiaResourceDialect,
22210            >::encode(
22211                (
22212                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
22213                        &self.device_name,
22214                    ),
22215                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
22216                    <fidl::encoding::Endpoint<
22217                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22218                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22219                        &mut self.channel
22220                    ),
22221                ),
22222                encoder,
22223                offset,
22224                _depth,
22225            )
22226        }
22227    }
22228    unsafe impl<
22229        T0: fidl::encoding::Encode<
22230                fidl::encoding::BoundedString<256>,
22231                fidl::encoding::DefaultFuchsiaResourceDialect,
22232            >,
22233        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22234        T2: fidl::encoding::Encode<
22235                fidl::encoding::Endpoint<
22236                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22237                >,
22238                fidl::encoding::DefaultFuchsiaResourceDialect,
22239            >,
22240    >
22241        fidl::encoding::Encode<
22242            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22243            fidl::encoding::DefaultFuchsiaResourceDialect,
22244        > for (T0, T1, T2)
22245    {
22246        #[inline]
22247        unsafe fn encode(
22248            self,
22249            encoder: &mut fidl::encoding::Encoder<
22250                '_,
22251                fidl::encoding::DefaultFuchsiaResourceDialect,
22252            >,
22253            offset: usize,
22254            depth: fidl::encoding::Depth,
22255        ) -> fidl::Result<()> {
22256            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22257            // Zero out padding regions. There's no need to apply masks
22258            // because the unmasked parts will be overwritten by fields.
22259            unsafe {
22260                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22261                (ptr as *mut u64).write_unaligned(0);
22262            }
22263            // Write the fields.
22264            self.0.encode(encoder, offset + 0, depth)?;
22265            self.1.encode(encoder, offset + 16, depth)?;
22266            self.2.encode(encoder, offset + 20, depth)?;
22267            Ok(())
22268        }
22269    }
22270
22271    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22272        for AudioDeviceEnumeratorAddDeviceByChannelRequest
22273    {
22274        #[inline(always)]
22275        fn new_empty() -> Self {
22276            Self {
22277                device_name: fidl::new_empty!(
22278                    fidl::encoding::BoundedString<256>,
22279                    fidl::encoding::DefaultFuchsiaResourceDialect
22280                ),
22281                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22282                channel: fidl::new_empty!(
22283                    fidl::encoding::Endpoint<
22284                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22285                    >,
22286                    fidl::encoding::DefaultFuchsiaResourceDialect
22287                ),
22288            }
22289        }
22290
22291        #[inline]
22292        unsafe fn decode(
22293            &mut self,
22294            decoder: &mut fidl::encoding::Decoder<
22295                '_,
22296                fidl::encoding::DefaultFuchsiaResourceDialect,
22297            >,
22298            offset: usize,
22299            _depth: fidl::encoding::Depth,
22300        ) -> fidl::Result<()> {
22301            decoder.debug_check_bounds::<Self>(offset);
22302            // Verify that padding bytes are zero.
22303            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22304            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22305            let mask = 0xffffff00u64;
22306            let maskedval = padval & mask;
22307            if maskedval != 0 {
22308                return Err(fidl::Error::NonZeroPadding {
22309                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22310                });
22311            }
22312            fidl::decode!(
22313                fidl::encoding::BoundedString<256>,
22314                fidl::encoding::DefaultFuchsiaResourceDialect,
22315                &mut self.device_name,
22316                decoder,
22317                offset + 0,
22318                _depth
22319            )?;
22320            fidl::decode!(
22321                bool,
22322                fidl::encoding::DefaultFuchsiaResourceDialect,
22323                &mut self.is_input,
22324                decoder,
22325                offset + 16,
22326                _depth
22327            )?;
22328            fidl::decode!(
22329                fidl::encoding::Endpoint<
22330                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22331                >,
22332                fidl::encoding::DefaultFuchsiaResourceDialect,
22333                &mut self.channel,
22334                decoder,
22335                offset + 20,
22336                _depth
22337            )?;
22338            Ok(())
22339        }
22340    }
22341
22342    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
22343        type Borrowed<'a> = &'a mut Self;
22344        fn take_or_borrow<'a>(
22345            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22346        ) -> Self::Borrowed<'a> {
22347            value
22348        }
22349    }
22350
22351    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
22352        type Owned = Self;
22353
22354        #[inline(always)]
22355        fn inline_align(_context: fidl::encoding::Context) -> usize {
22356            4
22357        }
22358
22359        #[inline(always)]
22360        fn inline_size(_context: fidl::encoding::Context) -> usize {
22361            4
22362        }
22363    }
22364
22365    unsafe impl
22366        fidl::encoding::Encode<
22367            AudioRendererBindGainControlRequest,
22368            fidl::encoding::DefaultFuchsiaResourceDialect,
22369        > for &mut AudioRendererBindGainControlRequest
22370    {
22371        #[inline]
22372        unsafe fn encode(
22373            self,
22374            encoder: &mut fidl::encoding::Encoder<
22375                '_,
22376                fidl::encoding::DefaultFuchsiaResourceDialect,
22377            >,
22378            offset: usize,
22379            _depth: fidl::encoding::Depth,
22380        ) -> fidl::Result<()> {
22381            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22382            // Delegate to tuple encoding.
22383            fidl::encoding::Encode::<
22384                AudioRendererBindGainControlRequest,
22385                fidl::encoding::DefaultFuchsiaResourceDialect,
22386            >::encode(
22387                (<fidl::encoding::Endpoint<
22388                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22389                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22390                    &mut self.gain_control_request,
22391                ),),
22392                encoder,
22393                offset,
22394                _depth,
22395            )
22396        }
22397    }
22398    unsafe impl<
22399        T0: fidl::encoding::Encode<
22400                fidl::encoding::Endpoint<
22401                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22402                >,
22403                fidl::encoding::DefaultFuchsiaResourceDialect,
22404            >,
22405    >
22406        fidl::encoding::Encode<
22407            AudioRendererBindGainControlRequest,
22408            fidl::encoding::DefaultFuchsiaResourceDialect,
22409        > for (T0,)
22410    {
22411        #[inline]
22412        unsafe fn encode(
22413            self,
22414            encoder: &mut fidl::encoding::Encoder<
22415                '_,
22416                fidl::encoding::DefaultFuchsiaResourceDialect,
22417            >,
22418            offset: usize,
22419            depth: fidl::encoding::Depth,
22420        ) -> fidl::Result<()> {
22421            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22422            // Zero out padding regions. There's no need to apply masks
22423            // because the unmasked parts will be overwritten by fields.
22424            // Write the fields.
22425            self.0.encode(encoder, offset + 0, depth)?;
22426            Ok(())
22427        }
22428    }
22429
22430    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22431        for AudioRendererBindGainControlRequest
22432    {
22433        #[inline(always)]
22434        fn new_empty() -> Self {
22435            Self {
22436                gain_control_request: fidl::new_empty!(
22437                    fidl::encoding::Endpoint<
22438                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22439                    >,
22440                    fidl::encoding::DefaultFuchsiaResourceDialect
22441                ),
22442            }
22443        }
22444
22445        #[inline]
22446        unsafe fn decode(
22447            &mut self,
22448            decoder: &mut fidl::encoding::Decoder<
22449                '_,
22450                fidl::encoding::DefaultFuchsiaResourceDialect,
22451            >,
22452            offset: usize,
22453            _depth: fidl::encoding::Depth,
22454        ) -> fidl::Result<()> {
22455            decoder.debug_check_bounds::<Self>(offset);
22456            // Verify that padding bytes are zero.
22457            fidl::decode!(
22458                fidl::encoding::Endpoint<
22459                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22460                >,
22461                fidl::encoding::DefaultFuchsiaResourceDialect,
22462                &mut self.gain_control_request,
22463                decoder,
22464                offset + 0,
22465                _depth
22466            )?;
22467            Ok(())
22468        }
22469    }
22470
22471    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
22472        type Borrowed<'a> = &'a mut Self;
22473        fn take_or_borrow<'a>(
22474            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22475        ) -> Self::Borrowed<'a> {
22476            value
22477        }
22478    }
22479
22480    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
22481        type Owned = Self;
22482
22483        #[inline(always)]
22484        fn inline_align(_context: fidl::encoding::Context) -> usize {
22485            4
22486        }
22487
22488        #[inline(always)]
22489        fn inline_size(_context: fidl::encoding::Context) -> usize {
22490            4
22491        }
22492    }
22493
22494    unsafe impl
22495        fidl::encoding::Encode<
22496            AudioRendererGetReferenceClockResponse,
22497            fidl::encoding::DefaultFuchsiaResourceDialect,
22498        > for &mut AudioRendererGetReferenceClockResponse
22499    {
22500        #[inline]
22501        unsafe fn encode(
22502            self,
22503            encoder: &mut fidl::encoding::Encoder<
22504                '_,
22505                fidl::encoding::DefaultFuchsiaResourceDialect,
22506            >,
22507            offset: usize,
22508            _depth: fidl::encoding::Depth,
22509        ) -> fidl::Result<()> {
22510            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22511            // Delegate to tuple encoding.
22512            fidl::encoding::Encode::<
22513                AudioRendererGetReferenceClockResponse,
22514                fidl::encoding::DefaultFuchsiaResourceDialect,
22515            >::encode(
22516                (<fidl::encoding::HandleType<
22517                    fidl::Clock,
22518                    { fidl::ObjectType::CLOCK.into_raw() },
22519                    2147483648,
22520                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22521                    &mut self.reference_clock,
22522                ),),
22523                encoder,
22524                offset,
22525                _depth,
22526            )
22527        }
22528    }
22529    unsafe impl<
22530        T0: fidl::encoding::Encode<
22531                fidl::encoding::HandleType<
22532                    fidl::Clock,
22533                    { fidl::ObjectType::CLOCK.into_raw() },
22534                    2147483648,
22535                >,
22536                fidl::encoding::DefaultFuchsiaResourceDialect,
22537            >,
22538    >
22539        fidl::encoding::Encode<
22540            AudioRendererGetReferenceClockResponse,
22541            fidl::encoding::DefaultFuchsiaResourceDialect,
22542        > for (T0,)
22543    {
22544        #[inline]
22545        unsafe fn encode(
22546            self,
22547            encoder: &mut fidl::encoding::Encoder<
22548                '_,
22549                fidl::encoding::DefaultFuchsiaResourceDialect,
22550            >,
22551            offset: usize,
22552            depth: fidl::encoding::Depth,
22553        ) -> fidl::Result<()> {
22554            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22555            // Zero out padding regions. There's no need to apply masks
22556            // because the unmasked parts will be overwritten by fields.
22557            // Write the fields.
22558            self.0.encode(encoder, offset + 0, depth)?;
22559            Ok(())
22560        }
22561    }
22562
22563    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22564        for AudioRendererGetReferenceClockResponse
22565    {
22566        #[inline(always)]
22567        fn new_empty() -> Self {
22568            Self {
22569                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22570            }
22571        }
22572
22573        #[inline]
22574        unsafe fn decode(
22575            &mut self,
22576            decoder: &mut fidl::encoding::Decoder<
22577                '_,
22578                fidl::encoding::DefaultFuchsiaResourceDialect,
22579            >,
22580            offset: usize,
22581            _depth: fidl::encoding::Depth,
22582        ) -> fidl::Result<()> {
22583            decoder.debug_check_bounds::<Self>(offset);
22584            // Verify that padding bytes are zero.
22585            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22586            Ok(())
22587        }
22588    }
22589
22590    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
22591        type Borrowed<'a> = &'a mut Self;
22592        fn take_or_borrow<'a>(
22593            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22594        ) -> Self::Borrowed<'a> {
22595            value
22596        }
22597    }
22598
22599    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
22600        type Owned = Self;
22601
22602        #[inline(always)]
22603        fn inline_align(_context: fidl::encoding::Context) -> usize {
22604            4
22605        }
22606
22607        #[inline(always)]
22608        fn inline_size(_context: fidl::encoding::Context) -> usize {
22609            4
22610        }
22611    }
22612
22613    unsafe impl
22614        fidl::encoding::Encode<
22615            AudioRendererSetReferenceClockRequest,
22616            fidl::encoding::DefaultFuchsiaResourceDialect,
22617        > for &mut AudioRendererSetReferenceClockRequest
22618    {
22619        #[inline]
22620        unsafe fn encode(
22621            self,
22622            encoder: &mut fidl::encoding::Encoder<
22623                '_,
22624                fidl::encoding::DefaultFuchsiaResourceDialect,
22625            >,
22626            offset: usize,
22627            _depth: fidl::encoding::Depth,
22628        ) -> fidl::Result<()> {
22629            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22630            // Delegate to tuple encoding.
22631            fidl::encoding::Encode::<
22632                AudioRendererSetReferenceClockRequest,
22633                fidl::encoding::DefaultFuchsiaResourceDialect,
22634            >::encode(
22635                (<fidl::encoding::Optional<
22636                    fidl::encoding::HandleType<
22637                        fidl::Clock,
22638                        { fidl::ObjectType::CLOCK.into_raw() },
22639                        2147483648,
22640                    >,
22641                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22642                    &mut self.reference_clock,
22643                ),),
22644                encoder,
22645                offset,
22646                _depth,
22647            )
22648        }
22649    }
22650    unsafe impl<
22651        T0: fidl::encoding::Encode<
22652                fidl::encoding::Optional<
22653                    fidl::encoding::HandleType<
22654                        fidl::Clock,
22655                        { fidl::ObjectType::CLOCK.into_raw() },
22656                        2147483648,
22657                    >,
22658                >,
22659                fidl::encoding::DefaultFuchsiaResourceDialect,
22660            >,
22661    >
22662        fidl::encoding::Encode<
22663            AudioRendererSetReferenceClockRequest,
22664            fidl::encoding::DefaultFuchsiaResourceDialect,
22665        > for (T0,)
22666    {
22667        #[inline]
22668        unsafe fn encode(
22669            self,
22670            encoder: &mut fidl::encoding::Encoder<
22671                '_,
22672                fidl::encoding::DefaultFuchsiaResourceDialect,
22673            >,
22674            offset: usize,
22675            depth: fidl::encoding::Depth,
22676        ) -> fidl::Result<()> {
22677            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22678            // Zero out padding regions. There's no need to apply masks
22679            // because the unmasked parts will be overwritten by fields.
22680            // Write the fields.
22681            self.0.encode(encoder, offset + 0, depth)?;
22682            Ok(())
22683        }
22684    }
22685
22686    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22687        for AudioRendererSetReferenceClockRequest
22688    {
22689        #[inline(always)]
22690        fn new_empty() -> Self {
22691            Self {
22692                reference_clock: fidl::new_empty!(
22693                    fidl::encoding::Optional<
22694                        fidl::encoding::HandleType<
22695                            fidl::Clock,
22696                            { fidl::ObjectType::CLOCK.into_raw() },
22697                            2147483648,
22698                        >,
22699                    >,
22700                    fidl::encoding::DefaultFuchsiaResourceDialect
22701                ),
22702            }
22703        }
22704
22705        #[inline]
22706        unsafe fn decode(
22707            &mut self,
22708            decoder: &mut fidl::encoding::Decoder<
22709                '_,
22710                fidl::encoding::DefaultFuchsiaResourceDialect,
22711            >,
22712            offset: usize,
22713            _depth: fidl::encoding::Depth,
22714        ) -> fidl::Result<()> {
22715            decoder.debug_check_bounds::<Self>(offset);
22716            // Verify that padding bytes are zero.
22717            fidl::decode!(
22718                fidl::encoding::Optional<
22719                    fidl::encoding::HandleType<
22720                        fidl::Clock,
22721                        { fidl::ObjectType::CLOCK.into_raw() },
22722                        2147483648,
22723                    >,
22724                >,
22725                fidl::encoding::DefaultFuchsiaResourceDialect,
22726                &mut self.reference_clock,
22727                decoder,
22728                offset + 0,
22729                _depth
22730            )?;
22731            Ok(())
22732        }
22733    }
22734
22735    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22736        type Borrowed<'a> = &'a mut Self;
22737        fn take_or_borrow<'a>(
22738            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22739        ) -> Self::Borrowed<'a> {
22740            value
22741        }
22742    }
22743
22744    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22745        type Owned = Self;
22746
22747        #[inline(always)]
22748        fn inline_align(_context: fidl::encoding::Context) -> usize {
22749            8
22750        }
22751
22752        #[inline(always)]
22753        fn inline_size(_context: fidl::encoding::Context) -> usize {
22754            40
22755        }
22756    }
22757
22758    unsafe impl
22759        fidl::encoding::Encode<
22760            ProfileProviderRegisterHandlerWithCapacityRequest,
22761            fidl::encoding::DefaultFuchsiaResourceDialect,
22762        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
22763    {
22764        #[inline]
22765        unsafe fn encode(
22766            self,
22767            encoder: &mut fidl::encoding::Encoder<
22768                '_,
22769                fidl::encoding::DefaultFuchsiaResourceDialect,
22770            >,
22771            offset: usize,
22772            _depth: fidl::encoding::Depth,
22773        ) -> fidl::Result<()> {
22774            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22775            // Delegate to tuple encoding.
22776            fidl::encoding::Encode::<
22777                ProfileProviderRegisterHandlerWithCapacityRequest,
22778                fidl::encoding::DefaultFuchsiaResourceDialect,
22779            >::encode(
22780                (
22781                    <fidl::encoding::HandleType<
22782                        fidl::Thread,
22783                        { fidl::ObjectType::THREAD.into_raw() },
22784                        2147483648,
22785                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22786                        &mut self.thread_handle,
22787                    ),
22788                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22789                        &self.name,
22790                    ),
22791                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
22792                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
22793                ),
22794                encoder,
22795                offset,
22796                _depth,
22797            )
22798        }
22799    }
22800    unsafe impl<
22801        T0: fidl::encoding::Encode<
22802                fidl::encoding::HandleType<
22803                    fidl::Thread,
22804                    { fidl::ObjectType::THREAD.into_raw() },
22805                    2147483648,
22806                >,
22807                fidl::encoding::DefaultFuchsiaResourceDialect,
22808            >,
22809        T1: fidl::encoding::Encode<
22810                fidl::encoding::BoundedString<64>,
22811                fidl::encoding::DefaultFuchsiaResourceDialect,
22812            >,
22813        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
22814        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
22815    >
22816        fidl::encoding::Encode<
22817            ProfileProviderRegisterHandlerWithCapacityRequest,
22818            fidl::encoding::DefaultFuchsiaResourceDialect,
22819        > for (T0, T1, T2, T3)
22820    {
22821        #[inline]
22822        unsafe fn encode(
22823            self,
22824            encoder: &mut fidl::encoding::Encoder<
22825                '_,
22826                fidl::encoding::DefaultFuchsiaResourceDialect,
22827            >,
22828            offset: usize,
22829            depth: fidl::encoding::Depth,
22830        ) -> fidl::Result<()> {
22831            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22832            // Zero out padding regions. There's no need to apply masks
22833            // because the unmasked parts will be overwritten by fields.
22834            unsafe {
22835                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
22836                (ptr as *mut u64).write_unaligned(0);
22837            }
22838            unsafe {
22839                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
22840                (ptr as *mut u64).write_unaligned(0);
22841            }
22842            // Write the fields.
22843            self.0.encode(encoder, offset + 0, depth)?;
22844            self.1.encode(encoder, offset + 8, depth)?;
22845            self.2.encode(encoder, offset + 24, depth)?;
22846            self.3.encode(encoder, offset + 32, depth)?;
22847            Ok(())
22848        }
22849    }
22850
22851    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22852        for ProfileProviderRegisterHandlerWithCapacityRequest
22853    {
22854        #[inline(always)]
22855        fn new_empty() -> Self {
22856            Self {
22857                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22858                name: fidl::new_empty!(
22859                    fidl::encoding::BoundedString<64>,
22860                    fidl::encoding::DefaultFuchsiaResourceDialect
22861                ),
22862                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
22863                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
22864            }
22865        }
22866
22867        #[inline]
22868        unsafe fn decode(
22869            &mut self,
22870            decoder: &mut fidl::encoding::Decoder<
22871                '_,
22872                fidl::encoding::DefaultFuchsiaResourceDialect,
22873            >,
22874            offset: usize,
22875            _depth: fidl::encoding::Depth,
22876        ) -> fidl::Result<()> {
22877            decoder.debug_check_bounds::<Self>(offset);
22878            // Verify that padding bytes are zero.
22879            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
22880            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22881            let mask = 0xffffffff00000000u64;
22882            let maskedval = padval & mask;
22883            if maskedval != 0 {
22884                return Err(fidl::Error::NonZeroPadding {
22885                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
22886                });
22887            }
22888            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
22889            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22890            let mask = 0xffffffff00000000u64;
22891            let maskedval = padval & mask;
22892            if maskedval != 0 {
22893                return Err(fidl::Error::NonZeroPadding {
22894                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
22895                });
22896            }
22897            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
22898            fidl::decode!(
22899                fidl::encoding::BoundedString<64>,
22900                fidl::encoding::DefaultFuchsiaResourceDialect,
22901                &mut self.name,
22902                decoder,
22903                offset + 8,
22904                _depth
22905            )?;
22906            fidl::decode!(
22907                i64,
22908                fidl::encoding::DefaultFuchsiaResourceDialect,
22909                &mut self.period,
22910                decoder,
22911                offset + 24,
22912                _depth
22913            )?;
22914            fidl::decode!(
22915                f32,
22916                fidl::encoding::DefaultFuchsiaResourceDialect,
22917                &mut self.capacity,
22918                decoder,
22919                offset + 32,
22920                _depth
22921            )?;
22922            Ok(())
22923        }
22924    }
22925
22926    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22927        type Borrowed<'a> = &'a mut Self;
22928        fn take_or_borrow<'a>(
22929            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22930        ) -> Self::Borrowed<'a> {
22931            value
22932        }
22933    }
22934
22935    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22936        type Owned = Self;
22937
22938        #[inline(always)]
22939        fn inline_align(_context: fidl::encoding::Context) -> usize {
22940            8
22941        }
22942
22943        #[inline(always)]
22944        fn inline_size(_context: fidl::encoding::Context) -> usize {
22945            24
22946        }
22947    }
22948
22949    unsafe impl
22950        fidl::encoding::Encode<
22951            ProfileProviderRegisterMemoryRangeRequest,
22952            fidl::encoding::DefaultFuchsiaResourceDialect,
22953        > for &mut ProfileProviderRegisterMemoryRangeRequest
22954    {
22955        #[inline]
22956        unsafe fn encode(
22957            self,
22958            encoder: &mut fidl::encoding::Encoder<
22959                '_,
22960                fidl::encoding::DefaultFuchsiaResourceDialect,
22961            >,
22962            offset: usize,
22963            _depth: fidl::encoding::Depth,
22964        ) -> fidl::Result<()> {
22965            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
22966            // Delegate to tuple encoding.
22967            fidl::encoding::Encode::<
22968                ProfileProviderRegisterMemoryRangeRequest,
22969                fidl::encoding::DefaultFuchsiaResourceDialect,
22970            >::encode(
22971                (
22972                    <fidl::encoding::HandleType<
22973                        fidl::Vmar,
22974                        { fidl::ObjectType::VMAR.into_raw() },
22975                        2147483648,
22976                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22977                        &mut self.vmar_handle
22978                    ),
22979                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22980                        &self.name,
22981                    ),
22982                ),
22983                encoder,
22984                offset,
22985                _depth,
22986            )
22987        }
22988    }
22989    unsafe impl<
22990        T0: fidl::encoding::Encode<
22991                fidl::encoding::HandleType<
22992                    fidl::Vmar,
22993                    { fidl::ObjectType::VMAR.into_raw() },
22994                    2147483648,
22995                >,
22996                fidl::encoding::DefaultFuchsiaResourceDialect,
22997            >,
22998        T1: fidl::encoding::Encode<
22999                fidl::encoding::BoundedString<64>,
23000                fidl::encoding::DefaultFuchsiaResourceDialect,
23001            >,
23002    >
23003        fidl::encoding::Encode<
23004            ProfileProviderRegisterMemoryRangeRequest,
23005            fidl::encoding::DefaultFuchsiaResourceDialect,
23006        > for (T0, T1)
23007    {
23008        #[inline]
23009        unsafe fn encode(
23010            self,
23011            encoder: &mut fidl::encoding::Encoder<
23012                '_,
23013                fidl::encoding::DefaultFuchsiaResourceDialect,
23014            >,
23015            offset: usize,
23016            depth: fidl::encoding::Depth,
23017        ) -> fidl::Result<()> {
23018            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23019            // Zero out padding regions. There's no need to apply masks
23020            // because the unmasked parts will be overwritten by fields.
23021            unsafe {
23022                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23023                (ptr as *mut u64).write_unaligned(0);
23024            }
23025            // Write the fields.
23026            self.0.encode(encoder, offset + 0, depth)?;
23027            self.1.encode(encoder, offset + 8, depth)?;
23028            Ok(())
23029        }
23030    }
23031
23032    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23033        for ProfileProviderRegisterMemoryRangeRequest
23034    {
23035        #[inline(always)]
23036        fn new_empty() -> Self {
23037            Self {
23038                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23039                name: fidl::new_empty!(
23040                    fidl::encoding::BoundedString<64>,
23041                    fidl::encoding::DefaultFuchsiaResourceDialect
23042                ),
23043            }
23044        }
23045
23046        #[inline]
23047        unsafe fn decode(
23048            &mut self,
23049            decoder: &mut fidl::encoding::Decoder<
23050                '_,
23051                fidl::encoding::DefaultFuchsiaResourceDialect,
23052            >,
23053            offset: usize,
23054            _depth: fidl::encoding::Depth,
23055        ) -> fidl::Result<()> {
23056            decoder.debug_check_bounds::<Self>(offset);
23057            // Verify that padding bytes are zero.
23058            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23059            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23060            let mask = 0xffffffff00000000u64;
23061            let maskedval = padval & mask;
23062            if maskedval != 0 {
23063                return Err(fidl::Error::NonZeroPadding {
23064                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23065                });
23066            }
23067            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23068            fidl::decode!(
23069                fidl::encoding::BoundedString<64>,
23070                fidl::encoding::DefaultFuchsiaResourceDialect,
23071                &mut self.name,
23072                decoder,
23073                offset + 8,
23074                _depth
23075            )?;
23076            Ok(())
23077        }
23078    }
23079
23080    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
23081        type Borrowed<'a> = &'a mut Self;
23082        fn take_or_borrow<'a>(
23083            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23084        ) -> Self::Borrowed<'a> {
23085            value
23086        }
23087    }
23088
23089    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
23090        type Owned = Self;
23091
23092        #[inline(always)]
23093        fn inline_align(_context: fidl::encoding::Context) -> usize {
23094            8
23095        }
23096
23097        #[inline(always)]
23098        fn inline_size(_context: fidl::encoding::Context) -> usize {
23099            24
23100        }
23101    }
23102
23103    unsafe impl
23104        fidl::encoding::Encode<
23105            ProfileProviderUnregisterHandlerRequest,
23106            fidl::encoding::DefaultFuchsiaResourceDialect,
23107        > for &mut ProfileProviderUnregisterHandlerRequest
23108    {
23109        #[inline]
23110        unsafe fn encode(
23111            self,
23112            encoder: &mut fidl::encoding::Encoder<
23113                '_,
23114                fidl::encoding::DefaultFuchsiaResourceDialect,
23115            >,
23116            offset: usize,
23117            _depth: fidl::encoding::Depth,
23118        ) -> fidl::Result<()> {
23119            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23120            // Delegate to tuple encoding.
23121            fidl::encoding::Encode::<
23122                ProfileProviderUnregisterHandlerRequest,
23123                fidl::encoding::DefaultFuchsiaResourceDialect,
23124            >::encode(
23125                (
23126                    <fidl::encoding::HandleType<
23127                        fidl::Thread,
23128                        { fidl::ObjectType::THREAD.into_raw() },
23129                        2147483648,
23130                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23131                        &mut self.thread_handle,
23132                    ),
23133                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23134                        &self.name,
23135                    ),
23136                ),
23137                encoder,
23138                offset,
23139                _depth,
23140            )
23141        }
23142    }
23143    unsafe impl<
23144        T0: fidl::encoding::Encode<
23145                fidl::encoding::HandleType<
23146                    fidl::Thread,
23147                    { fidl::ObjectType::THREAD.into_raw() },
23148                    2147483648,
23149                >,
23150                fidl::encoding::DefaultFuchsiaResourceDialect,
23151            >,
23152        T1: fidl::encoding::Encode<
23153                fidl::encoding::BoundedString<64>,
23154                fidl::encoding::DefaultFuchsiaResourceDialect,
23155            >,
23156    >
23157        fidl::encoding::Encode<
23158            ProfileProviderUnregisterHandlerRequest,
23159            fidl::encoding::DefaultFuchsiaResourceDialect,
23160        > for (T0, T1)
23161    {
23162        #[inline]
23163        unsafe fn encode(
23164            self,
23165            encoder: &mut fidl::encoding::Encoder<
23166                '_,
23167                fidl::encoding::DefaultFuchsiaResourceDialect,
23168            >,
23169            offset: usize,
23170            depth: fidl::encoding::Depth,
23171        ) -> fidl::Result<()> {
23172            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23173            // Zero out padding regions. There's no need to apply masks
23174            // because the unmasked parts will be overwritten by fields.
23175            unsafe {
23176                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23177                (ptr as *mut u64).write_unaligned(0);
23178            }
23179            // Write the fields.
23180            self.0.encode(encoder, offset + 0, depth)?;
23181            self.1.encode(encoder, offset + 8, depth)?;
23182            Ok(())
23183        }
23184    }
23185
23186    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23187        for ProfileProviderUnregisterHandlerRequest
23188    {
23189        #[inline(always)]
23190        fn new_empty() -> Self {
23191            Self {
23192                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23193                name: fidl::new_empty!(
23194                    fidl::encoding::BoundedString<64>,
23195                    fidl::encoding::DefaultFuchsiaResourceDialect
23196                ),
23197            }
23198        }
23199
23200        #[inline]
23201        unsafe fn decode(
23202            &mut self,
23203            decoder: &mut fidl::encoding::Decoder<
23204                '_,
23205                fidl::encoding::DefaultFuchsiaResourceDialect,
23206            >,
23207            offset: usize,
23208            _depth: fidl::encoding::Depth,
23209        ) -> fidl::Result<()> {
23210            decoder.debug_check_bounds::<Self>(offset);
23211            // Verify that padding bytes are zero.
23212            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23213            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23214            let mask = 0xffffffff00000000u64;
23215            let maskedval = padval & mask;
23216            if maskedval != 0 {
23217                return Err(fidl::Error::NonZeroPadding {
23218                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23219                });
23220            }
23221            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23222            fidl::decode!(
23223                fidl::encoding::BoundedString<64>,
23224                fidl::encoding::DefaultFuchsiaResourceDialect,
23225                &mut self.name,
23226                decoder,
23227                offset + 8,
23228                _depth
23229            )?;
23230            Ok(())
23231        }
23232    }
23233
23234    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23235        type Borrowed<'a> = &'a mut Self;
23236        fn take_or_borrow<'a>(
23237            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23238        ) -> Self::Borrowed<'a> {
23239            value
23240        }
23241    }
23242
23243    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23244        type Owned = Self;
23245
23246        #[inline(always)]
23247        fn inline_align(_context: fidl::encoding::Context) -> usize {
23248            4
23249        }
23250
23251        #[inline(always)]
23252        fn inline_size(_context: fidl::encoding::Context) -> usize {
23253            4
23254        }
23255    }
23256
23257    unsafe impl
23258        fidl::encoding::Encode<
23259            ProfileProviderUnregisterMemoryRangeRequest,
23260            fidl::encoding::DefaultFuchsiaResourceDialect,
23261        > for &mut ProfileProviderUnregisterMemoryRangeRequest
23262    {
23263        #[inline]
23264        unsafe fn encode(
23265            self,
23266            encoder: &mut fidl::encoding::Encoder<
23267                '_,
23268                fidl::encoding::DefaultFuchsiaResourceDialect,
23269            >,
23270            offset: usize,
23271            _depth: fidl::encoding::Depth,
23272        ) -> fidl::Result<()> {
23273            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23274            // Delegate to tuple encoding.
23275            fidl::encoding::Encode::<
23276                ProfileProviderUnregisterMemoryRangeRequest,
23277                fidl::encoding::DefaultFuchsiaResourceDialect,
23278            >::encode(
23279                (<fidl::encoding::HandleType<
23280                    fidl::Vmar,
23281                    { fidl::ObjectType::VMAR.into_raw() },
23282                    2147483648,
23283                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23284                    &mut self.vmar_handle
23285                ),),
23286                encoder,
23287                offset,
23288                _depth,
23289            )
23290        }
23291    }
23292    unsafe impl<
23293        T0: fidl::encoding::Encode<
23294                fidl::encoding::HandleType<
23295                    fidl::Vmar,
23296                    { fidl::ObjectType::VMAR.into_raw() },
23297                    2147483648,
23298                >,
23299                fidl::encoding::DefaultFuchsiaResourceDialect,
23300            >,
23301    >
23302        fidl::encoding::Encode<
23303            ProfileProviderUnregisterMemoryRangeRequest,
23304            fidl::encoding::DefaultFuchsiaResourceDialect,
23305        > for (T0,)
23306    {
23307        #[inline]
23308        unsafe fn encode(
23309            self,
23310            encoder: &mut fidl::encoding::Encoder<
23311                '_,
23312                fidl::encoding::DefaultFuchsiaResourceDialect,
23313            >,
23314            offset: usize,
23315            depth: fidl::encoding::Depth,
23316        ) -> fidl::Result<()> {
23317            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23318            // Zero out padding regions. There's no need to apply masks
23319            // because the unmasked parts will be overwritten by fields.
23320            // Write the fields.
23321            self.0.encode(encoder, offset + 0, depth)?;
23322            Ok(())
23323        }
23324    }
23325
23326    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23327        for ProfileProviderUnregisterMemoryRangeRequest
23328    {
23329        #[inline(always)]
23330        fn new_empty() -> Self {
23331            Self {
23332                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23333            }
23334        }
23335
23336        #[inline]
23337        unsafe fn decode(
23338            &mut self,
23339            decoder: &mut fidl::encoding::Decoder<
23340                '_,
23341                fidl::encoding::DefaultFuchsiaResourceDialect,
23342            >,
23343            offset: usize,
23344            _depth: fidl::encoding::Depth,
23345        ) -> fidl::Result<()> {
23346            decoder.debug_check_bounds::<Self>(offset);
23347            // Verify that padding bytes are zero.
23348            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23349            Ok(())
23350        }
23351    }
23352
23353    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23354        type Borrowed<'a> = &'a mut Self;
23355        fn take_or_borrow<'a>(
23356            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23357        ) -> Self::Borrowed<'a> {
23358            value
23359        }
23360    }
23361
23362    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23363        type Owned = Self;
23364
23365        #[inline(always)]
23366        fn inline_align(_context: fidl::encoding::Context) -> usize {
23367            8
23368        }
23369
23370        #[inline(always)]
23371        fn inline_size(_context: fidl::encoding::Context) -> usize {
23372            16
23373        }
23374    }
23375
23376    unsafe impl
23377        fidl::encoding::Encode<
23378            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23379            fidl::encoding::DefaultFuchsiaResourceDialect,
23380        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
23381    {
23382        #[inline]
23383        unsafe fn encode(
23384            self,
23385            encoder: &mut fidl::encoding::Encoder<
23386                '_,
23387                fidl::encoding::DefaultFuchsiaResourceDialect,
23388            >,
23389            offset: usize,
23390            _depth: fidl::encoding::Depth,
23391        ) -> fidl::Result<()> {
23392            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23393                offset,
23394            );
23395            // Delegate to tuple encoding.
23396            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23397                (
23398                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
23399                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23400                ),
23401                encoder, offset, _depth
23402            )
23403        }
23404    }
23405    unsafe impl<
23406        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
23407        T1: fidl::encoding::Encode<
23408                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23409                fidl::encoding::DefaultFuchsiaResourceDialect,
23410            >,
23411    >
23412        fidl::encoding::Encode<
23413            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23414            fidl::encoding::DefaultFuchsiaResourceDialect,
23415        > for (T0, T1)
23416    {
23417        #[inline]
23418        unsafe fn encode(
23419            self,
23420            encoder: &mut fidl::encoding::Encoder<
23421                '_,
23422                fidl::encoding::DefaultFuchsiaResourceDialect,
23423            >,
23424            offset: usize,
23425            depth: fidl::encoding::Depth,
23426        ) -> fidl::Result<()> {
23427            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23428                offset,
23429            );
23430            // Zero out padding regions. There's no need to apply masks
23431            // because the unmasked parts will be overwritten by fields.
23432            unsafe {
23433                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23434                (ptr as *mut u64).write_unaligned(0);
23435            }
23436            // Write the fields.
23437            self.0.encode(encoder, offset + 0, depth)?;
23438            self.1.encode(encoder, offset + 8, depth)?;
23439            Ok(())
23440        }
23441    }
23442
23443    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23444        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
23445    {
23446        #[inline(always)]
23447        fn new_empty() -> Self {
23448            Self {
23449                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
23450                audio_consumer_request: fidl::new_empty!(
23451                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23452                    fidl::encoding::DefaultFuchsiaResourceDialect
23453                ),
23454            }
23455        }
23456
23457        #[inline]
23458        unsafe fn decode(
23459            &mut self,
23460            decoder: &mut fidl::encoding::Decoder<
23461                '_,
23462                fidl::encoding::DefaultFuchsiaResourceDialect,
23463            >,
23464            offset: usize,
23465            _depth: fidl::encoding::Depth,
23466        ) -> fidl::Result<()> {
23467            decoder.debug_check_bounds::<Self>(offset);
23468            // Verify that padding bytes are zero.
23469            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23470            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23471            let mask = 0xffffffff00000000u64;
23472            let maskedval = padval & mask;
23473            if maskedval != 0 {
23474                return Err(fidl::Error::NonZeroPadding {
23475                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23476                });
23477            }
23478            fidl::decode!(
23479                u64,
23480                fidl::encoding::DefaultFuchsiaResourceDialect,
23481                &mut self.session_id,
23482                decoder,
23483                offset + 0,
23484                _depth
23485            )?;
23486            fidl::decode!(
23487                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23488                fidl::encoding::DefaultFuchsiaResourceDialect,
23489                &mut self.audio_consumer_request,
23490                decoder,
23491                offset + 8,
23492                _depth
23493            )?;
23494            Ok(())
23495        }
23496    }
23497
23498    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
23499        type Borrowed<'a> = &'a mut Self;
23500        fn take_or_borrow<'a>(
23501            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23502        ) -> Self::Borrowed<'a> {
23503            value
23504        }
23505    }
23506
23507    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
23508        type Owned = Self;
23509
23510        #[inline(always)]
23511        fn inline_align(_context: fidl::encoding::Context) -> usize {
23512            4
23513        }
23514
23515        #[inline(always)]
23516        fn inline_size(_context: fidl::encoding::Context) -> usize {
23517            8
23518        }
23519    }
23520
23521    unsafe impl
23522        fidl::encoding::Encode<
23523            StreamBufferSetAddPayloadBufferRequest,
23524            fidl::encoding::DefaultFuchsiaResourceDialect,
23525        > for &mut StreamBufferSetAddPayloadBufferRequest
23526    {
23527        #[inline]
23528        unsafe fn encode(
23529            self,
23530            encoder: &mut fidl::encoding::Encoder<
23531                '_,
23532                fidl::encoding::DefaultFuchsiaResourceDialect,
23533            >,
23534            offset: usize,
23535            _depth: fidl::encoding::Depth,
23536        ) -> fidl::Result<()> {
23537            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23538            // Delegate to tuple encoding.
23539            fidl::encoding::Encode::<
23540                StreamBufferSetAddPayloadBufferRequest,
23541                fidl::encoding::DefaultFuchsiaResourceDialect,
23542            >::encode(
23543                (
23544                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
23545                    <fidl::encoding::HandleType<
23546                        fidl::Vmo,
23547                        { fidl::ObjectType::VMO.into_raw() },
23548                        2147483648,
23549                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23550                        &mut self.payload_buffer,
23551                    ),
23552                ),
23553                encoder,
23554                offset,
23555                _depth,
23556            )
23557        }
23558    }
23559    unsafe impl<
23560        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
23561        T1: fidl::encoding::Encode<
23562                fidl::encoding::HandleType<
23563                    fidl::Vmo,
23564                    { fidl::ObjectType::VMO.into_raw() },
23565                    2147483648,
23566                >,
23567                fidl::encoding::DefaultFuchsiaResourceDialect,
23568            >,
23569    >
23570        fidl::encoding::Encode<
23571            StreamBufferSetAddPayloadBufferRequest,
23572            fidl::encoding::DefaultFuchsiaResourceDialect,
23573        > for (T0, T1)
23574    {
23575        #[inline]
23576        unsafe fn encode(
23577            self,
23578            encoder: &mut fidl::encoding::Encoder<
23579                '_,
23580                fidl::encoding::DefaultFuchsiaResourceDialect,
23581            >,
23582            offset: usize,
23583            depth: fidl::encoding::Depth,
23584        ) -> fidl::Result<()> {
23585            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23586            // Zero out padding regions. There's no need to apply masks
23587            // because the unmasked parts will be overwritten by fields.
23588            // Write the fields.
23589            self.0.encode(encoder, offset + 0, depth)?;
23590            self.1.encode(encoder, offset + 4, depth)?;
23591            Ok(())
23592        }
23593    }
23594
23595    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23596        for StreamBufferSetAddPayloadBufferRequest
23597    {
23598        #[inline(always)]
23599        fn new_empty() -> Self {
23600            Self {
23601                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
23602                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23603            }
23604        }
23605
23606        #[inline]
23607        unsafe fn decode(
23608            &mut self,
23609            decoder: &mut fidl::encoding::Decoder<
23610                '_,
23611                fidl::encoding::DefaultFuchsiaResourceDialect,
23612            >,
23613            offset: usize,
23614            _depth: fidl::encoding::Depth,
23615        ) -> fidl::Result<()> {
23616            decoder.debug_check_bounds::<Self>(offset);
23617            // Verify that padding bytes are zero.
23618            fidl::decode!(
23619                u32,
23620                fidl::encoding::DefaultFuchsiaResourceDialect,
23621                &mut self.id,
23622                decoder,
23623                offset + 0,
23624                _depth
23625            )?;
23626            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
23627            Ok(())
23628        }
23629    }
23630
23631    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23632        type Borrowed<'a> = &'a mut Self;
23633        fn take_or_borrow<'a>(
23634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23635        ) -> Self::Borrowed<'a> {
23636            value
23637        }
23638    }
23639
23640    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23641        type Owned = Self;
23642
23643        #[inline(always)]
23644        fn inline_align(_context: fidl::encoding::Context) -> usize {
23645            8
23646        }
23647
23648        #[inline(always)]
23649        fn inline_size(_context: fidl::encoding::Context) -> usize {
23650            16
23651        }
23652    }
23653
23654    unsafe impl
23655        fidl::encoding::Encode<
23656            StreamProcessorSetInputBufferPartialSettingsRequest,
23657            fidl::encoding::DefaultFuchsiaResourceDialect,
23658        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
23659    {
23660        #[inline]
23661        unsafe fn encode(
23662            self,
23663            encoder: &mut fidl::encoding::Encoder<
23664                '_,
23665                fidl::encoding::DefaultFuchsiaResourceDialect,
23666            >,
23667            offset: usize,
23668            _depth: fidl::encoding::Depth,
23669        ) -> fidl::Result<()> {
23670            encoder
23671                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23672            // Delegate to tuple encoding.
23673            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23674                (
23675                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
23676                ),
23677                encoder, offset, _depth
23678            )
23679        }
23680    }
23681    unsafe impl<
23682        T0: fidl::encoding::Encode<
23683                StreamBufferPartialSettings,
23684                fidl::encoding::DefaultFuchsiaResourceDialect,
23685            >,
23686    >
23687        fidl::encoding::Encode<
23688            StreamProcessorSetInputBufferPartialSettingsRequest,
23689            fidl::encoding::DefaultFuchsiaResourceDialect,
23690        > for (T0,)
23691    {
23692        #[inline]
23693        unsafe fn encode(
23694            self,
23695            encoder: &mut fidl::encoding::Encoder<
23696                '_,
23697                fidl::encoding::DefaultFuchsiaResourceDialect,
23698            >,
23699            offset: usize,
23700            depth: fidl::encoding::Depth,
23701        ) -> fidl::Result<()> {
23702            encoder
23703                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23704            // Zero out padding regions. There's no need to apply masks
23705            // because the unmasked parts will be overwritten by fields.
23706            // Write the fields.
23707            self.0.encode(encoder, offset + 0, depth)?;
23708            Ok(())
23709        }
23710    }
23711
23712    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23713        for StreamProcessorSetInputBufferPartialSettingsRequest
23714    {
23715        #[inline(always)]
23716        fn new_empty() -> Self {
23717            Self {
23718                input_settings: fidl::new_empty!(
23719                    StreamBufferPartialSettings,
23720                    fidl::encoding::DefaultFuchsiaResourceDialect
23721                ),
23722            }
23723        }
23724
23725        #[inline]
23726        unsafe fn decode(
23727            &mut self,
23728            decoder: &mut fidl::encoding::Decoder<
23729                '_,
23730                fidl::encoding::DefaultFuchsiaResourceDialect,
23731            >,
23732            offset: usize,
23733            _depth: fidl::encoding::Depth,
23734        ) -> fidl::Result<()> {
23735            decoder.debug_check_bounds::<Self>(offset);
23736            // Verify that padding bytes are zero.
23737            fidl::decode!(
23738                StreamBufferPartialSettings,
23739                fidl::encoding::DefaultFuchsiaResourceDialect,
23740                &mut self.input_settings,
23741                decoder,
23742                offset + 0,
23743                _depth
23744            )?;
23745            Ok(())
23746        }
23747    }
23748
23749    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23750        type Borrowed<'a> = &'a mut Self;
23751        fn take_or_borrow<'a>(
23752            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23753        ) -> Self::Borrowed<'a> {
23754            value
23755        }
23756    }
23757
23758    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23759        type Owned = Self;
23760
23761        #[inline(always)]
23762        fn inline_align(_context: fidl::encoding::Context) -> usize {
23763            8
23764        }
23765
23766        #[inline(always)]
23767        fn inline_size(_context: fidl::encoding::Context) -> usize {
23768            16
23769        }
23770    }
23771
23772    unsafe impl
23773        fidl::encoding::Encode<
23774            StreamProcessorSetOutputBufferPartialSettingsRequest,
23775            fidl::encoding::DefaultFuchsiaResourceDialect,
23776        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
23777    {
23778        #[inline]
23779        unsafe fn encode(
23780            self,
23781            encoder: &mut fidl::encoding::Encoder<
23782                '_,
23783                fidl::encoding::DefaultFuchsiaResourceDialect,
23784            >,
23785            offset: usize,
23786            _depth: fidl::encoding::Depth,
23787        ) -> fidl::Result<()> {
23788            encoder
23789                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23790            // Delegate to tuple encoding.
23791            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23792                (
23793                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
23794                ),
23795                encoder, offset, _depth
23796            )
23797        }
23798    }
23799    unsafe impl<
23800        T0: fidl::encoding::Encode<
23801                StreamBufferPartialSettings,
23802                fidl::encoding::DefaultFuchsiaResourceDialect,
23803            >,
23804    >
23805        fidl::encoding::Encode<
23806            StreamProcessorSetOutputBufferPartialSettingsRequest,
23807            fidl::encoding::DefaultFuchsiaResourceDialect,
23808        > for (T0,)
23809    {
23810        #[inline]
23811        unsafe fn encode(
23812            self,
23813            encoder: &mut fidl::encoding::Encoder<
23814                '_,
23815                fidl::encoding::DefaultFuchsiaResourceDialect,
23816            >,
23817            offset: usize,
23818            depth: fidl::encoding::Depth,
23819        ) -> fidl::Result<()> {
23820            encoder
23821                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23822            // Zero out padding regions. There's no need to apply masks
23823            // because the unmasked parts will be overwritten by fields.
23824            // Write the fields.
23825            self.0.encode(encoder, offset + 0, depth)?;
23826            Ok(())
23827        }
23828    }
23829
23830    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23831        for StreamProcessorSetOutputBufferPartialSettingsRequest
23832    {
23833        #[inline(always)]
23834        fn new_empty() -> Self {
23835            Self {
23836                output_settings: fidl::new_empty!(
23837                    StreamBufferPartialSettings,
23838                    fidl::encoding::DefaultFuchsiaResourceDialect
23839                ),
23840            }
23841        }
23842
23843        #[inline]
23844        unsafe fn decode(
23845            &mut self,
23846            decoder: &mut fidl::encoding::Decoder<
23847                '_,
23848                fidl::encoding::DefaultFuchsiaResourceDialect,
23849            >,
23850            offset: usize,
23851            _depth: fidl::encoding::Depth,
23852        ) -> fidl::Result<()> {
23853            decoder.debug_check_bounds::<Self>(offset);
23854            // Verify that padding bytes are zero.
23855            fidl::decode!(
23856                StreamBufferPartialSettings,
23857                fidl::encoding::DefaultFuchsiaResourceDialect,
23858                &mut self.output_settings,
23859                decoder,
23860                offset + 0,
23861                _depth
23862            )?;
23863            Ok(())
23864        }
23865    }
23866
23867    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23868        type Borrowed<'a> = &'a mut Self;
23869        fn take_or_borrow<'a>(
23870            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23871        ) -> Self::Borrowed<'a> {
23872            value
23873        }
23874    }
23875
23876    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23877        type Owned = Self;
23878
23879        #[inline(always)]
23880        fn inline_align(_context: fidl::encoding::Context) -> usize {
23881            4
23882        }
23883
23884        #[inline(always)]
23885        fn inline_size(_context: fidl::encoding::Context) -> usize {
23886            8
23887        }
23888    }
23889
23890    unsafe impl
23891        fidl::encoding::Encode<
23892            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23893            fidl::encoding::DefaultFuchsiaResourceDialect,
23894        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23895    {
23896        #[inline]
23897        unsafe fn encode(
23898            self,
23899            encoder: &mut fidl::encoding::Encoder<
23900                '_,
23901                fidl::encoding::DefaultFuchsiaResourceDialect,
23902            >,
23903            offset: usize,
23904            _depth: fidl::encoding::Depth,
23905        ) -> fidl::Result<()> {
23906            encoder
23907                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23908            // Delegate to tuple encoding.
23909            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23910                (
23911                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23912                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23913                ),
23914                encoder, offset, _depth
23915            )
23916        }
23917    }
23918    unsafe impl<
23919        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
23920        T1: fidl::encoding::Encode<
23921                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23922                fidl::encoding::DefaultFuchsiaResourceDialect,
23923            >,
23924    >
23925        fidl::encoding::Encode<
23926            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23927            fidl::encoding::DefaultFuchsiaResourceDialect,
23928        > for (T0, T1)
23929    {
23930        #[inline]
23931        unsafe fn encode(
23932            self,
23933            encoder: &mut fidl::encoding::Encoder<
23934                '_,
23935                fidl::encoding::DefaultFuchsiaResourceDialect,
23936            >,
23937            offset: usize,
23938            depth: fidl::encoding::Depth,
23939        ) -> fidl::Result<()> {
23940            encoder
23941                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23942            // Zero out padding regions. There's no need to apply masks
23943            // because the unmasked parts will be overwritten by fields.
23944            // Write the fields.
23945            self.0.encode(encoder, offset + 0, depth)?;
23946            self.1.encode(encoder, offset + 4, depth)?;
23947            Ok(())
23948        }
23949    }
23950
23951    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23952        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23953    {
23954        #[inline(always)]
23955        fn new_empty() -> Self {
23956            Self {
23957                usage: fidl::new_empty!(
23958                    AudioRenderUsage2,
23959                    fidl::encoding::DefaultFuchsiaResourceDialect
23960                ),
23961                audio_consumer_request: fidl::new_empty!(
23962                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23963                    fidl::encoding::DefaultFuchsiaResourceDialect
23964                ),
23965            }
23966        }
23967
23968        #[inline]
23969        unsafe fn decode(
23970            &mut self,
23971            decoder: &mut fidl::encoding::Decoder<
23972                '_,
23973                fidl::encoding::DefaultFuchsiaResourceDialect,
23974            >,
23975            offset: usize,
23976            _depth: fidl::encoding::Depth,
23977        ) -> fidl::Result<()> {
23978            decoder.debug_check_bounds::<Self>(offset);
23979            // Verify that padding bytes are zero.
23980            fidl::decode!(
23981                AudioRenderUsage2,
23982                fidl::encoding::DefaultFuchsiaResourceDialect,
23983                &mut self.usage,
23984                decoder,
23985                offset + 0,
23986                _depth
23987            )?;
23988            fidl::decode!(
23989                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23990                fidl::encoding::DefaultFuchsiaResourceDialect,
23991                &mut self.audio_consumer_request,
23992                decoder,
23993                offset + 4,
23994                _depth
23995            )?;
23996            Ok(())
23997        }
23998    }
23999
24000    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24001        type Borrowed<'a> = &'a mut Self;
24002        fn take_or_borrow<'a>(
24003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24004        ) -> Self::Borrowed<'a> {
24005            value
24006        }
24007    }
24008
24009    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24010        type Owned = Self;
24011
24012        #[inline(always)]
24013        fn inline_align(_context: fidl::encoding::Context) -> usize {
24014            4
24015        }
24016
24017        #[inline(always)]
24018        fn inline_size(_context: fidl::encoding::Context) -> usize {
24019            8
24020        }
24021    }
24022
24023    unsafe impl
24024        fidl::encoding::Encode<
24025            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24026            fidl::encoding::DefaultFuchsiaResourceDialect,
24027        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
24028    {
24029        #[inline]
24030        unsafe fn encode(
24031            self,
24032            encoder: &mut fidl::encoding::Encoder<
24033                '_,
24034                fidl::encoding::DefaultFuchsiaResourceDialect,
24035            >,
24036            offset: usize,
24037            _depth: fidl::encoding::Depth,
24038        ) -> fidl::Result<()> {
24039            encoder
24040                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24041            // Delegate to tuple encoding.
24042            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24043                (
24044                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24045                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24046                ),
24047                encoder, offset, _depth
24048            )
24049        }
24050    }
24051    unsafe impl<
24052        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24053        T1: fidl::encoding::Encode<
24054                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24055                fidl::encoding::DefaultFuchsiaResourceDialect,
24056            >,
24057    >
24058        fidl::encoding::Encode<
24059            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24060            fidl::encoding::DefaultFuchsiaResourceDialect,
24061        > for (T0, T1)
24062    {
24063        #[inline]
24064        unsafe fn encode(
24065            self,
24066            encoder: &mut fidl::encoding::Encoder<
24067                '_,
24068                fidl::encoding::DefaultFuchsiaResourceDialect,
24069            >,
24070            offset: usize,
24071            depth: fidl::encoding::Depth,
24072        ) -> fidl::Result<()> {
24073            encoder
24074                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24075            // Zero out padding regions. There's no need to apply masks
24076            // because the unmasked parts will be overwritten by fields.
24077            // Write the fields.
24078            self.0.encode(encoder, offset + 0, depth)?;
24079            self.1.encode(encoder, offset + 4, depth)?;
24080            Ok(())
24081        }
24082    }
24083
24084    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24085        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
24086    {
24087        #[inline(always)]
24088        fn new_empty() -> Self {
24089            Self {
24090                usage: fidl::new_empty!(
24091                    AudioRenderUsage,
24092                    fidl::encoding::DefaultFuchsiaResourceDialect
24093                ),
24094                audio_consumer_request: fidl::new_empty!(
24095                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24096                    fidl::encoding::DefaultFuchsiaResourceDialect
24097                ),
24098            }
24099        }
24100
24101        #[inline]
24102        unsafe fn decode(
24103            &mut self,
24104            decoder: &mut fidl::encoding::Decoder<
24105                '_,
24106                fidl::encoding::DefaultFuchsiaResourceDialect,
24107            >,
24108            offset: usize,
24109            _depth: fidl::encoding::Depth,
24110        ) -> fidl::Result<()> {
24111            decoder.debug_check_bounds::<Self>(offset);
24112            // Verify that padding bytes are zero.
24113            fidl::decode!(
24114                AudioRenderUsage,
24115                fidl::encoding::DefaultFuchsiaResourceDialect,
24116                &mut self.usage,
24117                decoder,
24118                offset + 0,
24119                _depth
24120            )?;
24121            fidl::decode!(
24122                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24123                fidl::encoding::DefaultFuchsiaResourceDialect,
24124                &mut self.audio_consumer_request,
24125                decoder,
24126                offset + 4,
24127                _depth
24128            )?;
24129            Ok(())
24130        }
24131    }
24132
24133    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
24134        type Borrowed<'a> = &'a mut Self;
24135        fn take_or_borrow<'a>(
24136            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24137        ) -> Self::Borrowed<'a> {
24138            value
24139        }
24140    }
24141
24142    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
24143        type Owned = Self;
24144
24145        #[inline(always)]
24146        fn inline_align(_context: fidl::encoding::Context) -> usize {
24147            8
24148        }
24149
24150        #[inline(always)]
24151        fn inline_size(_context: fidl::encoding::Context) -> usize {
24152            40
24153        }
24154    }
24155
24156    unsafe impl
24157        fidl::encoding::Encode<
24158            UsageGainReporterRegisterListener2Request,
24159            fidl::encoding::DefaultFuchsiaResourceDialect,
24160        > for &mut UsageGainReporterRegisterListener2Request
24161    {
24162        #[inline]
24163        unsafe fn encode(
24164            self,
24165            encoder: &mut fidl::encoding::Encoder<
24166                '_,
24167                fidl::encoding::DefaultFuchsiaResourceDialect,
24168            >,
24169            offset: usize,
24170            _depth: fidl::encoding::Depth,
24171        ) -> fidl::Result<()> {
24172            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24173            // Delegate to tuple encoding.
24174            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24175                (
24176                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24177                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24178                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24179                ),
24180                encoder, offset, _depth
24181            )
24182        }
24183    }
24184    unsafe impl<
24185        T0: fidl::encoding::Encode<
24186                fidl::encoding::BoundedString<36>,
24187                fidl::encoding::DefaultFuchsiaResourceDialect,
24188            >,
24189        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24190        T2: fidl::encoding::Encode<
24191                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24192                fidl::encoding::DefaultFuchsiaResourceDialect,
24193            >,
24194    >
24195        fidl::encoding::Encode<
24196            UsageGainReporterRegisterListener2Request,
24197            fidl::encoding::DefaultFuchsiaResourceDialect,
24198        > for (T0, T1, T2)
24199    {
24200        #[inline]
24201        unsafe fn encode(
24202            self,
24203            encoder: &mut fidl::encoding::Encoder<
24204                '_,
24205                fidl::encoding::DefaultFuchsiaResourceDialect,
24206            >,
24207            offset: usize,
24208            depth: fidl::encoding::Depth,
24209        ) -> fidl::Result<()> {
24210            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24211            // Zero out padding regions. There's no need to apply masks
24212            // because the unmasked parts will be overwritten by fields.
24213            unsafe {
24214                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24215                (ptr as *mut u64).write_unaligned(0);
24216            }
24217            // Write the fields.
24218            self.0.encode(encoder, offset + 0, depth)?;
24219            self.1.encode(encoder, offset + 16, depth)?;
24220            self.2.encode(encoder, offset + 32, depth)?;
24221            Ok(())
24222        }
24223    }
24224
24225    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24226        for UsageGainReporterRegisterListener2Request
24227    {
24228        #[inline(always)]
24229        fn new_empty() -> Self {
24230            Self {
24231                device_unique_id: fidl::new_empty!(
24232                    fidl::encoding::BoundedString<36>,
24233                    fidl::encoding::DefaultFuchsiaResourceDialect
24234                ),
24235                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24236                usage_gain_listener: fidl::new_empty!(
24237                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24238                    fidl::encoding::DefaultFuchsiaResourceDialect
24239                ),
24240            }
24241        }
24242
24243        #[inline]
24244        unsafe fn decode(
24245            &mut self,
24246            decoder: &mut fidl::encoding::Decoder<
24247                '_,
24248                fidl::encoding::DefaultFuchsiaResourceDialect,
24249            >,
24250            offset: usize,
24251            _depth: fidl::encoding::Depth,
24252        ) -> fidl::Result<()> {
24253            decoder.debug_check_bounds::<Self>(offset);
24254            // Verify that padding bytes are zero.
24255            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24256            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24257            let mask = 0xffffffff00000000u64;
24258            let maskedval = padval & mask;
24259            if maskedval != 0 {
24260                return Err(fidl::Error::NonZeroPadding {
24261                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24262                });
24263            }
24264            fidl::decode!(
24265                fidl::encoding::BoundedString<36>,
24266                fidl::encoding::DefaultFuchsiaResourceDialect,
24267                &mut self.device_unique_id,
24268                decoder,
24269                offset + 0,
24270                _depth
24271            )?;
24272            fidl::decode!(
24273                Usage2,
24274                fidl::encoding::DefaultFuchsiaResourceDialect,
24275                &mut self.usage,
24276                decoder,
24277                offset + 16,
24278                _depth
24279            )?;
24280            fidl::decode!(
24281                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24282                fidl::encoding::DefaultFuchsiaResourceDialect,
24283                &mut self.usage_gain_listener,
24284                decoder,
24285                offset + 32,
24286                _depth
24287            )?;
24288            Ok(())
24289        }
24290    }
24291
24292    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
24293        type Borrowed<'a> = &'a mut Self;
24294        fn take_or_borrow<'a>(
24295            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24296        ) -> Self::Borrowed<'a> {
24297            value
24298        }
24299    }
24300
24301    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
24302        type Owned = Self;
24303
24304        #[inline(always)]
24305        fn inline_align(_context: fidl::encoding::Context) -> usize {
24306            8
24307        }
24308
24309        #[inline(always)]
24310        fn inline_size(_context: fidl::encoding::Context) -> usize {
24311            40
24312        }
24313    }
24314
24315    unsafe impl
24316        fidl::encoding::Encode<
24317            UsageGainReporterRegisterListenerRequest,
24318            fidl::encoding::DefaultFuchsiaResourceDialect,
24319        > for &mut UsageGainReporterRegisterListenerRequest
24320    {
24321        #[inline]
24322        unsafe fn encode(
24323            self,
24324            encoder: &mut fidl::encoding::Encoder<
24325                '_,
24326                fidl::encoding::DefaultFuchsiaResourceDialect,
24327            >,
24328            offset: usize,
24329            _depth: fidl::encoding::Depth,
24330        ) -> fidl::Result<()> {
24331            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24332            // Delegate to tuple encoding.
24333            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24334                (
24335                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24336                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24337                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24338                ),
24339                encoder, offset, _depth
24340            )
24341        }
24342    }
24343    unsafe impl<
24344        T0: fidl::encoding::Encode<
24345                fidl::encoding::BoundedString<36>,
24346                fidl::encoding::DefaultFuchsiaResourceDialect,
24347            >,
24348        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24349        T2: fidl::encoding::Encode<
24350                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24351                fidl::encoding::DefaultFuchsiaResourceDialect,
24352            >,
24353    >
24354        fidl::encoding::Encode<
24355            UsageGainReporterRegisterListenerRequest,
24356            fidl::encoding::DefaultFuchsiaResourceDialect,
24357        > for (T0, T1, T2)
24358    {
24359        #[inline]
24360        unsafe fn encode(
24361            self,
24362            encoder: &mut fidl::encoding::Encoder<
24363                '_,
24364                fidl::encoding::DefaultFuchsiaResourceDialect,
24365            >,
24366            offset: usize,
24367            depth: fidl::encoding::Depth,
24368        ) -> fidl::Result<()> {
24369            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24370            // Zero out padding regions. There's no need to apply masks
24371            // because the unmasked parts will be overwritten by fields.
24372            unsafe {
24373                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24374                (ptr as *mut u64).write_unaligned(0);
24375            }
24376            // Write the fields.
24377            self.0.encode(encoder, offset + 0, depth)?;
24378            self.1.encode(encoder, offset + 16, depth)?;
24379            self.2.encode(encoder, offset + 32, depth)?;
24380            Ok(())
24381        }
24382    }
24383
24384    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24385        for UsageGainReporterRegisterListenerRequest
24386    {
24387        #[inline(always)]
24388        fn new_empty() -> Self {
24389            Self {
24390                device_unique_id: fidl::new_empty!(
24391                    fidl::encoding::BoundedString<36>,
24392                    fidl::encoding::DefaultFuchsiaResourceDialect
24393                ),
24394                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24395                usage_gain_listener: fidl::new_empty!(
24396                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24397                    fidl::encoding::DefaultFuchsiaResourceDialect
24398                ),
24399            }
24400        }
24401
24402        #[inline]
24403        unsafe fn decode(
24404            &mut self,
24405            decoder: &mut fidl::encoding::Decoder<
24406                '_,
24407                fidl::encoding::DefaultFuchsiaResourceDialect,
24408            >,
24409            offset: usize,
24410            _depth: fidl::encoding::Depth,
24411        ) -> fidl::Result<()> {
24412            decoder.debug_check_bounds::<Self>(offset);
24413            // Verify that padding bytes are zero.
24414            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24415            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24416            let mask = 0xffffffff00000000u64;
24417            let maskedval = padval & mask;
24418            if maskedval != 0 {
24419                return Err(fidl::Error::NonZeroPadding {
24420                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24421                });
24422            }
24423            fidl::decode!(
24424                fidl::encoding::BoundedString<36>,
24425                fidl::encoding::DefaultFuchsiaResourceDialect,
24426                &mut self.device_unique_id,
24427                decoder,
24428                offset + 0,
24429                _depth
24430            )?;
24431            fidl::decode!(
24432                Usage,
24433                fidl::encoding::DefaultFuchsiaResourceDialect,
24434                &mut self.usage,
24435                decoder,
24436                offset + 16,
24437                _depth
24438            )?;
24439            fidl::decode!(
24440                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24441                fidl::encoding::DefaultFuchsiaResourceDialect,
24442                &mut self.usage_gain_listener,
24443                decoder,
24444                offset + 32,
24445                _depth
24446            )?;
24447            Ok(())
24448        }
24449    }
24450
24451    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
24452        type Borrowed<'a> = &'a mut Self;
24453        fn take_or_borrow<'a>(
24454            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24455        ) -> Self::Borrowed<'a> {
24456            value
24457        }
24458    }
24459
24460    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
24461        type Owned = Self;
24462
24463        #[inline(always)]
24464        fn inline_align(_context: fidl::encoding::Context) -> usize {
24465            8
24466        }
24467
24468        #[inline(always)]
24469        fn inline_size(_context: fidl::encoding::Context) -> usize {
24470            24
24471        }
24472    }
24473
24474    unsafe impl
24475        fidl::encoding::Encode<
24476            UsageReporterWatch2Request,
24477            fidl::encoding::DefaultFuchsiaResourceDialect,
24478        > for &mut UsageReporterWatch2Request
24479    {
24480        #[inline]
24481        unsafe fn encode(
24482            self,
24483            encoder: &mut fidl::encoding::Encoder<
24484                '_,
24485                fidl::encoding::DefaultFuchsiaResourceDialect,
24486            >,
24487            offset: usize,
24488            _depth: fidl::encoding::Depth,
24489        ) -> fidl::Result<()> {
24490            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24491            // Delegate to tuple encoding.
24492            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24493                (
24494                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24495                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24496                ),
24497                encoder, offset, _depth
24498            )
24499        }
24500    }
24501    unsafe impl<
24502        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24503        T1: fidl::encoding::Encode<
24504                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24505                fidl::encoding::DefaultFuchsiaResourceDialect,
24506            >,
24507    >
24508        fidl::encoding::Encode<
24509            UsageReporterWatch2Request,
24510            fidl::encoding::DefaultFuchsiaResourceDialect,
24511        > for (T0, T1)
24512    {
24513        #[inline]
24514        unsafe fn encode(
24515            self,
24516            encoder: &mut fidl::encoding::Encoder<
24517                '_,
24518                fidl::encoding::DefaultFuchsiaResourceDialect,
24519            >,
24520            offset: usize,
24521            depth: fidl::encoding::Depth,
24522        ) -> fidl::Result<()> {
24523            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24524            // Zero out padding regions. There's no need to apply masks
24525            // because the unmasked parts will be overwritten by fields.
24526            unsafe {
24527                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24528                (ptr as *mut u64).write_unaligned(0);
24529            }
24530            // Write the fields.
24531            self.0.encode(encoder, offset + 0, depth)?;
24532            self.1.encode(encoder, offset + 16, depth)?;
24533            Ok(())
24534        }
24535    }
24536
24537    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24538        for UsageReporterWatch2Request
24539    {
24540        #[inline(always)]
24541        fn new_empty() -> Self {
24542            Self {
24543                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24544                usage_watcher: fidl::new_empty!(
24545                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24546                    fidl::encoding::DefaultFuchsiaResourceDialect
24547                ),
24548            }
24549        }
24550
24551        #[inline]
24552        unsafe fn decode(
24553            &mut self,
24554            decoder: &mut fidl::encoding::Decoder<
24555                '_,
24556                fidl::encoding::DefaultFuchsiaResourceDialect,
24557            >,
24558            offset: usize,
24559            _depth: fidl::encoding::Depth,
24560        ) -> fidl::Result<()> {
24561            decoder.debug_check_bounds::<Self>(offset);
24562            // Verify that padding bytes are zero.
24563            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24564            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24565            let mask = 0xffffffff00000000u64;
24566            let maskedval = padval & mask;
24567            if maskedval != 0 {
24568                return Err(fidl::Error::NonZeroPadding {
24569                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24570                });
24571            }
24572            fidl::decode!(
24573                Usage2,
24574                fidl::encoding::DefaultFuchsiaResourceDialect,
24575                &mut self.usage,
24576                decoder,
24577                offset + 0,
24578                _depth
24579            )?;
24580            fidl::decode!(
24581                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24582                fidl::encoding::DefaultFuchsiaResourceDialect,
24583                &mut self.usage_watcher,
24584                decoder,
24585                offset + 16,
24586                _depth
24587            )?;
24588            Ok(())
24589        }
24590    }
24591
24592    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
24593        type Borrowed<'a> = &'a mut Self;
24594        fn take_or_borrow<'a>(
24595            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24596        ) -> Self::Borrowed<'a> {
24597            value
24598        }
24599    }
24600
24601    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
24602        type Owned = Self;
24603
24604        #[inline(always)]
24605        fn inline_align(_context: fidl::encoding::Context) -> usize {
24606            8
24607        }
24608
24609        #[inline(always)]
24610        fn inline_size(_context: fidl::encoding::Context) -> usize {
24611            24
24612        }
24613    }
24614
24615    unsafe impl
24616        fidl::encoding::Encode<
24617            UsageReporterWatchRequest,
24618            fidl::encoding::DefaultFuchsiaResourceDialect,
24619        > for &mut UsageReporterWatchRequest
24620    {
24621        #[inline]
24622        unsafe fn encode(
24623            self,
24624            encoder: &mut fidl::encoding::Encoder<
24625                '_,
24626                fidl::encoding::DefaultFuchsiaResourceDialect,
24627            >,
24628            offset: usize,
24629            _depth: fidl::encoding::Depth,
24630        ) -> fidl::Result<()> {
24631            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24632            // Delegate to tuple encoding.
24633            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24634                (
24635                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24636                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24637                ),
24638                encoder, offset, _depth
24639            )
24640        }
24641    }
24642    unsafe impl<
24643        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24644        T1: fidl::encoding::Encode<
24645                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24646                fidl::encoding::DefaultFuchsiaResourceDialect,
24647            >,
24648    >
24649        fidl::encoding::Encode<
24650            UsageReporterWatchRequest,
24651            fidl::encoding::DefaultFuchsiaResourceDialect,
24652        > for (T0, T1)
24653    {
24654        #[inline]
24655        unsafe fn encode(
24656            self,
24657            encoder: &mut fidl::encoding::Encoder<
24658                '_,
24659                fidl::encoding::DefaultFuchsiaResourceDialect,
24660            >,
24661            offset: usize,
24662            depth: fidl::encoding::Depth,
24663        ) -> fidl::Result<()> {
24664            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24665            // Zero out padding regions. There's no need to apply masks
24666            // because the unmasked parts will be overwritten by fields.
24667            unsafe {
24668                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24669                (ptr as *mut u64).write_unaligned(0);
24670            }
24671            // Write the fields.
24672            self.0.encode(encoder, offset + 0, depth)?;
24673            self.1.encode(encoder, offset + 16, depth)?;
24674            Ok(())
24675        }
24676    }
24677
24678    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24679        for UsageReporterWatchRequest
24680    {
24681        #[inline(always)]
24682        fn new_empty() -> Self {
24683            Self {
24684                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24685                usage_watcher: fidl::new_empty!(
24686                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24687                    fidl::encoding::DefaultFuchsiaResourceDialect
24688                ),
24689            }
24690        }
24691
24692        #[inline]
24693        unsafe fn decode(
24694            &mut self,
24695            decoder: &mut fidl::encoding::Decoder<
24696                '_,
24697                fidl::encoding::DefaultFuchsiaResourceDialect,
24698            >,
24699            offset: usize,
24700            _depth: fidl::encoding::Depth,
24701        ) -> fidl::Result<()> {
24702            decoder.debug_check_bounds::<Self>(offset);
24703            // Verify that padding bytes are zero.
24704            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24705            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24706            let mask = 0xffffffff00000000u64;
24707            let maskedval = padval & mask;
24708            if maskedval != 0 {
24709                return Err(fidl::Error::NonZeroPadding {
24710                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24711                });
24712            }
24713            fidl::decode!(
24714                Usage,
24715                fidl::encoding::DefaultFuchsiaResourceDialect,
24716                &mut self.usage,
24717                decoder,
24718                offset + 0,
24719                _depth
24720            )?;
24721            fidl::decode!(
24722                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24723                fidl::encoding::DefaultFuchsiaResourceDialect,
24724                &mut self.usage_watcher,
24725                decoder,
24726                offset + 16,
24727                _depth
24728            )?;
24729            Ok(())
24730        }
24731    }
24732
24733    impl StreamBufferPartialSettings {
24734        #[inline(always)]
24735        fn max_ordinal_present(&self) -> u64 {
24736            if let Some(_) = self.sysmem2_token {
24737                return 7;
24738            }
24739            if let Some(_) = self.sysmem_token {
24740                return 6;
24741            }
24742            if let Some(_) = self.packet_count_for_client {
24743                return 5;
24744            }
24745            if let Some(_) = self.packet_count_for_server {
24746                return 4;
24747            }
24748            if let Some(_) = self.single_buffer_mode {
24749                return 3;
24750            }
24751            if let Some(_) = self.buffer_constraints_version_ordinal {
24752                return 2;
24753            }
24754            if let Some(_) = self.buffer_lifetime_ordinal {
24755                return 1;
24756            }
24757            0
24758        }
24759    }
24760
24761    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
24762        type Borrowed<'a> = &'a mut Self;
24763        fn take_or_borrow<'a>(
24764            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24765        ) -> Self::Borrowed<'a> {
24766            value
24767        }
24768    }
24769
24770    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
24771        type Owned = Self;
24772
24773        #[inline(always)]
24774        fn inline_align(_context: fidl::encoding::Context) -> usize {
24775            8
24776        }
24777
24778        #[inline(always)]
24779        fn inline_size(_context: fidl::encoding::Context) -> usize {
24780            16
24781        }
24782    }
24783
24784    unsafe impl
24785        fidl::encoding::Encode<
24786            StreamBufferPartialSettings,
24787            fidl::encoding::DefaultFuchsiaResourceDialect,
24788        > for &mut StreamBufferPartialSettings
24789    {
24790        unsafe fn encode(
24791            self,
24792            encoder: &mut fidl::encoding::Encoder<
24793                '_,
24794                fidl::encoding::DefaultFuchsiaResourceDialect,
24795            >,
24796            offset: usize,
24797            mut depth: fidl::encoding::Depth,
24798        ) -> fidl::Result<()> {
24799            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
24800            // Vector header
24801            let max_ordinal: u64 = self.max_ordinal_present();
24802            encoder.write_num(max_ordinal, offset);
24803            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24804            // Calling encoder.out_of_line_offset(0) is not allowed.
24805            if max_ordinal == 0 {
24806                return Ok(());
24807            }
24808            depth.increment()?;
24809            let envelope_size = 8;
24810            let bytes_len = max_ordinal as usize * envelope_size;
24811            #[allow(unused_variables)]
24812            let offset = encoder.out_of_line_offset(bytes_len);
24813            let mut _prev_end_offset: usize = 0;
24814            if 1 > max_ordinal {
24815                return Ok(());
24816            }
24817
24818            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24819            // are envelope_size bytes.
24820            let cur_offset: usize = (1 - 1) * envelope_size;
24821
24822            // Zero reserved fields.
24823            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24824
24825            // Safety:
24826            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24827            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24828            //   envelope_size bytes, there is always sufficient room.
24829            fidl::encoding::encode_in_envelope_optional::<
24830                u64,
24831                fidl::encoding::DefaultFuchsiaResourceDialect,
24832            >(
24833                self.buffer_lifetime_ordinal
24834                    .as_ref()
24835                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24836                encoder,
24837                offset + cur_offset,
24838                depth,
24839            )?;
24840
24841            _prev_end_offset = cur_offset + envelope_size;
24842            if 2 > max_ordinal {
24843                return Ok(());
24844            }
24845
24846            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24847            // are envelope_size bytes.
24848            let cur_offset: usize = (2 - 1) * envelope_size;
24849
24850            // Zero reserved fields.
24851            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24852
24853            // Safety:
24854            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24855            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24856            //   envelope_size bytes, there is always sufficient room.
24857            fidl::encoding::encode_in_envelope_optional::<
24858                u64,
24859                fidl::encoding::DefaultFuchsiaResourceDialect,
24860            >(
24861                self.buffer_constraints_version_ordinal
24862                    .as_ref()
24863                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24864                encoder,
24865                offset + cur_offset,
24866                depth,
24867            )?;
24868
24869            _prev_end_offset = cur_offset + envelope_size;
24870            if 3 > max_ordinal {
24871                return Ok(());
24872            }
24873
24874            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24875            // are envelope_size bytes.
24876            let cur_offset: usize = (3 - 1) * envelope_size;
24877
24878            // Zero reserved fields.
24879            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24880
24881            // Safety:
24882            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24883            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24884            //   envelope_size bytes, there is always sufficient room.
24885            fidl::encoding::encode_in_envelope_optional::<
24886                bool,
24887                fidl::encoding::DefaultFuchsiaResourceDialect,
24888            >(
24889                self.single_buffer_mode
24890                    .as_ref()
24891                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
24892                encoder,
24893                offset + cur_offset,
24894                depth,
24895            )?;
24896
24897            _prev_end_offset = cur_offset + envelope_size;
24898            if 4 > max_ordinal {
24899                return Ok(());
24900            }
24901
24902            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24903            // are envelope_size bytes.
24904            let cur_offset: usize = (4 - 1) * envelope_size;
24905
24906            // Zero reserved fields.
24907            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24908
24909            // Safety:
24910            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24911            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24912            //   envelope_size bytes, there is always sufficient room.
24913            fidl::encoding::encode_in_envelope_optional::<
24914                u32,
24915                fidl::encoding::DefaultFuchsiaResourceDialect,
24916            >(
24917                self.packet_count_for_server
24918                    .as_ref()
24919                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24920                encoder,
24921                offset + cur_offset,
24922                depth,
24923            )?;
24924
24925            _prev_end_offset = cur_offset + envelope_size;
24926            if 5 > max_ordinal {
24927                return Ok(());
24928            }
24929
24930            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24931            // are envelope_size bytes.
24932            let cur_offset: usize = (5 - 1) * envelope_size;
24933
24934            // Zero reserved fields.
24935            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24936
24937            // Safety:
24938            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24939            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24940            //   envelope_size bytes, there is always sufficient room.
24941            fidl::encoding::encode_in_envelope_optional::<
24942                u32,
24943                fidl::encoding::DefaultFuchsiaResourceDialect,
24944            >(
24945                self.packet_count_for_client
24946                    .as_ref()
24947                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24948                encoder,
24949                offset + cur_offset,
24950                depth,
24951            )?;
24952
24953            _prev_end_offset = cur_offset + envelope_size;
24954            if 6 > max_ordinal {
24955                return Ok(());
24956            }
24957
24958            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24959            // are envelope_size bytes.
24960            let cur_offset: usize = (6 - 1) * envelope_size;
24961
24962            // Zero reserved fields.
24963            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24964
24965            // Safety:
24966            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24967            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24968            //   envelope_size bytes, there is always sufficient room.
24969            fidl::encoding::encode_in_envelope_optional::<
24970                fidl::encoding::Endpoint<
24971                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
24972                >,
24973                fidl::encoding::DefaultFuchsiaResourceDialect,
24974            >(
24975                self.sysmem_token.as_mut().map(
24976                    <fidl::encoding::Endpoint<
24977                        fidl::endpoints::ClientEnd<
24978                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
24979                        >,
24980                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
24981                ),
24982                encoder,
24983                offset + cur_offset,
24984                depth,
24985            )?;
24986
24987            _prev_end_offset = cur_offset + envelope_size;
24988            if 7 > max_ordinal {
24989                return Ok(());
24990            }
24991
24992            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24993            // are envelope_size bytes.
24994            let cur_offset: usize = (7 - 1) * envelope_size;
24995
24996            // Zero reserved fields.
24997            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24998
24999            // Safety:
25000            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25001            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25002            //   envelope_size bytes, there is always sufficient room.
25003            fidl::encoding::encode_in_envelope_optional::<
25004                fidl::encoding::Endpoint<
25005                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25006                >,
25007                fidl::encoding::DefaultFuchsiaResourceDialect,
25008            >(
25009                self.sysmem2_token.as_mut().map(
25010                    <fidl::encoding::Endpoint<
25011                        fidl::endpoints::ClientEnd<
25012                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25013                        >,
25014                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25015                ),
25016                encoder,
25017                offset + cur_offset,
25018                depth,
25019            )?;
25020
25021            _prev_end_offset = cur_offset + envelope_size;
25022
25023            Ok(())
25024        }
25025    }
25026
25027    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25028        for StreamBufferPartialSettings
25029    {
25030        #[inline(always)]
25031        fn new_empty() -> Self {
25032            Self::default()
25033        }
25034
25035        unsafe fn decode(
25036            &mut self,
25037            decoder: &mut fidl::encoding::Decoder<
25038                '_,
25039                fidl::encoding::DefaultFuchsiaResourceDialect,
25040            >,
25041            offset: usize,
25042            mut depth: fidl::encoding::Depth,
25043        ) -> fidl::Result<()> {
25044            decoder.debug_check_bounds::<Self>(offset);
25045            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
25046                None => return Err(fidl::Error::NotNullable),
25047                Some(len) => len,
25048            };
25049            // Calling decoder.out_of_line_offset(0) is not allowed.
25050            if len == 0 {
25051                return Ok(());
25052            };
25053            depth.increment()?;
25054            let envelope_size = 8;
25055            let bytes_len = len * envelope_size;
25056            let offset = decoder.out_of_line_offset(bytes_len)?;
25057            // Decode the envelope for each type.
25058            let mut _next_ordinal_to_read = 0;
25059            let mut next_offset = offset;
25060            let end_offset = offset + bytes_len;
25061            _next_ordinal_to_read += 1;
25062            if next_offset >= end_offset {
25063                return Ok(());
25064            }
25065
25066            // Decode unknown envelopes for gaps in ordinals.
25067            while _next_ordinal_to_read < 1 {
25068                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25069                _next_ordinal_to_read += 1;
25070                next_offset += envelope_size;
25071            }
25072
25073            let next_out_of_line = decoder.next_out_of_line();
25074            let handles_before = decoder.remaining_handles();
25075            if let Some((inlined, num_bytes, num_handles)) =
25076                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25077            {
25078                let member_inline_size =
25079                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25080                if inlined != (member_inline_size <= 4) {
25081                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25082                }
25083                let inner_offset;
25084                let mut inner_depth = depth.clone();
25085                if inlined {
25086                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25087                    inner_offset = next_offset;
25088                } else {
25089                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25090                    inner_depth.increment()?;
25091                }
25092                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
25093                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25094                });
25095                fidl::decode!(
25096                    u64,
25097                    fidl::encoding::DefaultFuchsiaResourceDialect,
25098                    val_ref,
25099                    decoder,
25100                    inner_offset,
25101                    inner_depth
25102                )?;
25103                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25104                {
25105                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25106                }
25107                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25108                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25109                }
25110            }
25111
25112            next_offset += envelope_size;
25113            _next_ordinal_to_read += 1;
25114            if next_offset >= end_offset {
25115                return Ok(());
25116            }
25117
25118            // Decode unknown envelopes for gaps in ordinals.
25119            while _next_ordinal_to_read < 2 {
25120                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25121                _next_ordinal_to_read += 1;
25122                next_offset += envelope_size;
25123            }
25124
25125            let next_out_of_line = decoder.next_out_of_line();
25126            let handles_before = decoder.remaining_handles();
25127            if let Some((inlined, num_bytes, num_handles)) =
25128                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25129            {
25130                let member_inline_size =
25131                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25132                if inlined != (member_inline_size <= 4) {
25133                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25134                }
25135                let inner_offset;
25136                let mut inner_depth = depth.clone();
25137                if inlined {
25138                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25139                    inner_offset = next_offset;
25140                } else {
25141                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25142                    inner_depth.increment()?;
25143                }
25144                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
25145                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25146                });
25147                fidl::decode!(
25148                    u64,
25149                    fidl::encoding::DefaultFuchsiaResourceDialect,
25150                    val_ref,
25151                    decoder,
25152                    inner_offset,
25153                    inner_depth
25154                )?;
25155                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25156                {
25157                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25158                }
25159                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25160                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25161                }
25162            }
25163
25164            next_offset += envelope_size;
25165            _next_ordinal_to_read += 1;
25166            if next_offset >= end_offset {
25167                return Ok(());
25168            }
25169
25170            // Decode unknown envelopes for gaps in ordinals.
25171            while _next_ordinal_to_read < 3 {
25172                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25173                _next_ordinal_to_read += 1;
25174                next_offset += envelope_size;
25175            }
25176
25177            let next_out_of_line = decoder.next_out_of_line();
25178            let handles_before = decoder.remaining_handles();
25179            if let Some((inlined, num_bytes, num_handles)) =
25180                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25181            {
25182                let member_inline_size =
25183                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25184                if inlined != (member_inline_size <= 4) {
25185                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25186                }
25187                let inner_offset;
25188                let mut inner_depth = depth.clone();
25189                if inlined {
25190                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25191                    inner_offset = next_offset;
25192                } else {
25193                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25194                    inner_depth.increment()?;
25195                }
25196                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
25197                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
25198                });
25199                fidl::decode!(
25200                    bool,
25201                    fidl::encoding::DefaultFuchsiaResourceDialect,
25202                    val_ref,
25203                    decoder,
25204                    inner_offset,
25205                    inner_depth
25206                )?;
25207                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25208                {
25209                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25210                }
25211                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25212                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25213                }
25214            }
25215
25216            next_offset += envelope_size;
25217            _next_ordinal_to_read += 1;
25218            if next_offset >= end_offset {
25219                return Ok(());
25220            }
25221
25222            // Decode unknown envelopes for gaps in ordinals.
25223            while _next_ordinal_to_read < 4 {
25224                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25225                _next_ordinal_to_read += 1;
25226                next_offset += envelope_size;
25227            }
25228
25229            let next_out_of_line = decoder.next_out_of_line();
25230            let handles_before = decoder.remaining_handles();
25231            if let Some((inlined, num_bytes, num_handles)) =
25232                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25233            {
25234                let member_inline_size =
25235                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25236                if inlined != (member_inline_size <= 4) {
25237                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25238                }
25239                let inner_offset;
25240                let mut inner_depth = depth.clone();
25241                if inlined {
25242                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25243                    inner_offset = next_offset;
25244                } else {
25245                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25246                    inner_depth.increment()?;
25247                }
25248                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
25249                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25250                });
25251                fidl::decode!(
25252                    u32,
25253                    fidl::encoding::DefaultFuchsiaResourceDialect,
25254                    val_ref,
25255                    decoder,
25256                    inner_offset,
25257                    inner_depth
25258                )?;
25259                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25260                {
25261                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25262                }
25263                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25264                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25265                }
25266            }
25267
25268            next_offset += envelope_size;
25269            _next_ordinal_to_read += 1;
25270            if next_offset >= end_offset {
25271                return Ok(());
25272            }
25273
25274            // Decode unknown envelopes for gaps in ordinals.
25275            while _next_ordinal_to_read < 5 {
25276                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25277                _next_ordinal_to_read += 1;
25278                next_offset += envelope_size;
25279            }
25280
25281            let next_out_of_line = decoder.next_out_of_line();
25282            let handles_before = decoder.remaining_handles();
25283            if let Some((inlined, num_bytes, num_handles)) =
25284                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25285            {
25286                let member_inline_size =
25287                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25288                if inlined != (member_inline_size <= 4) {
25289                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25290                }
25291                let inner_offset;
25292                let mut inner_depth = depth.clone();
25293                if inlined {
25294                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25295                    inner_offset = next_offset;
25296                } else {
25297                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25298                    inner_depth.increment()?;
25299                }
25300                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
25301                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25302                });
25303                fidl::decode!(
25304                    u32,
25305                    fidl::encoding::DefaultFuchsiaResourceDialect,
25306                    val_ref,
25307                    decoder,
25308                    inner_offset,
25309                    inner_depth
25310                )?;
25311                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25312                {
25313                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25314                }
25315                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25316                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25317                }
25318            }
25319
25320            next_offset += envelope_size;
25321            _next_ordinal_to_read += 1;
25322            if next_offset >= end_offset {
25323                return Ok(());
25324            }
25325
25326            // Decode unknown envelopes for gaps in ordinals.
25327            while _next_ordinal_to_read < 6 {
25328                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25329                _next_ordinal_to_read += 1;
25330                next_offset += envelope_size;
25331            }
25332
25333            let next_out_of_line = decoder.next_out_of_line();
25334            let handles_before = decoder.remaining_handles();
25335            if let Some((inlined, num_bytes, num_handles)) =
25336                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25337            {
25338                let member_inline_size = <fidl::encoding::Endpoint<
25339                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25340                > as fidl::encoding::TypeMarker>::inline_size(
25341                    decoder.context
25342                );
25343                if inlined != (member_inline_size <= 4) {
25344                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25345                }
25346                let inner_offset;
25347                let mut inner_depth = depth.clone();
25348                if inlined {
25349                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25350                    inner_offset = next_offset;
25351                } else {
25352                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25353                    inner_depth.increment()?;
25354                }
25355                let val_ref = self.sysmem_token.get_or_insert_with(|| {
25356                    fidl::new_empty!(
25357                        fidl::encoding::Endpoint<
25358                            fidl::endpoints::ClientEnd<
25359                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25360                            >,
25361                        >,
25362                        fidl::encoding::DefaultFuchsiaResourceDialect
25363                    )
25364                });
25365                fidl::decode!(
25366                    fidl::encoding::Endpoint<
25367                        fidl::endpoints::ClientEnd<
25368                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25369                        >,
25370                    >,
25371                    fidl::encoding::DefaultFuchsiaResourceDialect,
25372                    val_ref,
25373                    decoder,
25374                    inner_offset,
25375                    inner_depth
25376                )?;
25377                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25378                {
25379                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25380                }
25381                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25382                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25383                }
25384            }
25385
25386            next_offset += envelope_size;
25387            _next_ordinal_to_read += 1;
25388            if next_offset >= end_offset {
25389                return Ok(());
25390            }
25391
25392            // Decode unknown envelopes for gaps in ordinals.
25393            while _next_ordinal_to_read < 7 {
25394                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25395                _next_ordinal_to_read += 1;
25396                next_offset += envelope_size;
25397            }
25398
25399            let next_out_of_line = decoder.next_out_of_line();
25400            let handles_before = decoder.remaining_handles();
25401            if let Some((inlined, num_bytes, num_handles)) =
25402                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25403            {
25404                let member_inline_size = <fidl::encoding::Endpoint<
25405                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25406                > as fidl::encoding::TypeMarker>::inline_size(
25407                    decoder.context
25408                );
25409                if inlined != (member_inline_size <= 4) {
25410                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25411                }
25412                let inner_offset;
25413                let mut inner_depth = depth.clone();
25414                if inlined {
25415                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25416                    inner_offset = next_offset;
25417                } else {
25418                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25419                    inner_depth.increment()?;
25420                }
25421                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
25422                    fidl::new_empty!(
25423                        fidl::encoding::Endpoint<
25424                            fidl::endpoints::ClientEnd<
25425                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25426                            >,
25427                        >,
25428                        fidl::encoding::DefaultFuchsiaResourceDialect
25429                    )
25430                });
25431                fidl::decode!(
25432                    fidl::encoding::Endpoint<
25433                        fidl::endpoints::ClientEnd<
25434                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25435                        >,
25436                    >,
25437                    fidl::encoding::DefaultFuchsiaResourceDialect,
25438                    val_ref,
25439                    decoder,
25440                    inner_offset,
25441                    inner_depth
25442                )?;
25443                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25444                {
25445                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25446                }
25447                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25448                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25449                }
25450            }
25451
25452            next_offset += envelope_size;
25453
25454            // Decode the remaining unknown envelopes.
25455            while next_offset < end_offset {
25456                _next_ordinal_to_read += 1;
25457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25458                next_offset += envelope_size;
25459            }
25460
25461            Ok(())
25462        }
25463    }
25464}