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    #[non_exhaustive]
14552    _UnknownEvent {
14553        /// Ordinal of the event that was sent.
14554        ordinal: u64,
14555    },
14556}
14557
14558impl StreamProcessorEvent {
14559    #[allow(irrefutable_let_patterns)]
14560    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
14561        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
14562            Some((stream_lifetime_ordinal, error))
14563        } else {
14564            None
14565        }
14566    }
14567    #[allow(irrefutable_let_patterns)]
14568    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
14569        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
14570            Some((input_constraints))
14571        } else {
14572            None
14573        }
14574    }
14575    #[allow(irrefutable_let_patterns)]
14576    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
14577        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
14578            Some((output_config))
14579        } else {
14580            None
14581        }
14582    }
14583    #[allow(irrefutable_let_patterns)]
14584    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
14585        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
14586            Some((output_format))
14587        } else {
14588            None
14589        }
14590    }
14591    #[allow(irrefutable_let_patterns)]
14592    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
14593        if let StreamProcessorEvent::OnOutputPacket {
14594            output_packet,
14595            error_detected_before,
14596            error_detected_during,
14597        } = self
14598        {
14599            Some((output_packet, error_detected_before, error_detected_during))
14600        } else {
14601            None
14602        }
14603    }
14604    #[allow(irrefutable_let_patterns)]
14605    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
14606        if let StreamProcessorEvent::OnOutputEndOfStream {
14607            stream_lifetime_ordinal,
14608            error_detected_before,
14609        } = self
14610        {
14611            Some((stream_lifetime_ordinal, error_detected_before))
14612        } else {
14613            None
14614        }
14615    }
14616    #[allow(irrefutable_let_patterns)]
14617    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
14618        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
14619            Some((free_input_packet))
14620        } else {
14621            None
14622        }
14623    }
14624
14625    /// Decodes a message buffer as a [`StreamProcessorEvent`].
14626    fn decode(
14627        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14628    ) -> Result<StreamProcessorEvent, fidl::Error> {
14629        let (bytes, _handles) = buf.split_mut();
14630        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14631        debug_assert_eq!(tx_header.tx_id, 0);
14632        match tx_header.ordinal {
14633            0x77ccf70bb061cf8e => {
14634                let mut out = fidl::new_empty!(
14635                    StreamProcessorOnStreamFailedRequest,
14636                    fidl::encoding::DefaultFuchsiaResourceDialect
14637                );
14638                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14639                Ok((StreamProcessorEvent::OnStreamFailed {
14640                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14641                    error: out.error,
14642                }))
14643            }
14644            0x211da9966a8ca0 => {
14645                let mut out = fidl::new_empty!(
14646                    StreamProcessorOnInputConstraintsRequest,
14647                    fidl::encoding::DefaultFuchsiaResourceDialect
14648                );
14649                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14650                Ok((StreamProcessorEvent::OnInputConstraints {
14651                    input_constraints: out.input_constraints,
14652                }))
14653            }
14654            0x40d8234504c170f3 => {
14655                let mut out = fidl::new_empty!(
14656                    StreamProcessorOnOutputConstraintsRequest,
14657                    fidl::encoding::DefaultFuchsiaResourceDialect
14658                );
14659                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14660                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
14661            }
14662            0x131b77ae120360bc => {
14663                let mut out = fidl::new_empty!(
14664                    StreamProcessorOnOutputFormatRequest,
14665                    fidl::encoding::DefaultFuchsiaResourceDialect
14666                );
14667                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14668                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
14669            }
14670            0x5c2029be1090ce93 => {
14671                let mut out = fidl::new_empty!(
14672                    StreamProcessorOnOutputPacketRequest,
14673                    fidl::encoding::DefaultFuchsiaResourceDialect
14674                );
14675                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14676                Ok((StreamProcessorEvent::OnOutputPacket {
14677                    output_packet: out.output_packet,
14678                    error_detected_before: out.error_detected_before,
14679                    error_detected_during: out.error_detected_during,
14680                }))
14681            }
14682            0x3bb65d237cfa50e6 => {
14683                let mut out = fidl::new_empty!(
14684                    StreamProcessorOnOutputEndOfStreamRequest,
14685                    fidl::encoding::DefaultFuchsiaResourceDialect
14686                );
14687                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14688                Ok((StreamProcessorEvent::OnOutputEndOfStream {
14689                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
14690                    error_detected_before: out.error_detected_before,
14691                }))
14692            }
14693            0xeef799b28708bbd => {
14694                let mut out = fidl::new_empty!(
14695                    StreamProcessorOnFreeInputPacketRequest,
14696                    fidl::encoding::DefaultFuchsiaResourceDialect
14697                );
14698                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
14699                Ok((StreamProcessorEvent::OnFreeInputPacket {
14700                    free_input_packet: out.free_input_packet,
14701                }))
14702            }
14703            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
14704                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
14705            }
14706            _ => Err(fidl::Error::UnknownOrdinal {
14707                ordinal: tx_header.ordinal,
14708                protocol_name:
14709                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14710            }),
14711        }
14712    }
14713}
14714
14715/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
14716pub struct StreamProcessorRequestStream {
14717    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14718    is_terminated: bool,
14719}
14720
14721impl std::marker::Unpin for StreamProcessorRequestStream {}
14722
14723impl futures::stream::FusedStream for StreamProcessorRequestStream {
14724    fn is_terminated(&self) -> bool {
14725        self.is_terminated
14726    }
14727}
14728
14729impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
14730    type Protocol = StreamProcessorMarker;
14731    type ControlHandle = StreamProcessorControlHandle;
14732
14733    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
14734        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14735    }
14736
14737    fn control_handle(&self) -> Self::ControlHandle {
14738        StreamProcessorControlHandle { inner: self.inner.clone() }
14739    }
14740
14741    fn into_inner(
14742        self,
14743    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
14744    {
14745        (self.inner, self.is_terminated)
14746    }
14747
14748    fn from_inner(
14749        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
14750        is_terminated: bool,
14751    ) -> Self {
14752        Self { inner, is_terminated }
14753    }
14754}
14755
14756impl futures::Stream for StreamProcessorRequestStream {
14757    type Item = Result<StreamProcessorRequest, fidl::Error>;
14758
14759    fn poll_next(
14760        mut self: std::pin::Pin<&mut Self>,
14761        cx: &mut std::task::Context<'_>,
14762    ) -> std::task::Poll<Option<Self::Item>> {
14763        let this = &mut *self;
14764        if this.inner.check_shutdown(cx) {
14765            this.is_terminated = true;
14766            return std::task::Poll::Ready(None);
14767        }
14768        if this.is_terminated {
14769            panic!("polled StreamProcessorRequestStream after completion");
14770        }
14771        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
14772            |bytes, handles| {
14773                match this.inner.channel().read_etc(cx, bytes, handles) {
14774                    std::task::Poll::Ready(Ok(())) => {}
14775                    std::task::Poll::Pending => return std::task::Poll::Pending,
14776                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
14777                        this.is_terminated = true;
14778                        return std::task::Poll::Ready(None);
14779                    }
14780                    std::task::Poll::Ready(Err(e)) => {
14781                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14782                            e.into(),
14783                        ))));
14784                    }
14785                }
14786
14787                // A message has been received from the channel
14788                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14789
14790                std::task::Poll::Ready(Some(match header.ordinal {
14791                    0x3940929617dbf02b => {
14792                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14793                        let mut req = fidl::new_empty!(
14794                            fidl::encoding::EmptyPayload,
14795                            fidl::encoding::DefaultFuchsiaResourceDialect
14796                        );
14797                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14798                        let control_handle =
14799                            StreamProcessorControlHandle { inner: this.inner.clone() };
14800                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
14801                    }
14802                    0xb02e0663a40e4c4 => {
14803                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14804                        let mut req = fidl::new_empty!(
14805                            StreamProcessorSetInputBufferPartialSettingsRequest,
14806                            fidl::encoding::DefaultFuchsiaResourceDialect
14807                        );
14808                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14809                        let control_handle =
14810                            StreamProcessorControlHandle { inner: this.inner.clone() };
14811                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
14812                            input_settings: req.input_settings,
14813
14814                            control_handle,
14815                        })
14816                    }
14817                    0x118bb8c819a7bbbb => {
14818                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14819                        let mut req = fidl::new_empty!(
14820                            StreamProcessorSetOutputBufferPartialSettingsRequest,
14821                            fidl::encoding::DefaultFuchsiaResourceDialect
14822                        );
14823                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14824                        let control_handle =
14825                            StreamProcessorControlHandle { inner: this.inner.clone() };
14826                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
14827                            output_settings: req.output_settings,
14828
14829                            control_handle,
14830                        })
14831                    }
14832                    0x50529e5c680ae3ab => {
14833                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14834                        let mut req = fidl::new_empty!(
14835                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
14836                            fidl::encoding::DefaultFuchsiaResourceDialect
14837                        );
14838                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
14839                        let control_handle =
14840                            StreamProcessorControlHandle { inner: this.inner.clone() };
14841                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
14842                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
14843
14844                            control_handle,
14845                        })
14846                    }
14847                    0x2b62c3e26d0667e6 => {
14848                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14849                        let mut req = fidl::new_empty!(
14850                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
14851                            fidl::encoding::DefaultFuchsiaResourceDialect
14852                        );
14853                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14854                        let control_handle =
14855                            StreamProcessorControlHandle { inner: this.inner.clone() };
14856                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
14857                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14858
14859                            control_handle,
14860                        })
14861                    }
14862                    0x1d8a67522170ca07 => {
14863                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14864                        let mut req = fidl::new_empty!(
14865                            StreamProcessorCloseCurrentStreamRequest,
14866                            fidl::encoding::DefaultFuchsiaResourceDialect
14867                        );
14868                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14869                        let control_handle =
14870                            StreamProcessorControlHandle { inner: this.inner.clone() };
14871                        Ok(StreamProcessorRequest::CloseCurrentStream {
14872                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14873                            release_input_buffers: req.release_input_buffers,
14874                            release_output_buffers: req.release_output_buffers,
14875
14876                            control_handle,
14877                        })
14878                    }
14879                    0x4b3e44300b0ec6aa => {
14880                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14881                        let mut req = fidl::new_empty!(
14882                            fidl::encoding::EmptyPayload,
14883                            fidl::encoding::DefaultFuchsiaResourceDialect
14884                        );
14885                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14886                        let control_handle =
14887                            StreamProcessorControlHandle { inner: this.inner.clone() };
14888                        Ok(StreamProcessorRequest::Sync {
14889                            responder: StreamProcessorSyncResponder {
14890                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14891                                tx_id: header.tx_id,
14892                            },
14893                        })
14894                    }
14895                    0x32763632b94e0bd5 => {
14896                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14897                        let mut req = fidl::new_empty!(
14898                            StreamProcessorRecycleOutputPacketRequest,
14899                            fidl::encoding::DefaultFuchsiaResourceDialect
14900                        );
14901                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14902                        let control_handle =
14903                            StreamProcessorControlHandle { inner: this.inner.clone() };
14904                        Ok(StreamProcessorRequest::RecycleOutputPacket {
14905                            available_output_packet: req.available_output_packet,
14906
14907                            control_handle,
14908                        })
14909                    }
14910                    0x170dc0979d52231 => {
14911                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14912                        let mut req = fidl::new_empty!(
14913                            StreamProcessorQueueInputFormatDetailsRequest,
14914                            fidl::encoding::DefaultFuchsiaResourceDialect
14915                        );
14916                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
14917                        let control_handle =
14918                            StreamProcessorControlHandle { inner: this.inner.clone() };
14919                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
14920                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14921                            format_details: req.format_details,
14922
14923                            control_handle,
14924                        })
14925                    }
14926                    0x47173d2652d9df3b => {
14927                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14928                        let mut req = fidl::new_empty!(
14929                            StreamProcessorQueueInputPacketRequest,
14930                            fidl::encoding::DefaultFuchsiaResourceDialect
14931                        );
14932                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14933                        let control_handle =
14934                            StreamProcessorControlHandle { inner: this.inner.clone() };
14935                        Ok(StreamProcessorRequest::QueueInputPacket {
14936                            packet: req.packet,
14937
14938                            control_handle,
14939                        })
14940                    }
14941                    0x2051b6ad00f20b37 => {
14942                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14943                        let mut req = fidl::new_empty!(
14944                            StreamProcessorQueueInputEndOfStreamRequest,
14945                            fidl::encoding::DefaultFuchsiaResourceDialect
14946                        );
14947                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
14948                        let control_handle =
14949                            StreamProcessorControlHandle { inner: this.inner.clone() };
14950                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
14951                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
14952
14953                            control_handle,
14954                        })
14955                    }
14956                    _ if header.tx_id == 0
14957                        && header
14958                            .dynamic_flags()
14959                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
14960                    {
14961                        Ok(StreamProcessorRequest::_UnknownMethod {
14962                            ordinal: header.ordinal,
14963                            control_handle: StreamProcessorControlHandle {
14964                                inner: this.inner.clone(),
14965                            },
14966                            method_type: fidl::MethodType::OneWay,
14967                        })
14968                    }
14969                    _ if header
14970                        .dynamic_flags()
14971                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
14972                    {
14973                        this.inner.send_framework_err(
14974                            fidl::encoding::FrameworkErr::UnknownMethod,
14975                            header.tx_id,
14976                            header.ordinal,
14977                            header.dynamic_flags(),
14978                            (bytes, handles),
14979                        )?;
14980                        Ok(StreamProcessorRequest::_UnknownMethod {
14981                            ordinal: header.ordinal,
14982                            control_handle: StreamProcessorControlHandle {
14983                                inner: this.inner.clone(),
14984                            },
14985                            method_type: fidl::MethodType::TwoWay,
14986                        })
14987                    }
14988                    _ => Err(fidl::Error::UnknownOrdinal {
14989                        ordinal: header.ordinal,
14990                        protocol_name:
14991                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
14992                    }),
14993                }))
14994            },
14995        )
14996    }
14997}
14998
14999/// Overview of operation:
15000///
15001/// 1. Create
15002///   * create via CodecFactory - see CodecFactory
15003///   * create via LicenseSession - see LicenseSession
15004/// 2. Get input constraints
15005///   * OnInputConstraints() - sent unsolicited by stream processor shortly after
15006///     stream processor creation.
15007/// 3. Provide input buffers
15008///   * SetInputBufferPartialSettings()
15009/// 4. Deliver input data
15010///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
15011///     possibly working through all input packets repeatedly before...
15012/// 5. Get output constraints and format
15013///   * OnOutputConstraints()
15014///   * This is not sent until after at least one QueueInput* message is sent by
15015///     the client, even if the underlying processor behind the StreamProcessor
15016///     doesn't fundamentally need any input data to determine its output
15017///     constraints.  This server behavior prevents clients taking an incorrect
15018///     dependency on the output constraints showing up before input is
15019///     delivered.
15020///   * A client must tolerate this arriving as late as after substantial input
15021///     data has been delivered, including lots of input packet recycling via
15022///     OnFreeInputPacket().
15023///   * This message can arrive more than once before the first output data.
15024/// 6. Provide output buffers
15025///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
15026/// 7. Data flows, with optional EndOfStream
15027///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
15028///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
15029///
15030/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
15031/// very few capabilities) just in case the decoding SW has a vulnerability
15032/// which could be used to take over the StreamProcessor server.  Clients of the
15033/// stream processor interface using decoders and processing streams of separate
15034/// security contexts, to a greater extent than some other interfaces, need to
15035/// protect themselves against invalid server behavior, such as double-free of a
15036/// packet_index and any other invalid server behavior.  Having fed in
15037/// compressed data of one security context, don't place too much trust in a
15038/// single StreamProcessor instance to not mix data among any buffers that
15039/// StreamProcessor server has ever been told about.  Instead, create separate
15040/// StreamProcessor instances for use by security-separate client-side contexts.
15041/// While the picture for HW-based decoders looks somewhat different and is out
15042/// of scope of this paragraph, the client should always use separate
15043/// StreamProcessor instances for security-separate client-side contexts.
15044///
15045/// Descriptions of actions taken by methods of this protocol and the states of
15046/// things are given as if the methods are synchronously executed by the stream
15047/// processor server, but in reality, as is typical of FIDL interfaces, the
15048/// message processing is async.  The states described are to be read as the
15049/// state from the client's point of view unless otherwise stated.  Events
15050/// coming back from the server are of course delivered async, and a client that
15051/// processes more than one stream per StreamProcessor instance needs to care
15052/// whether a given event is from the current stream vs. some older
15053/// soon-to-be-gone stream.
15054///
15055/// The Sync() method's main purpose is to enable the client to robustly prevent
15056/// having both old and new buffers allocated in the system at the same time,
15057/// since media buffers can be significantly large, depending. The Sync() method
15058/// achieves this by only delivering it's response when all previous calls to
15059/// the StreamProcessor protocol have actually taken effect in the
15060/// StreamControl ordering domain. Sync() can also be used to wait for the
15061/// stream processor server to catch up if there's a possibility that a client
15062/// might otherwise get too far ahead of the StreamProcessor server, by for
15063/// example requesting creation of a large number of streams in a row.  It can
15064/// also be used during debugging to ensure that a stream processor server
15065/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
15066/// for correctness - only potentially required to de-overlap resource usage.
15067///
15068/// It's possible to re-use a StreamProcessor instance for another stream, and
15069/// doing so can sometimes skip over re-allocation of buffers. This can be a
15070/// useful thing to do for cases like seeking to a new location - at the
15071/// StreamProcessor interface that can look like switching to a new stream.
15072#[derive(Debug)]
15073pub enum StreamProcessorRequest {
15074    /// Permit the server to use OnStreamFailed() instead of the server just
15075    /// closing the whole StreamProcessor channel on stream failure.
15076    ///
15077    /// If the server hasn't seen this message by the time a stream fails, the
15078    /// server will close the StreamProcessor channel instead of sending
15079    /// OnStreamFailed().
15080    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
15081    /// This is the replacement for SetInputBufferSettings().
15082    ///
15083    /// When the client is using sysmem to allocate buffers, this message is
15084    /// used instead of SetInputBufferSettings()+AddInputBuffer().  Instead, a
15085    /// single SetInputBufferPartialSettings() provides the StreamProcessor with
15086    /// the client-specified input settings and a BufferCollectionToken which
15087    /// the StreamProcessor will use to convey constraints to sysmem.  Both the
15088    /// client and the StreamProcessor will be informed of the allocated buffers
15089    /// directly by sysmem via their BufferCollection channel (not via the
15090    /// StreamProcessor channel).
15091    ///
15092    /// The client must not QueueInput...() until after sysmem informs the client
15093    /// that buffer allocation has completed and was successful.
15094    ///
15095    /// The server should be prepared to see QueueInput...() before the server
15096    /// has necessarily heard from sysmem that the buffers are allocated - the
15097    /// server must tolerate either ordering, as the QueueInput...() and
15098    /// notification of sysmem allocation completion arrive on different
15099    /// channels, so the client having heard that allocation is complete doesn't
15100    /// mean the server knows that allocation is complete yet.  However, the
15101    /// server can expect that allocation is in fact complete and can expect to
15102    /// get the allocation information from sysmem immediately upon requesting
15103    /// the information from sysmem.
15104    SetInputBufferPartialSettings {
15105        input_settings: StreamBufferPartialSettings,
15106        control_handle: StreamProcessorControlHandle,
15107    },
15108    /// This is the replacement for SetOutputBufferSettings().
15109    ///
15110    /// When the client is using sysmem to allocate buffers, this message is
15111    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
15112    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
15113    /// with the client-specified output settings and a BufferCollectionToken
15114    /// which the StreamProcessor will use to convey constraints to sysmem.
15115    /// Both the client and the StreamProcessor will be informed of the
15116    /// allocated buffers directly by sysmem via their BufferCollection channel
15117    /// (not via the StreamProcessor channel).
15118    ///
15119    /// Configuring output buffers is _required_ after OnOutputConstraints() is
15120    /// received by the client with buffer_constraints_action_required true and
15121    /// stream_lifetime_ordinal equal to the client's current
15122    /// stream_lifetime_ordinal (even if there is an active stream), and is
15123    /// _permitted_ any time there is no current stream.
15124    ///
15125    /// Closing the current stream occurs on the StreamControl ordering domain,
15126    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15127    /// subsequent Sync() completion must be received by the client before the
15128    /// client knows that there's no longer a current stream.
15129    ///
15130    /// See also CompleteOutputBufferPartialSettings().
15131    SetOutputBufferPartialSettings {
15132        output_settings: StreamBufferPartialSettings,
15133        control_handle: StreamProcessorControlHandle,
15134    },
15135    /// After SetOutputBufferPartialSettings(), the server won't send
15136    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15137    /// OnOutputEndOfStream() until after the client sends
15138    /// CompleteOutputBufferPartialSettings().
15139    ///
15140    /// Some clients may be able to send
15141    /// CompleteOutputBufferPartialSettings() immediately after
15142    /// SetOutputBufferPartialSettings() - in that case the client needs to be
15143    /// prepared to receive output without knowing the buffer count or packet
15144    /// count yet - such clients may internally delay processing the received
15145    /// output until the client has heard from sysmem (which is when the client
15146    /// will learn the buffer count and packet count).
15147    ///
15148    /// Other clients may first wait for sysmem to allocate, prepare to receive
15149    /// output, and then send CompleteOutputBufferPartialSettings().
15150    CompleteOutputBufferPartialSettings {
15151        buffer_lifetime_ordinal: u64,
15152        control_handle: StreamProcessorControlHandle,
15153    },
15154    /// This message is optional.
15155    ///
15156    /// This message is only valid after QueueInputEndOfStream() for this stream.
15157    /// The stream_lifetime_ordinal input parameter must match the
15158    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15159    /// will close the channel.
15160    ///
15161    /// A client can use this message to flush through (not discard) the last
15162    /// input data of a stream so that the stream processor server generates
15163    /// corresponding output data for all the input data before the server moves
15164    /// on to the next stream, without forcing the client to wait for
15165    /// OnOutputEndOfStream() before queueing data of another stream.
15166    ///
15167    /// The difference between QueueInputEndOfStream() and
15168    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15169    /// from the client that there will not be any more input data for the
15170    /// stream (and this info is needed by some stream processors for the stream
15171    /// processor to ever emit the very last output data).  The
15172    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15173    /// later completely discarding the rest of the current stream by closing
15174    /// the current stream (with or without a stream switch).  In contrast,
15175    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15176    /// the previously-queued input data be processed including the logical
15177    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15178    /// before moving on to any newer stream - this essentially changes the
15179    /// close-stream handling from discard to flush-through for this stream
15180    /// only.
15181    ///
15182    /// A client using this message can start providing input data for a new
15183    /// stream without that causing discard of old stream data.  That's the
15184    /// purpose of this message - to allow a client to flush through (not
15185    /// discard) the old stream's last data (instead of the default when closing
15186    /// or switching streams which is discard).
15187    ///
15188    /// Because the old stream is not done processing yet and the old stream's
15189    /// data is not being discarded, the client must be prepared to continue to
15190    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15191    /// is done. The client will know the stream_lifetime_ordinal is done when
15192    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15193    /// closes.
15194    FlushEndOfStreamAndCloseStream {
15195        stream_lifetime_ordinal: u64,
15196        control_handle: StreamProcessorControlHandle,
15197    },
15198    /// This "closes" the current stream, leaving no current stream.  In
15199    /// addition, this message can optionally release input buffers or output
15200    /// buffers.
15201    ///
15202    /// If there has never been any active stream, the stream_lifetime_ordinal
15203    /// must be zero or the server will close the channel.  If there has been an
15204    /// active stream, the stream_lifetime_ordinal must be the most recent
15205    /// active stream whether that stream is still active or not.  Else the
15206    /// server will close the channel.
15207    ///
15208    /// Multiple of this message without any new active stream in between is not
15209    /// to be considered an error, which allows a client to use this message to
15210    /// close the current stream to stop wasting processing power on a stream the
15211    /// user no longer cares about, then later decide that buffers should be
15212    /// released and send this message again with release_input_buffers and/or
15213    /// release_output_buffers true to get the buffers released, if the client is
15214    /// interested in trying to avoid overlap in resource usage between old
15215    /// buffers and new buffers (not all clients are).
15216    ///
15217    /// See also Sync().
15218    CloseCurrentStream {
15219        stream_lifetime_ordinal: u64,
15220        release_input_buffers: bool,
15221        release_output_buffers: bool,
15222        control_handle: StreamProcessorControlHandle,
15223    },
15224    /// On completion, all previous StreamProcessor calls have done what they're
15225    /// going to do server-side, _except_ for processing of data queued using
15226    /// QueueInputPacket().
15227    ///
15228    /// The main purpose of this call is to enable the client to wait until
15229    /// CloseCurrentStream() with release_input_buffers and/or
15230    /// release_output_buffers set to true to take effect, before the client
15231    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15232    /// de-overlapping of resource usage can be worthwhile for media buffers
15233    /// which can consume resource types whose overall pools aren't necessarily
15234    /// vast in comparison to resources consumed.  Especially if a client is
15235    /// reconfiguring buffers multiple times.
15236    ///
15237    /// Note that Sync() prior to allocating new media buffers is not alone
15238    /// sufficient to achieve non-overlap of media buffer resource usage system
15239    /// wide, but it can be a useful part of achieving that.
15240    ///
15241    /// The Sync() transits the Output ordering domain and the StreamControl
15242    /// ordering domain, but not the InputData ordering domain.
15243    ///
15244    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15245    /// presently 10.  A client that stays <= 8 in-flight streams will
15246    /// comfortably stay under the limit of 10.  While the protocol permits
15247    /// repeated SetInputBufferSettings() and the like, a client that spams the
15248    /// channel can expect that the channel will just close if the server or the
15249    /// channel itself gets too far behind.
15250    Sync { responder: StreamProcessorSyncResponder },
15251    /// After the client is done with an output packet, the client needs to tell
15252    /// the stream processor that the output packet can be re-used for more
15253    /// output, via this method.
15254    ///
15255    /// It's not permitted to recycle an output packet that's already free with
15256    /// the stream processor server.  It's permitted but discouraged for a
15257    /// client to recycle an output packet that has been deallocated by an
15258    /// explicit or implicit output buffer de-configuration().  See
15259    /// buffer_lifetime_ordinal for more on that. A server must ignore any such
15260    /// stale RecycleOutputPacket() calls.
15261    RecycleOutputPacket {
15262        available_output_packet: PacketHeader,
15263        control_handle: StreamProcessorControlHandle,
15264    },
15265    /// If the input format details are still the same as specified during
15266    /// StreamProcessor creation, this message is unnecessary and does not need
15267    /// to be sent.
15268    ///
15269    /// If the stream doesn't exist yet, this message creates the stream.
15270    ///
15271    /// The server won't send OnOutputConstraints() until after the client has
15272    /// sent at least one QueueInput* message.
15273    ///
15274    /// All servers must permit QueueInputFormatDetails() at the start of a
15275    /// stream without failing, as long as the new format is supported by the
15276    /// StreamProcessor instance.  Technically this allows for a server to only
15277    /// support the exact input format set during StreamProcessor creation, and
15278    /// that is by design.  A client that tries to switch formats and gets a
15279    /// StreamProcessor channel failure should try again one more time with a
15280    /// fresh StreamProcessor instance created with CodecFactory using the new
15281    /// input format during creation, before giving up.
15282    ///
15283    /// These format details override the format details specified during stream
15284    /// processor creation for this stream only.  The next stream will default
15285    /// back to the format details set during stream processor creation.
15286    ///
15287    /// This message is permitted at the start of the first stream (just like at
15288    /// the start of any stream).  The format specified need not match what was
15289    /// specified during stream processor creation, but if it doesn't match, the
15290    /// StreamProcessor channel might close as described above.
15291    QueueInputFormatDetails {
15292        stream_lifetime_ordinal: u64,
15293        format_details: FormatDetails,
15294        control_handle: StreamProcessorControlHandle,
15295    },
15296    /// This message queues input data to the stream processor for processing.
15297    ///
15298    /// If the stream doesn't exist yet, this message creates the new stream.
15299    ///
15300    /// The server won't send OnOutputConstraints() until after the client has
15301    /// sent at least one QueueInput* message.
15302    ///
15303    /// The client must continue to deliver input data via this message even if
15304    /// the stream processor has not yet generated the first OnOutputConstraints(),
15305    /// and even if the StreamProcessor is generating OnFreeInputPacket() for
15306    /// previously-queued input packets.  The input data must continue as long
15307    /// as there are free packets to be assured that the server will ever
15308    /// generate the first OnOutputConstraints().
15309    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
15310    /// Inform the server that all QueueInputPacket() messages for this stream
15311    /// have been sent.
15312    ///
15313    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15314    /// or StreamProcessor channel closing), there will later be a corresponding
15315    /// OnOutputEndOfStream().
15316    ///
15317    /// The corresponding OnOutputEndOfStream() message will be generated only if
15318    /// the server finishes processing the stream before the server sees the
15319    /// client close the stream (such as by starting a new stream).  A way to
15320    /// force the server to finish the stream before closing is to use
15321    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before any
15322    /// new stream.  Another way to force the server to finish the stream before
15323    /// closing is to wait for the OnOutputEndOfStream() before taking any action
15324    /// that closes the stream.
15325    ///
15326    /// In addition to serving as an "EndOfStream" marker to make it obvious
15327    /// client-side when all input data has been processed, if a client never
15328    /// sends QueueInputEndOfStream(), no amount of waiting will necessarily
15329    /// result in all input data getting processed through to the output.  Some
15330    /// stream processors have some internally-delayed data which only gets
15331    /// pushed through by additional input data _or_ by this EndOfStream marker.
15332    /// In that sense, this message can be viewed as a flush-through at
15333    /// InputData domain level, but the flush-through only takes effect if the
15334    /// stream processor even gets that far before the stream is just closed at
15335    /// StreamControl domain level.  This message is not alone sufficient to act
15336    /// as an overall flush-through at StreamControl level. For that, send this
15337    /// message first and then send FlushEndOfStreamAndCloseStream() (at which
15338    /// point it becomes possible to queue input data for a new stream without
15339    /// causing discard of this older stream's data), or wait for the
15340    /// OnOutputEndOfStream() before closing the current stream.
15341    ///
15342    /// If a client sends QueueInputPacket(), QueueInputFormatDetails(),
15343    /// QueueInputEndOfStream() for this stream after the first
15344    /// QueueInputEndOfStream() for this stream, a server should close the
15345    /// StreamProcessor channel.
15346    QueueInputEndOfStream {
15347        stream_lifetime_ordinal: u64,
15348        control_handle: StreamProcessorControlHandle,
15349    },
15350    /// An interaction was received which does not match any known method.
15351    #[non_exhaustive]
15352    _UnknownMethod {
15353        /// Ordinal of the method that was called.
15354        ordinal: u64,
15355        control_handle: StreamProcessorControlHandle,
15356        method_type: fidl::MethodType,
15357    },
15358}
15359
15360impl StreamProcessorRequest {
15361    #[allow(irrefutable_let_patterns)]
15362    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
15363        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
15364            Some((control_handle))
15365        } else {
15366            None
15367        }
15368    }
15369
15370    #[allow(irrefutable_let_patterns)]
15371    pub fn into_set_input_buffer_partial_settings(
15372        self,
15373    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15374        if let StreamProcessorRequest::SetInputBufferPartialSettings {
15375            input_settings,
15376            control_handle,
15377        } = self
15378        {
15379            Some((input_settings, control_handle))
15380        } else {
15381            None
15382        }
15383    }
15384
15385    #[allow(irrefutable_let_patterns)]
15386    pub fn into_set_output_buffer_partial_settings(
15387        self,
15388    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
15389        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
15390            output_settings,
15391            control_handle,
15392        } = self
15393        {
15394            Some((output_settings, control_handle))
15395        } else {
15396            None
15397        }
15398    }
15399
15400    #[allow(irrefutable_let_patterns)]
15401    pub fn into_complete_output_buffer_partial_settings(
15402        self,
15403    ) -> Option<(u64, StreamProcessorControlHandle)> {
15404        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
15405            buffer_lifetime_ordinal,
15406            control_handle,
15407        } = self
15408        {
15409            Some((buffer_lifetime_ordinal, control_handle))
15410        } else {
15411            None
15412        }
15413    }
15414
15415    #[allow(irrefutable_let_patterns)]
15416    pub fn into_flush_end_of_stream_and_close_stream(
15417        self,
15418    ) -> Option<(u64, StreamProcessorControlHandle)> {
15419        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
15420            stream_lifetime_ordinal,
15421            control_handle,
15422        } = self
15423        {
15424            Some((stream_lifetime_ordinal, control_handle))
15425        } else {
15426            None
15427        }
15428    }
15429
15430    #[allow(irrefutable_let_patterns)]
15431    pub fn into_close_current_stream(
15432        self,
15433    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
15434        if let StreamProcessorRequest::CloseCurrentStream {
15435            stream_lifetime_ordinal,
15436            release_input_buffers,
15437            release_output_buffers,
15438            control_handle,
15439        } = self
15440        {
15441            Some((
15442                stream_lifetime_ordinal,
15443                release_input_buffers,
15444                release_output_buffers,
15445                control_handle,
15446            ))
15447        } else {
15448            None
15449        }
15450    }
15451
15452    #[allow(irrefutable_let_patterns)]
15453    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
15454        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
15455    }
15456
15457    #[allow(irrefutable_let_patterns)]
15458    pub fn into_recycle_output_packet(
15459        self,
15460    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
15461        if let StreamProcessorRequest::RecycleOutputPacket {
15462            available_output_packet,
15463            control_handle,
15464        } = self
15465        {
15466            Some((available_output_packet, control_handle))
15467        } else {
15468            None
15469        }
15470    }
15471
15472    #[allow(irrefutable_let_patterns)]
15473    pub fn into_queue_input_format_details(
15474        self,
15475    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
15476        if let StreamProcessorRequest::QueueInputFormatDetails {
15477            stream_lifetime_ordinal,
15478            format_details,
15479            control_handle,
15480        } = self
15481        {
15482            Some((stream_lifetime_ordinal, format_details, control_handle))
15483        } else {
15484            None
15485        }
15486    }
15487
15488    #[allow(irrefutable_let_patterns)]
15489    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
15490        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
15491            Some((packet, control_handle))
15492        } else {
15493            None
15494        }
15495    }
15496
15497    #[allow(irrefutable_let_patterns)]
15498    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
15499        if let StreamProcessorRequest::QueueInputEndOfStream {
15500            stream_lifetime_ordinal,
15501            control_handle,
15502        } = self
15503        {
15504            Some((stream_lifetime_ordinal, control_handle))
15505        } else {
15506            None
15507        }
15508    }
15509
15510    /// Name of the method defined in FIDL
15511    pub fn method_name(&self) -> &'static str {
15512        match *self {
15513            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
15514            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
15515                "set_input_buffer_partial_settings"
15516            }
15517            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
15518                "set_output_buffer_partial_settings"
15519            }
15520            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
15521                "complete_output_buffer_partial_settings"
15522            }
15523            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
15524                "flush_end_of_stream_and_close_stream"
15525            }
15526            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
15527            StreamProcessorRequest::Sync { .. } => "sync",
15528            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
15529            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
15530            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
15531            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
15532            StreamProcessorRequest::_UnknownMethod {
15533                method_type: fidl::MethodType::OneWay,
15534                ..
15535            } => "unknown one-way method",
15536            StreamProcessorRequest::_UnknownMethod {
15537                method_type: fidl::MethodType::TwoWay,
15538                ..
15539            } => "unknown two-way method",
15540        }
15541    }
15542}
15543
15544#[derive(Debug, Clone)]
15545pub struct StreamProcessorControlHandle {
15546    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
15547}
15548
15549impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
15550    fn shutdown(&self) {
15551        self.inner.shutdown()
15552    }
15553
15554    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
15555        self.inner.shutdown_with_epitaph(status)
15556    }
15557
15558    fn is_closed(&self) -> bool {
15559        self.inner.channel().is_closed()
15560    }
15561    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
15562        self.inner.channel().on_closed()
15563    }
15564
15565    #[cfg(target_os = "fuchsia")]
15566    fn signal_peer(
15567        &self,
15568        clear_mask: zx::Signals,
15569        set_mask: zx::Signals,
15570    ) -> Result<(), zx_status::Status> {
15571        use fidl::Peered;
15572        self.inner.channel().signal_peer(clear_mask, set_mask)
15573    }
15574}
15575
15576impl StreamProcessorControlHandle {
15577    pub fn send_on_stream_failed(
15578        &self,
15579        mut stream_lifetime_ordinal: u64,
15580        mut error: StreamError,
15581    ) -> Result<(), fidl::Error> {
15582        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
15583            (stream_lifetime_ordinal, error),
15584            0,
15585            0x77ccf70bb061cf8e,
15586            fidl::encoding::DynamicFlags::empty(),
15587        )
15588    }
15589
15590    pub fn send_on_input_constraints(
15591        &self,
15592        mut input_constraints: &StreamBufferConstraints,
15593    ) -> Result<(), fidl::Error> {
15594        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
15595            (input_constraints,),
15596            0,
15597            0x211da9966a8ca0,
15598            fidl::encoding::DynamicFlags::empty(),
15599        )
15600    }
15601
15602    pub fn send_on_output_constraints(
15603        &self,
15604        mut output_config: &StreamOutputConstraints,
15605    ) -> Result<(), fidl::Error> {
15606        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
15607            (output_config,),
15608            0,
15609            0x40d8234504c170f3,
15610            fidl::encoding::DynamicFlags::empty(),
15611        )
15612    }
15613
15614    pub fn send_on_output_format(
15615        &self,
15616        mut output_format: &StreamOutputFormat,
15617    ) -> Result<(), fidl::Error> {
15618        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
15619            (output_format,),
15620            0,
15621            0x131b77ae120360bc,
15622            fidl::encoding::DynamicFlags::empty(),
15623        )
15624    }
15625
15626    pub fn send_on_output_packet(
15627        &self,
15628        mut output_packet: &Packet,
15629        mut error_detected_before: bool,
15630        mut error_detected_during: bool,
15631    ) -> Result<(), fidl::Error> {
15632        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
15633            (output_packet, error_detected_before, error_detected_during),
15634            0,
15635            0x5c2029be1090ce93,
15636            fidl::encoding::DynamicFlags::empty(),
15637        )
15638    }
15639
15640    pub fn send_on_output_end_of_stream(
15641        &self,
15642        mut stream_lifetime_ordinal: u64,
15643        mut error_detected_before: bool,
15644    ) -> Result<(), fidl::Error> {
15645        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
15646            (stream_lifetime_ordinal, error_detected_before),
15647            0,
15648            0x3bb65d237cfa50e6,
15649            fidl::encoding::DynamicFlags::empty(),
15650        )
15651    }
15652
15653    pub fn send_on_free_input_packet(
15654        &self,
15655        mut free_input_packet: &PacketHeader,
15656    ) -> Result<(), fidl::Error> {
15657        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
15658            (free_input_packet,),
15659            0,
15660            0xeef799b28708bbd,
15661            fidl::encoding::DynamicFlags::empty(),
15662        )
15663    }
15664}
15665
15666#[must_use = "FIDL methods require a response to be sent"]
15667#[derive(Debug)]
15668pub struct StreamProcessorSyncResponder {
15669    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
15670    tx_id: u32,
15671}
15672
15673/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
15674/// if the responder is dropped without sending a response, so that the client
15675/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15676impl std::ops::Drop for StreamProcessorSyncResponder {
15677    fn drop(&mut self) {
15678        self.control_handle.shutdown();
15679        // Safety: drops once, never accessed again
15680        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15681    }
15682}
15683
15684impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
15685    type ControlHandle = StreamProcessorControlHandle;
15686
15687    fn control_handle(&self) -> &StreamProcessorControlHandle {
15688        &self.control_handle
15689    }
15690
15691    fn drop_without_shutdown(mut self) {
15692        // Safety: drops once, never accessed again due to mem::forget
15693        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15694        // Prevent Drop from running (which would shut down the channel)
15695        std::mem::forget(self);
15696    }
15697}
15698
15699impl StreamProcessorSyncResponder {
15700    /// Sends a response to the FIDL transaction.
15701    ///
15702    /// Sets the channel to shutdown if an error occurs.
15703    pub fn send(self) -> Result<(), fidl::Error> {
15704        let _result = self.send_raw();
15705        if _result.is_err() {
15706            self.control_handle.shutdown();
15707        }
15708        self.drop_without_shutdown();
15709        _result
15710    }
15711
15712    /// Similar to "send" but does not shutdown the channel if an error occurs.
15713    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15714        let _result = self.send_raw();
15715        self.drop_without_shutdown();
15716        _result
15717    }
15718
15719    fn send_raw(&self) -> Result<(), fidl::Error> {
15720        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15721            (),
15722            self.tx_id,
15723            0x4b3e44300b0ec6aa,
15724            fidl::encoding::DynamicFlags::empty(),
15725        )
15726    }
15727}
15728
15729#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15730pub struct StreamSinkMarker;
15731
15732impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
15733    type Proxy = StreamSinkProxy;
15734    type RequestStream = StreamSinkRequestStream;
15735    #[cfg(target_os = "fuchsia")]
15736    type SynchronousProxy = StreamSinkSynchronousProxy;
15737
15738    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
15739}
15740
15741pub trait StreamSinkProxyInterface: Send + Sync {
15742    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15743    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
15744    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
15745    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
15746    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
15747    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
15748    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
15749}
15750#[derive(Debug)]
15751#[cfg(target_os = "fuchsia")]
15752pub struct StreamSinkSynchronousProxy {
15753    client: fidl::client::sync::Client,
15754}
15755
15756#[cfg(target_os = "fuchsia")]
15757impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
15758    type Proxy = StreamSinkProxy;
15759    type Protocol = StreamSinkMarker;
15760
15761    fn from_channel(inner: fidl::Channel) -> Self {
15762        Self::new(inner)
15763    }
15764
15765    fn into_channel(self) -> fidl::Channel {
15766        self.client.into_channel()
15767    }
15768
15769    fn as_channel(&self) -> &fidl::Channel {
15770        self.client.as_channel()
15771    }
15772}
15773
15774#[cfg(target_os = "fuchsia")]
15775impl StreamSinkSynchronousProxy {
15776    pub fn new(channel: fidl::Channel) -> Self {
15777        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15778        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
15779    }
15780
15781    pub fn into_channel(self) -> fidl::Channel {
15782        self.client.into_channel()
15783    }
15784
15785    /// Waits until an event arrives and returns it. It is safe for other
15786    /// threads to make concurrent requests while waiting for an event.
15787    pub fn wait_for_event(
15788        &self,
15789        deadline: zx::MonotonicInstant,
15790    ) -> Result<StreamSinkEvent, fidl::Error> {
15791        StreamSinkEvent::decode(self.client.wait_for_event(deadline)?)
15792    }
15793
15794    /// Sends a packet to the service. The response is sent when the service is
15795    /// done with the associated payload memory.
15796    ///
15797    /// `packet` must be valid for the current buffer set, otherwise the service
15798    /// will close the connection.
15799    pub fn r#send_packet(
15800        &self,
15801        mut packet: &StreamPacket,
15802        ___deadline: zx::MonotonicInstant,
15803    ) -> Result<(), fidl::Error> {
15804        let _response =
15805            self.client.send_query::<StreamSinkSendPacketRequest, fidl::encoding::EmptyPayload>(
15806                (packet,),
15807                0x67cddd607442775f,
15808                fidl::encoding::DynamicFlags::empty(),
15809                ___deadline,
15810            )?;
15811        Ok(_response)
15812    }
15813
15814    /// Sends a packet to the service. This interface doesn't define how the
15815    /// client knows when the sink is done with the associated payload memory.
15816    /// The inheriting interface must define that.
15817    ///
15818    /// `packet` must be valid for the current buffer set, otherwise the service
15819    /// will close the connection.
15820    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15821        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15822            (packet,),
15823            0x8d9b8b413ceba9d,
15824            fidl::encoding::DynamicFlags::empty(),
15825        )
15826    }
15827
15828    /// Indicates the stream has ended. The precise semantics of this method are
15829    /// determined by the inheriting interface.
15830    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15831        self.client.send::<fidl::encoding::EmptyPayload>(
15832            (),
15833            0x6180fd6f7e793b71,
15834            fidl::encoding::DynamicFlags::empty(),
15835        )
15836    }
15837
15838    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15839    /// and not yet released. The response is sent after all packets have been
15840    /// released.
15841    pub fn r#discard_all_packets(
15842        &self,
15843        ___deadline: zx::MonotonicInstant,
15844    ) -> Result<(), fidl::Error> {
15845        let _response =
15846            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
15847                (),
15848                0x6f4dad7af2917665,
15849                fidl::encoding::DynamicFlags::empty(),
15850                ___deadline,
15851            )?;
15852        Ok(_response)
15853    }
15854
15855    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15856    /// and not yet released.
15857    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15858        self.client.send::<fidl::encoding::EmptyPayload>(
15859            (),
15860            0x50d36d0d23081bc4,
15861            fidl::encoding::DynamicFlags::empty(),
15862        )
15863    }
15864}
15865
15866#[cfg(target_os = "fuchsia")]
15867impl From<StreamSinkSynchronousProxy> for zx::NullableHandle {
15868    fn from(value: StreamSinkSynchronousProxy) -> Self {
15869        value.into_channel().into()
15870    }
15871}
15872
15873#[cfg(target_os = "fuchsia")]
15874impl From<fidl::Channel> for StreamSinkSynchronousProxy {
15875    fn from(value: fidl::Channel) -> Self {
15876        Self::new(value)
15877    }
15878}
15879
15880#[cfg(target_os = "fuchsia")]
15881impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
15882    type Protocol = StreamSinkMarker;
15883
15884    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
15885        Self::new(value.into_channel())
15886    }
15887}
15888
15889#[derive(Debug, Clone)]
15890pub struct StreamSinkProxy {
15891    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
15892}
15893
15894impl fidl::endpoints::Proxy for StreamSinkProxy {
15895    type Protocol = StreamSinkMarker;
15896
15897    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
15898        Self::new(inner)
15899    }
15900
15901    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
15902        self.client.into_channel().map_err(|client| Self { client })
15903    }
15904
15905    fn as_channel(&self) -> &::fidl::AsyncChannel {
15906        self.client.as_channel()
15907    }
15908}
15909
15910impl StreamSinkProxy {
15911    /// Create a new Proxy for fuchsia.media/StreamSink.
15912    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
15913        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
15914        Self { client: fidl::client::Client::new(channel, protocol_name) }
15915    }
15916
15917    /// Get a Stream of events from the remote end of the protocol.
15918    ///
15919    /// # Panics
15920    ///
15921    /// Panics if the event stream was already taken.
15922    pub fn take_event_stream(&self) -> StreamSinkEventStream {
15923        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
15924    }
15925
15926    /// Sends a packet to the service. The response is sent when the service is
15927    /// done with the associated payload memory.
15928    ///
15929    /// `packet` must be valid for the current buffer set, otherwise the service
15930    /// will close the connection.
15931    pub fn r#send_packet(
15932        &self,
15933        mut packet: &StreamPacket,
15934    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15935        StreamSinkProxyInterface::r#send_packet(self, packet)
15936    }
15937
15938    /// Sends a packet to the service. This interface doesn't define how the
15939    /// client knows when the sink is done with the associated payload memory.
15940    /// The inheriting interface must define that.
15941    ///
15942    /// `packet` must be valid for the current buffer set, otherwise the service
15943    /// will close the connection.
15944    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15945        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
15946    }
15947
15948    /// Indicates the stream has ended. The precise semantics of this method are
15949    /// determined by the inheriting interface.
15950    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
15951        StreamSinkProxyInterface::r#end_of_stream(self)
15952    }
15953
15954    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15955    /// and not yet released. The response is sent after all packets have been
15956    /// released.
15957    pub fn r#discard_all_packets(
15958        &self,
15959    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15960        StreamSinkProxyInterface::r#discard_all_packets(self)
15961    }
15962
15963    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
15964    /// and not yet released.
15965    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15966        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
15967    }
15968}
15969
15970impl StreamSinkProxyInterface for StreamSinkProxy {
15971    type SendPacketResponseFut =
15972        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15973    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
15974        fn _decode(
15975            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15976        ) -> Result<(), fidl::Error> {
15977            let _response = fidl::client::decode_transaction_body::<
15978                fidl::encoding::EmptyPayload,
15979                fidl::encoding::DefaultFuchsiaResourceDialect,
15980                0x67cddd607442775f,
15981            >(_buf?)?;
15982            Ok(_response)
15983        }
15984        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
15985            (packet,),
15986            0x67cddd607442775f,
15987            fidl::encoding::DynamicFlags::empty(),
15988            _decode,
15989        )
15990    }
15991
15992    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15993        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
15994            (packet,),
15995            0x8d9b8b413ceba9d,
15996            fidl::encoding::DynamicFlags::empty(),
15997        )
15998    }
15999
16000    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
16001        self.client.send::<fidl::encoding::EmptyPayload>(
16002            (),
16003            0x6180fd6f7e793b71,
16004            fidl::encoding::DynamicFlags::empty(),
16005        )
16006    }
16007
16008    type DiscardAllPacketsResponseFut =
16009        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16010    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16011        fn _decode(
16012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16013        ) -> Result<(), fidl::Error> {
16014            let _response = fidl::client::decode_transaction_body::<
16015                fidl::encoding::EmptyPayload,
16016                fidl::encoding::DefaultFuchsiaResourceDialect,
16017                0x6f4dad7af2917665,
16018            >(_buf?)?;
16019            Ok(_response)
16020        }
16021        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16022            (),
16023            0x6f4dad7af2917665,
16024            fidl::encoding::DynamicFlags::empty(),
16025            _decode,
16026        )
16027    }
16028
16029    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16030        self.client.send::<fidl::encoding::EmptyPayload>(
16031            (),
16032            0x50d36d0d23081bc4,
16033            fidl::encoding::DynamicFlags::empty(),
16034        )
16035    }
16036}
16037
16038pub struct StreamSinkEventStream {
16039    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16040}
16041
16042impl std::marker::Unpin for StreamSinkEventStream {}
16043
16044impl futures::stream::FusedStream for StreamSinkEventStream {
16045    fn is_terminated(&self) -> bool {
16046        self.event_receiver.is_terminated()
16047    }
16048}
16049
16050impl futures::Stream for StreamSinkEventStream {
16051    type Item = Result<StreamSinkEvent, fidl::Error>;
16052
16053    fn poll_next(
16054        mut self: std::pin::Pin<&mut Self>,
16055        cx: &mut std::task::Context<'_>,
16056    ) -> std::task::Poll<Option<Self::Item>> {
16057        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16058            &mut self.event_receiver,
16059            cx
16060        )?) {
16061            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
16062            None => std::task::Poll::Ready(None),
16063        }
16064    }
16065}
16066
16067#[derive(Debug)]
16068pub enum StreamSinkEvent {}
16069
16070impl StreamSinkEvent {
16071    /// Decodes a message buffer as a [`StreamSinkEvent`].
16072    fn decode(
16073        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16074    ) -> Result<StreamSinkEvent, fidl::Error> {
16075        let (bytes, _handles) = buf.split_mut();
16076        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16077        debug_assert_eq!(tx_header.tx_id, 0);
16078        match tx_header.ordinal {
16079            _ => Err(fidl::Error::UnknownOrdinal {
16080                ordinal: tx_header.ordinal,
16081                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16082            }),
16083        }
16084    }
16085}
16086
16087/// A Stream of incoming requests for fuchsia.media/StreamSink.
16088pub struct StreamSinkRequestStream {
16089    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16090    is_terminated: bool,
16091}
16092
16093impl std::marker::Unpin for StreamSinkRequestStream {}
16094
16095impl futures::stream::FusedStream for StreamSinkRequestStream {
16096    fn is_terminated(&self) -> bool {
16097        self.is_terminated
16098    }
16099}
16100
16101impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
16102    type Protocol = StreamSinkMarker;
16103    type ControlHandle = StreamSinkControlHandle;
16104
16105    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16106        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16107    }
16108
16109    fn control_handle(&self) -> Self::ControlHandle {
16110        StreamSinkControlHandle { inner: self.inner.clone() }
16111    }
16112
16113    fn into_inner(
16114        self,
16115    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16116    {
16117        (self.inner, self.is_terminated)
16118    }
16119
16120    fn from_inner(
16121        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16122        is_terminated: bool,
16123    ) -> Self {
16124        Self { inner, is_terminated }
16125    }
16126}
16127
16128impl futures::Stream for StreamSinkRequestStream {
16129    type Item = Result<StreamSinkRequest, fidl::Error>;
16130
16131    fn poll_next(
16132        mut self: std::pin::Pin<&mut Self>,
16133        cx: &mut std::task::Context<'_>,
16134    ) -> std::task::Poll<Option<Self::Item>> {
16135        let this = &mut *self;
16136        if this.inner.check_shutdown(cx) {
16137            this.is_terminated = true;
16138            return std::task::Poll::Ready(None);
16139        }
16140        if this.is_terminated {
16141            panic!("polled StreamSinkRequestStream after completion");
16142        }
16143        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16144            |bytes, handles| {
16145                match this.inner.channel().read_etc(cx, bytes, handles) {
16146                    std::task::Poll::Ready(Ok(())) => {}
16147                    std::task::Poll::Pending => return std::task::Poll::Pending,
16148                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16149                        this.is_terminated = true;
16150                        return std::task::Poll::Ready(None);
16151                    }
16152                    std::task::Poll::Ready(Err(e)) => {
16153                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16154                            e.into(),
16155                        ))));
16156                    }
16157                }
16158
16159                // A message has been received from the channel
16160                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16161
16162                std::task::Poll::Ready(Some(match header.ordinal {
16163                    0x67cddd607442775f => {
16164                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16165                        let mut req = fidl::new_empty!(
16166                            StreamSinkSendPacketRequest,
16167                            fidl::encoding::DefaultFuchsiaResourceDialect
16168                        );
16169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16170                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16171                        Ok(StreamSinkRequest::SendPacket {
16172                            packet: req.packet,
16173
16174                            responder: StreamSinkSendPacketResponder {
16175                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16176                                tx_id: header.tx_id,
16177                            },
16178                        })
16179                    }
16180                    0x8d9b8b413ceba9d => {
16181                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16182                        let mut req = fidl::new_empty!(
16183                            StreamSinkSendPacketNoReplyRequest,
16184                            fidl::encoding::DefaultFuchsiaResourceDialect
16185                        );
16186                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
16187                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16188                        Ok(StreamSinkRequest::SendPacketNoReply {
16189                            packet: req.packet,
16190
16191                            control_handle,
16192                        })
16193                    }
16194                    0x6180fd6f7e793b71 => {
16195                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16196                        let mut req = fidl::new_empty!(
16197                            fidl::encoding::EmptyPayload,
16198                            fidl::encoding::DefaultFuchsiaResourceDialect
16199                        );
16200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16201                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16202                        Ok(StreamSinkRequest::EndOfStream { control_handle })
16203                    }
16204                    0x6f4dad7af2917665 => {
16205                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16206                        let mut req = fidl::new_empty!(
16207                            fidl::encoding::EmptyPayload,
16208                            fidl::encoding::DefaultFuchsiaResourceDialect
16209                        );
16210                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16211                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16212                        Ok(StreamSinkRequest::DiscardAllPackets {
16213                            responder: StreamSinkDiscardAllPacketsResponder {
16214                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16215                                tx_id: header.tx_id,
16216                            },
16217                        })
16218                    }
16219                    0x50d36d0d23081bc4 => {
16220                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16221                        let mut req = fidl::new_empty!(
16222                            fidl::encoding::EmptyPayload,
16223                            fidl::encoding::DefaultFuchsiaResourceDialect
16224                        );
16225                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16226                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
16227                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
16228                    }
16229                    _ => Err(fidl::Error::UnknownOrdinal {
16230                        ordinal: header.ordinal,
16231                        protocol_name:
16232                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16233                    }),
16234                }))
16235            },
16236        )
16237    }
16238}
16239
16240/// Consumes a stream of packets. This interface is typically inherited along
16241/// with `StreamBufferSet` to enable the transport of elementary streams from
16242/// clients to services.
16243#[derive(Debug)]
16244pub enum StreamSinkRequest {
16245    /// Sends a packet to the service. The response is sent when the service is
16246    /// done with the associated payload memory.
16247    ///
16248    /// `packet` must be valid for the current buffer set, otherwise the service
16249    /// will close the connection.
16250    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
16251    /// Sends a packet to the service. This interface doesn't define how the
16252    /// client knows when the sink is done with the associated payload memory.
16253    /// The inheriting interface must define that.
16254    ///
16255    /// `packet` must be valid for the current buffer set, otherwise the service
16256    /// will close the connection.
16257    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
16258    /// Indicates the stream has ended. The precise semantics of this method are
16259    /// determined by the inheriting interface.
16260    EndOfStream { control_handle: StreamSinkControlHandle },
16261    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16262    /// and not yet released. The response is sent after all packets have been
16263    /// released.
16264    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
16265    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
16266    /// and not yet released.
16267    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
16268}
16269
16270impl StreamSinkRequest {
16271    #[allow(irrefutable_let_patterns)]
16272    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
16273        if let StreamSinkRequest::SendPacket { packet, responder } = self {
16274            Some((packet, responder))
16275        } else {
16276            None
16277        }
16278    }
16279
16280    #[allow(irrefutable_let_patterns)]
16281    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
16282        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
16283            Some((packet, control_handle))
16284        } else {
16285            None
16286        }
16287    }
16288
16289    #[allow(irrefutable_let_patterns)]
16290    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
16291        if let StreamSinkRequest::EndOfStream { control_handle } = self {
16292            Some((control_handle))
16293        } else {
16294            None
16295        }
16296    }
16297
16298    #[allow(irrefutable_let_patterns)]
16299    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
16300        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
16301            Some((responder))
16302        } else {
16303            None
16304        }
16305    }
16306
16307    #[allow(irrefutable_let_patterns)]
16308    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
16309        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
16310            Some((control_handle))
16311        } else {
16312            None
16313        }
16314    }
16315
16316    /// Name of the method defined in FIDL
16317    pub fn method_name(&self) -> &'static str {
16318        match *self {
16319            StreamSinkRequest::SendPacket { .. } => "send_packet",
16320            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
16321            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
16322            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
16323            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16324        }
16325    }
16326}
16327
16328#[derive(Debug, Clone)]
16329pub struct StreamSinkControlHandle {
16330    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16331}
16332
16333impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
16334    fn shutdown(&self) {
16335        self.inner.shutdown()
16336    }
16337
16338    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16339        self.inner.shutdown_with_epitaph(status)
16340    }
16341
16342    fn is_closed(&self) -> bool {
16343        self.inner.channel().is_closed()
16344    }
16345    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16346        self.inner.channel().on_closed()
16347    }
16348
16349    #[cfg(target_os = "fuchsia")]
16350    fn signal_peer(
16351        &self,
16352        clear_mask: zx::Signals,
16353        set_mask: zx::Signals,
16354    ) -> Result<(), zx_status::Status> {
16355        use fidl::Peered;
16356        self.inner.channel().signal_peer(clear_mask, set_mask)
16357    }
16358}
16359
16360impl StreamSinkControlHandle {}
16361
16362#[must_use = "FIDL methods require a response to be sent"]
16363#[derive(Debug)]
16364pub struct StreamSinkSendPacketResponder {
16365    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16366    tx_id: u32,
16367}
16368
16369/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16370/// if the responder is dropped without sending a response, so that the client
16371/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16372impl std::ops::Drop for StreamSinkSendPacketResponder {
16373    fn drop(&mut self) {
16374        self.control_handle.shutdown();
16375        // Safety: drops once, never accessed again
16376        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16377    }
16378}
16379
16380impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
16381    type ControlHandle = StreamSinkControlHandle;
16382
16383    fn control_handle(&self) -> &StreamSinkControlHandle {
16384        &self.control_handle
16385    }
16386
16387    fn drop_without_shutdown(mut self) {
16388        // Safety: drops once, never accessed again due to mem::forget
16389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16390        // Prevent Drop from running (which would shut down the channel)
16391        std::mem::forget(self);
16392    }
16393}
16394
16395impl StreamSinkSendPacketResponder {
16396    /// Sends a response to the FIDL transaction.
16397    ///
16398    /// Sets the channel to shutdown if an error occurs.
16399    pub fn send(self) -> Result<(), fidl::Error> {
16400        let _result = self.send_raw();
16401        if _result.is_err() {
16402            self.control_handle.shutdown();
16403        }
16404        self.drop_without_shutdown();
16405        _result
16406    }
16407
16408    /// Similar to "send" but does not shutdown the channel if an error occurs.
16409    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16410        let _result = self.send_raw();
16411        self.drop_without_shutdown();
16412        _result
16413    }
16414
16415    fn send_raw(&self) -> Result<(), fidl::Error> {
16416        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16417            (),
16418            self.tx_id,
16419            0x67cddd607442775f,
16420            fidl::encoding::DynamicFlags::empty(),
16421        )
16422    }
16423}
16424
16425#[must_use = "FIDL methods require a response to be sent"]
16426#[derive(Debug)]
16427pub struct StreamSinkDiscardAllPacketsResponder {
16428    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
16429    tx_id: u32,
16430}
16431
16432/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
16433/// if the responder is dropped without sending a response, so that the client
16434/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16435impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
16436    fn drop(&mut self) {
16437        self.control_handle.shutdown();
16438        // Safety: drops once, never accessed again
16439        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16440    }
16441}
16442
16443impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
16444    type ControlHandle = StreamSinkControlHandle;
16445
16446    fn control_handle(&self) -> &StreamSinkControlHandle {
16447        &self.control_handle
16448    }
16449
16450    fn drop_without_shutdown(mut self) {
16451        // Safety: drops once, never accessed again due to mem::forget
16452        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16453        // Prevent Drop from running (which would shut down the channel)
16454        std::mem::forget(self);
16455    }
16456}
16457
16458impl StreamSinkDiscardAllPacketsResponder {
16459    /// Sends a response to the FIDL transaction.
16460    ///
16461    /// Sets the channel to shutdown if an error occurs.
16462    pub fn send(self) -> Result<(), fidl::Error> {
16463        let _result = self.send_raw();
16464        if _result.is_err() {
16465            self.control_handle.shutdown();
16466        }
16467        self.drop_without_shutdown();
16468        _result
16469    }
16470
16471    /// Similar to "send" but does not shutdown the channel if an error occurs.
16472    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16473        let _result = self.send_raw();
16474        self.drop_without_shutdown();
16475        _result
16476    }
16477
16478    fn send_raw(&self) -> Result<(), fidl::Error> {
16479        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16480            (),
16481            self.tx_id,
16482            0x6f4dad7af2917665,
16483            fidl::encoding::DynamicFlags::empty(),
16484        )
16485    }
16486}
16487
16488#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16489pub struct StreamSourceMarker;
16490
16491impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
16492    type Proxy = StreamSourceProxy;
16493    type RequestStream = StreamSourceRequestStream;
16494    #[cfg(target_os = "fuchsia")]
16495    type SynchronousProxy = StreamSourceSynchronousProxy;
16496
16497    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
16498}
16499
16500pub trait StreamSourceProxyInterface: Send + Sync {
16501    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
16502    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16503    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
16504    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
16505}
16506#[derive(Debug)]
16507#[cfg(target_os = "fuchsia")]
16508pub struct StreamSourceSynchronousProxy {
16509    client: fidl::client::sync::Client,
16510}
16511
16512#[cfg(target_os = "fuchsia")]
16513impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
16514    type Proxy = StreamSourceProxy;
16515    type Protocol = StreamSourceMarker;
16516
16517    fn from_channel(inner: fidl::Channel) -> Self {
16518        Self::new(inner)
16519    }
16520
16521    fn into_channel(self) -> fidl::Channel {
16522        self.client.into_channel()
16523    }
16524
16525    fn as_channel(&self) -> &fidl::Channel {
16526        self.client.as_channel()
16527    }
16528}
16529
16530#[cfg(target_os = "fuchsia")]
16531impl StreamSourceSynchronousProxy {
16532    pub fn new(channel: fidl::Channel) -> Self {
16533        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16534        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
16535    }
16536
16537    pub fn into_channel(self) -> fidl::Channel {
16538        self.client.into_channel()
16539    }
16540
16541    /// Waits until an event arrives and returns it. It is safe for other
16542    /// threads to make concurrent requests while waiting for an event.
16543    pub fn wait_for_event(
16544        &self,
16545        deadline: zx::MonotonicInstant,
16546    ) -> Result<StreamSourceEvent, fidl::Error> {
16547        StreamSourceEvent::decode(self.client.wait_for_event(deadline)?)
16548    }
16549
16550    /// Releases payload memory associated with a packet previously delivered
16551    /// via `OnPacketProduced`.
16552    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16553        self.client.send::<StreamSourceReleasePacketRequest>(
16554            (packet,),
16555            0x7a7b57f0f7d9e4bb,
16556            fidl::encoding::DynamicFlags::empty(),
16557        )
16558    }
16559
16560    pub fn r#discard_all_packets(
16561        &self,
16562        ___deadline: zx::MonotonicInstant,
16563    ) -> Result<(), fidl::Error> {
16564        let _response =
16565            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
16566                (),
16567                0x27afd605e97b09d2,
16568                fidl::encoding::DynamicFlags::empty(),
16569                ___deadline,
16570            )?;
16571        Ok(_response)
16572    }
16573
16574    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16575        self.client.send::<fidl::encoding::EmptyPayload>(
16576            (),
16577            0x35f9d721e905b831,
16578            fidl::encoding::DynamicFlags::empty(),
16579        )
16580    }
16581}
16582
16583#[cfg(target_os = "fuchsia")]
16584impl From<StreamSourceSynchronousProxy> for zx::NullableHandle {
16585    fn from(value: StreamSourceSynchronousProxy) -> Self {
16586        value.into_channel().into()
16587    }
16588}
16589
16590#[cfg(target_os = "fuchsia")]
16591impl From<fidl::Channel> for StreamSourceSynchronousProxy {
16592    fn from(value: fidl::Channel) -> Self {
16593        Self::new(value)
16594    }
16595}
16596
16597#[cfg(target_os = "fuchsia")]
16598impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
16599    type Protocol = StreamSourceMarker;
16600
16601    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
16602        Self::new(value.into_channel())
16603    }
16604}
16605
16606#[derive(Debug, Clone)]
16607pub struct StreamSourceProxy {
16608    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
16609}
16610
16611impl fidl::endpoints::Proxy for StreamSourceProxy {
16612    type Protocol = StreamSourceMarker;
16613
16614    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
16615        Self::new(inner)
16616    }
16617
16618    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
16619        self.client.into_channel().map_err(|client| Self { client })
16620    }
16621
16622    fn as_channel(&self) -> &::fidl::AsyncChannel {
16623        self.client.as_channel()
16624    }
16625}
16626
16627impl StreamSourceProxy {
16628    /// Create a new Proxy for fuchsia.media/StreamSource.
16629    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
16630        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
16631        Self { client: fidl::client::Client::new(channel, protocol_name) }
16632    }
16633
16634    /// Get a Stream of events from the remote end of the protocol.
16635    ///
16636    /// # Panics
16637    ///
16638    /// Panics if the event stream was already taken.
16639    pub fn take_event_stream(&self) -> StreamSourceEventStream {
16640        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
16641    }
16642
16643    /// Releases payload memory associated with a packet previously delivered
16644    /// via `OnPacketProduced`.
16645    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16646        StreamSourceProxyInterface::r#release_packet(self, packet)
16647    }
16648
16649    pub fn r#discard_all_packets(
16650        &self,
16651    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
16652        StreamSourceProxyInterface::r#discard_all_packets(self)
16653    }
16654
16655    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16656        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
16657    }
16658}
16659
16660impl StreamSourceProxyInterface for StreamSourceProxy {
16661    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
16662        self.client.send::<StreamSourceReleasePacketRequest>(
16663            (packet,),
16664            0x7a7b57f0f7d9e4bb,
16665            fidl::encoding::DynamicFlags::empty(),
16666        )
16667    }
16668
16669    type DiscardAllPacketsResponseFut =
16670        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
16671    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
16672        fn _decode(
16673            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16674        ) -> Result<(), fidl::Error> {
16675            let _response = fidl::client::decode_transaction_body::<
16676                fidl::encoding::EmptyPayload,
16677                fidl::encoding::DefaultFuchsiaResourceDialect,
16678                0x27afd605e97b09d2,
16679            >(_buf?)?;
16680            Ok(_response)
16681        }
16682        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
16683            (),
16684            0x27afd605e97b09d2,
16685            fidl::encoding::DynamicFlags::empty(),
16686            _decode,
16687        )
16688    }
16689
16690    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
16691        self.client.send::<fidl::encoding::EmptyPayload>(
16692            (),
16693            0x35f9d721e905b831,
16694            fidl::encoding::DynamicFlags::empty(),
16695        )
16696    }
16697}
16698
16699pub struct StreamSourceEventStream {
16700    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
16701}
16702
16703impl std::marker::Unpin for StreamSourceEventStream {}
16704
16705impl futures::stream::FusedStream for StreamSourceEventStream {
16706    fn is_terminated(&self) -> bool {
16707        self.event_receiver.is_terminated()
16708    }
16709}
16710
16711impl futures::Stream for StreamSourceEventStream {
16712    type Item = Result<StreamSourceEvent, fidl::Error>;
16713
16714    fn poll_next(
16715        mut self: std::pin::Pin<&mut Self>,
16716        cx: &mut std::task::Context<'_>,
16717    ) -> std::task::Poll<Option<Self::Item>> {
16718        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16719            &mut self.event_receiver,
16720            cx
16721        )?) {
16722            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
16723            None => std::task::Poll::Ready(None),
16724        }
16725    }
16726}
16727
16728#[derive(Debug)]
16729pub enum StreamSourceEvent {
16730    OnPacketProduced { packet: StreamPacket },
16731    OnEndOfStream {},
16732}
16733
16734impl StreamSourceEvent {
16735    #[allow(irrefutable_let_patterns)]
16736    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
16737        if let StreamSourceEvent::OnPacketProduced { packet } = self {
16738            Some((packet))
16739        } else {
16740            None
16741        }
16742    }
16743    #[allow(irrefutable_let_patterns)]
16744    pub fn into_on_end_of_stream(self) -> Option<()> {
16745        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
16746    }
16747
16748    /// Decodes a message buffer as a [`StreamSourceEvent`].
16749    fn decode(
16750        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16751    ) -> Result<StreamSourceEvent, fidl::Error> {
16752        let (bytes, _handles) = buf.split_mut();
16753        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16754        debug_assert_eq!(tx_header.tx_id, 0);
16755        match tx_header.ordinal {
16756            0x6bbe69746a3c8bd9 => {
16757                let mut out = fidl::new_empty!(
16758                    StreamSourceOnPacketProducedRequest,
16759                    fidl::encoding::DefaultFuchsiaResourceDialect
16760                );
16761                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16762                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
16763            }
16764            0x550e69b41d03e2c2 => {
16765                let mut out = fidl::new_empty!(
16766                    fidl::encoding::EmptyPayload,
16767                    fidl::encoding::DefaultFuchsiaResourceDialect
16768                );
16769                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
16770                Ok((StreamSourceEvent::OnEndOfStream {}))
16771            }
16772            _ => Err(fidl::Error::UnknownOrdinal {
16773                ordinal: tx_header.ordinal,
16774                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16775            }),
16776        }
16777    }
16778}
16779
16780/// A Stream of incoming requests for fuchsia.media/StreamSource.
16781pub struct StreamSourceRequestStream {
16782    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16783    is_terminated: bool,
16784}
16785
16786impl std::marker::Unpin for StreamSourceRequestStream {}
16787
16788impl futures::stream::FusedStream for StreamSourceRequestStream {
16789    fn is_terminated(&self) -> bool {
16790        self.is_terminated
16791    }
16792}
16793
16794impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
16795    type Protocol = StreamSourceMarker;
16796    type ControlHandle = StreamSourceControlHandle;
16797
16798    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16799        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16800    }
16801
16802    fn control_handle(&self) -> Self::ControlHandle {
16803        StreamSourceControlHandle { inner: self.inner.clone() }
16804    }
16805
16806    fn into_inner(
16807        self,
16808    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16809    {
16810        (self.inner, self.is_terminated)
16811    }
16812
16813    fn from_inner(
16814        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16815        is_terminated: bool,
16816    ) -> Self {
16817        Self { inner, is_terminated }
16818    }
16819}
16820
16821impl futures::Stream for StreamSourceRequestStream {
16822    type Item = Result<StreamSourceRequest, fidl::Error>;
16823
16824    fn poll_next(
16825        mut self: std::pin::Pin<&mut Self>,
16826        cx: &mut std::task::Context<'_>,
16827    ) -> std::task::Poll<Option<Self::Item>> {
16828        let this = &mut *self;
16829        if this.inner.check_shutdown(cx) {
16830            this.is_terminated = true;
16831            return std::task::Poll::Ready(None);
16832        }
16833        if this.is_terminated {
16834            panic!("polled StreamSourceRequestStream after completion");
16835        }
16836        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16837            |bytes, handles| {
16838                match this.inner.channel().read_etc(cx, bytes, handles) {
16839                    std::task::Poll::Ready(Ok(())) => {}
16840                    std::task::Poll::Pending => return std::task::Poll::Pending,
16841                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16842                        this.is_terminated = true;
16843                        return std::task::Poll::Ready(None);
16844                    }
16845                    std::task::Poll::Ready(Err(e)) => {
16846                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16847                            e.into(),
16848                        ))));
16849                    }
16850                }
16851
16852                // A message has been received from the channel
16853                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16854
16855                std::task::Poll::Ready(Some(match header.ordinal {
16856                    0x7a7b57f0f7d9e4bb => {
16857                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16858                        let mut req = fidl::new_empty!(
16859                            StreamSourceReleasePacketRequest,
16860                            fidl::encoding::DefaultFuchsiaResourceDialect
16861                        );
16862                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
16863                        let control_handle =
16864                            StreamSourceControlHandle { inner: this.inner.clone() };
16865                        Ok(StreamSourceRequest::ReleasePacket {
16866                            packet: req.packet,
16867
16868                            control_handle,
16869                        })
16870                    }
16871                    0x27afd605e97b09d2 => {
16872                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16873                        let mut req = fidl::new_empty!(
16874                            fidl::encoding::EmptyPayload,
16875                            fidl::encoding::DefaultFuchsiaResourceDialect
16876                        );
16877                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16878                        let control_handle =
16879                            StreamSourceControlHandle { inner: this.inner.clone() };
16880                        Ok(StreamSourceRequest::DiscardAllPackets {
16881                            responder: StreamSourceDiscardAllPacketsResponder {
16882                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16883                                tx_id: header.tx_id,
16884                            },
16885                        })
16886                    }
16887                    0x35f9d721e905b831 => {
16888                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16889                        let mut req = fidl::new_empty!(
16890                            fidl::encoding::EmptyPayload,
16891                            fidl::encoding::DefaultFuchsiaResourceDialect
16892                        );
16893                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16894                        let control_handle =
16895                            StreamSourceControlHandle { inner: this.inner.clone() };
16896                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
16897                    }
16898                    _ => Err(fidl::Error::UnknownOrdinal {
16899                        ordinal: header.ordinal,
16900                        protocol_name:
16901                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16902                    }),
16903                }))
16904            },
16905        )
16906    }
16907}
16908
16909/// Produces a stream of packets. This interface is typically inherited along
16910/// with `StreamBufferSet` to enable the transport of elementary streams from
16911/// services to clients.
16912#[derive(Debug)]
16913pub enum StreamSourceRequest {
16914    /// Releases payload memory associated with a packet previously delivered
16915    /// via `OnPacketProduced`.
16916    ReleasePacket {
16917        packet: StreamPacket,
16918        control_handle: StreamSourceControlHandle,
16919    },
16920    DiscardAllPackets {
16921        responder: StreamSourceDiscardAllPacketsResponder,
16922    },
16923    DiscardAllPacketsNoReply {
16924        control_handle: StreamSourceControlHandle,
16925    },
16926}
16927
16928impl StreamSourceRequest {
16929    #[allow(irrefutable_let_patterns)]
16930    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
16931        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
16932            Some((packet, control_handle))
16933        } else {
16934            None
16935        }
16936    }
16937
16938    #[allow(irrefutable_let_patterns)]
16939    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
16940        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
16941            Some((responder))
16942        } else {
16943            None
16944        }
16945    }
16946
16947    #[allow(irrefutable_let_patterns)]
16948    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
16949        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
16950            Some((control_handle))
16951        } else {
16952            None
16953        }
16954    }
16955
16956    /// Name of the method defined in FIDL
16957    pub fn method_name(&self) -> &'static str {
16958        match *self {
16959            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
16960            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
16961            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
16962        }
16963    }
16964}
16965
16966#[derive(Debug, Clone)]
16967pub struct StreamSourceControlHandle {
16968    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16969}
16970
16971impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
16972    fn shutdown(&self) {
16973        self.inner.shutdown()
16974    }
16975
16976    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
16977        self.inner.shutdown_with_epitaph(status)
16978    }
16979
16980    fn is_closed(&self) -> bool {
16981        self.inner.channel().is_closed()
16982    }
16983    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
16984        self.inner.channel().on_closed()
16985    }
16986
16987    #[cfg(target_os = "fuchsia")]
16988    fn signal_peer(
16989        &self,
16990        clear_mask: zx::Signals,
16991        set_mask: zx::Signals,
16992    ) -> Result<(), zx_status::Status> {
16993        use fidl::Peered;
16994        self.inner.channel().signal_peer(clear_mask, set_mask)
16995    }
16996}
16997
16998impl StreamSourceControlHandle {
16999    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
17000        self.inner.send::<StreamSourceOnPacketProducedRequest>(
17001            (packet,),
17002            0,
17003            0x6bbe69746a3c8bd9,
17004            fidl::encoding::DynamicFlags::empty(),
17005        )
17006    }
17007
17008    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
17009        self.inner.send::<fidl::encoding::EmptyPayload>(
17010            (),
17011            0,
17012            0x550e69b41d03e2c2,
17013            fidl::encoding::DynamicFlags::empty(),
17014        )
17015    }
17016}
17017
17018#[must_use = "FIDL methods require a response to be sent"]
17019#[derive(Debug)]
17020pub struct StreamSourceDiscardAllPacketsResponder {
17021    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
17022    tx_id: u32,
17023}
17024
17025/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
17026/// if the responder is dropped without sending a response, so that the client
17027/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17028impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
17029    fn drop(&mut self) {
17030        self.control_handle.shutdown();
17031        // Safety: drops once, never accessed again
17032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17033    }
17034}
17035
17036impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
17037    type ControlHandle = StreamSourceControlHandle;
17038
17039    fn control_handle(&self) -> &StreamSourceControlHandle {
17040        &self.control_handle
17041    }
17042
17043    fn drop_without_shutdown(mut self) {
17044        // Safety: drops once, never accessed again due to mem::forget
17045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17046        // Prevent Drop from running (which would shut down the channel)
17047        std::mem::forget(self);
17048    }
17049}
17050
17051impl StreamSourceDiscardAllPacketsResponder {
17052    /// Sends a response to the FIDL transaction.
17053    ///
17054    /// Sets the channel to shutdown if an error occurs.
17055    pub fn send(self) -> Result<(), fidl::Error> {
17056        let _result = self.send_raw();
17057        if _result.is_err() {
17058            self.control_handle.shutdown();
17059        }
17060        self.drop_without_shutdown();
17061        _result
17062    }
17063
17064    /// Similar to "send" but does not shutdown the channel if an error occurs.
17065    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17066        let _result = self.send_raw();
17067        self.drop_without_shutdown();
17068        _result
17069    }
17070
17071    fn send_raw(&self) -> Result<(), fidl::Error> {
17072        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17073            (),
17074            self.tx_id,
17075            0x27afd605e97b09d2,
17076            fidl::encoding::DynamicFlags::empty(),
17077        )
17078    }
17079}
17080
17081#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17082pub struct Usage2AudioConsumerFactoryMarker;
17083
17084impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
17085    type Proxy = Usage2AudioConsumerFactoryProxy;
17086    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
17087    #[cfg(target_os = "fuchsia")]
17088    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
17089
17090    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
17091}
17092impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
17093
17094pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
17095    fn r#create_audio_consumer(
17096        &self,
17097        usage: AudioRenderUsage2,
17098        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17099    ) -> Result<(), fidl::Error>;
17100}
17101#[derive(Debug)]
17102#[cfg(target_os = "fuchsia")]
17103pub struct Usage2AudioConsumerFactorySynchronousProxy {
17104    client: fidl::client::sync::Client,
17105}
17106
17107#[cfg(target_os = "fuchsia")]
17108impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
17109    type Proxy = Usage2AudioConsumerFactoryProxy;
17110    type Protocol = Usage2AudioConsumerFactoryMarker;
17111
17112    fn from_channel(inner: fidl::Channel) -> Self {
17113        Self::new(inner)
17114    }
17115
17116    fn into_channel(self) -> fidl::Channel {
17117        self.client.into_channel()
17118    }
17119
17120    fn as_channel(&self) -> &fidl::Channel {
17121        self.client.as_channel()
17122    }
17123}
17124
17125#[cfg(target_os = "fuchsia")]
17126impl Usage2AudioConsumerFactorySynchronousProxy {
17127    pub fn new(channel: fidl::Channel) -> Self {
17128        let protocol_name =
17129            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17130        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17131    }
17132
17133    pub fn into_channel(self) -> fidl::Channel {
17134        self.client.into_channel()
17135    }
17136
17137    /// Waits until an event arrives and returns it. It is safe for other
17138    /// threads to make concurrent requests while waiting for an event.
17139    pub fn wait_for_event(
17140        &self,
17141        deadline: zx::MonotonicInstant,
17142    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17143        Usage2AudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17144    }
17145
17146    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17147    /// Audio submitted to such a consumer is always rendered locally.
17148    pub fn r#create_audio_consumer(
17149        &self,
17150        mut usage: AudioRenderUsage2,
17151        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17152    ) -> Result<(), fidl::Error> {
17153        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17154            (usage, audio_consumer_request),
17155            0x767722302a171873,
17156            fidl::encoding::DynamicFlags::FLEXIBLE,
17157        )
17158    }
17159}
17160
17161#[cfg(target_os = "fuchsia")]
17162impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17163    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
17164        value.into_channel().into()
17165    }
17166}
17167
17168#[cfg(target_os = "fuchsia")]
17169impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
17170    fn from(value: fidl::Channel) -> Self {
17171        Self::new(value)
17172    }
17173}
17174
17175#[cfg(target_os = "fuchsia")]
17176impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
17177    type Protocol = Usage2AudioConsumerFactoryMarker;
17178
17179    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
17180        Self::new(value.into_channel())
17181    }
17182}
17183
17184#[derive(Debug, Clone)]
17185pub struct Usage2AudioConsumerFactoryProxy {
17186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17187}
17188
17189impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
17190    type Protocol = Usage2AudioConsumerFactoryMarker;
17191
17192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17193        Self::new(inner)
17194    }
17195
17196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17197        self.client.into_channel().map_err(|client| Self { client })
17198    }
17199
17200    fn as_channel(&self) -> &::fidl::AsyncChannel {
17201        self.client.as_channel()
17202    }
17203}
17204
17205impl Usage2AudioConsumerFactoryProxy {
17206    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
17207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17208        let protocol_name =
17209            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17210        Self { client: fidl::client::Client::new(channel, protocol_name) }
17211    }
17212
17213    /// Get a Stream of events from the remote end of the protocol.
17214    ///
17215    /// # Panics
17216    ///
17217    /// Panics if the event stream was already taken.
17218    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
17219        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17220    }
17221
17222    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17223    /// Audio submitted to such a consumer is always rendered locally.
17224    pub fn r#create_audio_consumer(
17225        &self,
17226        mut usage: AudioRenderUsage2,
17227        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17228    ) -> Result<(), fidl::Error> {
17229        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17230            self,
17231            usage,
17232            audio_consumer_request,
17233        )
17234    }
17235}
17236
17237impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
17238    fn r#create_audio_consumer(
17239        &self,
17240        mut usage: AudioRenderUsage2,
17241        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17242    ) -> Result<(), fidl::Error> {
17243        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
17244            (usage, audio_consumer_request),
17245            0x767722302a171873,
17246            fidl::encoding::DynamicFlags::FLEXIBLE,
17247        )
17248    }
17249}
17250
17251pub struct Usage2AudioConsumerFactoryEventStream {
17252    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17253}
17254
17255impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
17256
17257impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
17258    fn is_terminated(&self) -> bool {
17259        self.event_receiver.is_terminated()
17260    }
17261}
17262
17263impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
17264    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
17265
17266    fn poll_next(
17267        mut self: std::pin::Pin<&mut Self>,
17268        cx: &mut std::task::Context<'_>,
17269    ) -> std::task::Poll<Option<Self::Item>> {
17270        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17271            &mut self.event_receiver,
17272            cx
17273        )?) {
17274            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
17275            None => std::task::Poll::Ready(None),
17276        }
17277    }
17278}
17279
17280#[derive(Debug)]
17281pub enum Usage2AudioConsumerFactoryEvent {
17282    #[non_exhaustive]
17283    _UnknownEvent {
17284        /// Ordinal of the event that was sent.
17285        ordinal: u64,
17286    },
17287}
17288
17289impl Usage2AudioConsumerFactoryEvent {
17290    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
17291    fn decode(
17292        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17293    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
17294        let (bytes, _handles) = buf.split_mut();
17295        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17296        debug_assert_eq!(tx_header.tx_id, 0);
17297        match tx_header.ordinal {
17298            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17299                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
17300                    ordinal: tx_header.ordinal,
17301                })
17302            }
17303            _ => Err(fidl::Error::UnknownOrdinal {
17304                ordinal: tx_header.ordinal,
17305                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17306            })
17307        }
17308    }
17309}
17310
17311/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
17312pub struct Usage2AudioConsumerFactoryRequestStream {
17313    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17314    is_terminated: bool,
17315}
17316
17317impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
17318
17319impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
17320    fn is_terminated(&self) -> bool {
17321        self.is_terminated
17322    }
17323}
17324
17325impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
17326    type Protocol = Usage2AudioConsumerFactoryMarker;
17327    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
17328
17329    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17330        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17331    }
17332
17333    fn control_handle(&self) -> Self::ControlHandle {
17334        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17335    }
17336
17337    fn into_inner(
17338        self,
17339    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17340    {
17341        (self.inner, self.is_terminated)
17342    }
17343
17344    fn from_inner(
17345        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17346        is_terminated: bool,
17347    ) -> Self {
17348        Self { inner, is_terminated }
17349    }
17350}
17351
17352impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
17353    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
17354
17355    fn poll_next(
17356        mut self: std::pin::Pin<&mut Self>,
17357        cx: &mut std::task::Context<'_>,
17358    ) -> std::task::Poll<Option<Self::Item>> {
17359        let this = &mut *self;
17360        if this.inner.check_shutdown(cx) {
17361            this.is_terminated = true;
17362            return std::task::Poll::Ready(None);
17363        }
17364        if this.is_terminated {
17365            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
17366        }
17367        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17368            |bytes, handles| {
17369                match this.inner.channel().read_etc(cx, bytes, handles) {
17370                    std::task::Poll::Ready(Ok(())) => {}
17371                    std::task::Poll::Pending => return std::task::Poll::Pending,
17372                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17373                        this.is_terminated = true;
17374                        return std::task::Poll::Ready(None);
17375                    }
17376                    std::task::Poll::Ready(Err(e)) => {
17377                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17378                            e.into(),
17379                        ))));
17380                    }
17381                }
17382
17383                // A message has been received from the channel
17384                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17385
17386                std::task::Poll::Ready(Some(match header.ordinal {
17387                0x767722302a171873 => {
17388                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17389                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17390                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17391                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
17392                        inner: this.inner.clone(),
17393                    };
17394                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17395audio_consumer_request: req.audio_consumer_request,
17396
17397                        control_handle,
17398                    })
17399                }
17400                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17401                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17402                        ordinal: header.ordinal,
17403                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17404                        method_type: fidl::MethodType::OneWay,
17405                    })
17406                }
17407                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17408                    this.inner.send_framework_err(
17409                        fidl::encoding::FrameworkErr::UnknownMethod,
17410                        header.tx_id,
17411                        header.ordinal,
17412                        header.dynamic_flags(),
17413                        (bytes, handles),
17414                    )?;
17415                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17416                        ordinal: header.ordinal,
17417                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
17418                        method_type: fidl::MethodType::TwoWay,
17419                    })
17420                }
17421                _ => Err(fidl::Error::UnknownOrdinal {
17422                    ordinal: header.ordinal,
17423                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17424                }),
17425            }))
17426            },
17427        )
17428    }
17429}
17430
17431/// Interface for creating audio consumers for local rendering.
17432#[derive(Debug)]
17433pub enum Usage2AudioConsumerFactoryRequest {
17434    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
17435    /// Audio submitted to such a consumer is always rendered locally.
17436    CreateAudioConsumer {
17437        usage: AudioRenderUsage2,
17438        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17439        control_handle: Usage2AudioConsumerFactoryControlHandle,
17440    },
17441    /// An interaction was received which does not match any known method.
17442    #[non_exhaustive]
17443    _UnknownMethod {
17444        /// Ordinal of the method that was called.
17445        ordinal: u64,
17446        control_handle: Usage2AudioConsumerFactoryControlHandle,
17447        method_type: fidl::MethodType,
17448    },
17449}
17450
17451impl Usage2AudioConsumerFactoryRequest {
17452    #[allow(irrefutable_let_patterns)]
17453    pub fn into_create_audio_consumer(
17454        self,
17455    ) -> Option<(
17456        AudioRenderUsage2,
17457        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17458        Usage2AudioConsumerFactoryControlHandle,
17459    )> {
17460        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
17461            usage,
17462            audio_consumer_request,
17463            control_handle,
17464        } = self
17465        {
17466            Some((usage, audio_consumer_request, control_handle))
17467        } else {
17468            None
17469        }
17470    }
17471
17472    /// Name of the method defined in FIDL
17473    pub fn method_name(&self) -> &'static str {
17474        match *self {
17475            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
17476                "create_audio_consumer"
17477            }
17478            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17479                method_type: fidl::MethodType::OneWay,
17480                ..
17481            } => "unknown one-way method",
17482            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
17483                method_type: fidl::MethodType::TwoWay,
17484                ..
17485            } => "unknown two-way method",
17486        }
17487    }
17488}
17489
17490#[derive(Debug, Clone)]
17491pub struct Usage2AudioConsumerFactoryControlHandle {
17492    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17493}
17494
17495impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
17496    fn shutdown(&self) {
17497        self.inner.shutdown()
17498    }
17499
17500    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17501        self.inner.shutdown_with_epitaph(status)
17502    }
17503
17504    fn is_closed(&self) -> bool {
17505        self.inner.channel().is_closed()
17506    }
17507    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17508        self.inner.channel().on_closed()
17509    }
17510
17511    #[cfg(target_os = "fuchsia")]
17512    fn signal_peer(
17513        &self,
17514        clear_mask: zx::Signals,
17515        set_mask: zx::Signals,
17516    ) -> Result<(), zx_status::Status> {
17517        use fidl::Peered;
17518        self.inner.channel().signal_peer(clear_mask, set_mask)
17519    }
17520}
17521
17522impl Usage2AudioConsumerFactoryControlHandle {}
17523
17524#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17525pub struct UsageAudioConsumerFactoryMarker;
17526
17527impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
17528    type Proxy = UsageAudioConsumerFactoryProxy;
17529    type RequestStream = UsageAudioConsumerFactoryRequestStream;
17530    #[cfg(target_os = "fuchsia")]
17531    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
17532
17533    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
17534}
17535impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
17536
17537pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
17538    fn r#create_audio_consumer(
17539        &self,
17540        usage: AudioRenderUsage,
17541        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17542    ) -> Result<(), fidl::Error>;
17543}
17544#[derive(Debug)]
17545#[cfg(target_os = "fuchsia")]
17546pub struct UsageAudioConsumerFactorySynchronousProxy {
17547    client: fidl::client::sync::Client,
17548}
17549
17550#[cfg(target_os = "fuchsia")]
17551impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
17552    type Proxy = UsageAudioConsumerFactoryProxy;
17553    type Protocol = UsageAudioConsumerFactoryMarker;
17554
17555    fn from_channel(inner: fidl::Channel) -> Self {
17556        Self::new(inner)
17557    }
17558
17559    fn into_channel(self) -> fidl::Channel {
17560        self.client.into_channel()
17561    }
17562
17563    fn as_channel(&self) -> &fidl::Channel {
17564        self.client.as_channel()
17565    }
17566}
17567
17568#[cfg(target_os = "fuchsia")]
17569impl UsageAudioConsumerFactorySynchronousProxy {
17570    pub fn new(channel: fidl::Channel) -> Self {
17571        let protocol_name =
17572            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17573        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17574    }
17575
17576    pub fn into_channel(self) -> fidl::Channel {
17577        self.client.into_channel()
17578    }
17579
17580    /// Waits until an event arrives and returns it. It is safe for other
17581    /// threads to make concurrent requests while waiting for an event.
17582    pub fn wait_for_event(
17583        &self,
17584        deadline: zx::MonotonicInstant,
17585    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17586        UsageAudioConsumerFactoryEvent::decode(self.client.wait_for_event(deadline)?)
17587    }
17588
17589    pub fn r#create_audio_consumer(
17590        &self,
17591        mut usage: AudioRenderUsage,
17592        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17593    ) -> Result<(), fidl::Error> {
17594        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17595            (usage, audio_consumer_request),
17596            0x4d975ca9b8f625a3,
17597            fidl::encoding::DynamicFlags::empty(),
17598        )
17599    }
17600}
17601
17602#[cfg(target_os = "fuchsia")]
17603impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
17604    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
17605        value.into_channel().into()
17606    }
17607}
17608
17609#[cfg(target_os = "fuchsia")]
17610impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
17611    fn from(value: fidl::Channel) -> Self {
17612        Self::new(value)
17613    }
17614}
17615
17616#[cfg(target_os = "fuchsia")]
17617impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
17618    type Protocol = UsageAudioConsumerFactoryMarker;
17619
17620    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
17621        Self::new(value.into_channel())
17622    }
17623}
17624
17625#[derive(Debug, Clone)]
17626pub struct UsageAudioConsumerFactoryProxy {
17627    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
17628}
17629
17630impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
17631    type Protocol = UsageAudioConsumerFactoryMarker;
17632
17633    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
17634        Self::new(inner)
17635    }
17636
17637    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
17638        self.client.into_channel().map_err(|client| Self { client })
17639    }
17640
17641    fn as_channel(&self) -> &::fidl::AsyncChannel {
17642        self.client.as_channel()
17643    }
17644}
17645
17646impl UsageAudioConsumerFactoryProxy {
17647    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
17648    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
17649        let protocol_name =
17650            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17651        Self { client: fidl::client::Client::new(channel, protocol_name) }
17652    }
17653
17654    /// Get a Stream of events from the remote end of the protocol.
17655    ///
17656    /// # Panics
17657    ///
17658    /// Panics if the event stream was already taken.
17659    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
17660        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
17661    }
17662
17663    pub fn r#create_audio_consumer(
17664        &self,
17665        mut usage: AudioRenderUsage,
17666        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17667    ) -> Result<(), fidl::Error> {
17668        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
17669            self,
17670            usage,
17671            audio_consumer_request,
17672        )
17673    }
17674}
17675
17676impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
17677    fn r#create_audio_consumer(
17678        &self,
17679        mut usage: AudioRenderUsage,
17680        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17681    ) -> Result<(), fidl::Error> {
17682        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
17683            (usage, audio_consumer_request),
17684            0x4d975ca9b8f625a3,
17685            fidl::encoding::DynamicFlags::empty(),
17686        )
17687    }
17688}
17689
17690pub struct UsageAudioConsumerFactoryEventStream {
17691    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
17692}
17693
17694impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
17695
17696impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
17697    fn is_terminated(&self) -> bool {
17698        self.event_receiver.is_terminated()
17699    }
17700}
17701
17702impl futures::Stream for UsageAudioConsumerFactoryEventStream {
17703    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
17704
17705    fn poll_next(
17706        mut self: std::pin::Pin<&mut Self>,
17707        cx: &mut std::task::Context<'_>,
17708    ) -> std::task::Poll<Option<Self::Item>> {
17709        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17710            &mut self.event_receiver,
17711            cx
17712        )?) {
17713            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
17714            None => std::task::Poll::Ready(None),
17715        }
17716    }
17717}
17718
17719#[derive(Debug)]
17720pub enum UsageAudioConsumerFactoryEvent {}
17721
17722impl UsageAudioConsumerFactoryEvent {
17723    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
17724    fn decode(
17725        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17726    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
17727        let (bytes, _handles) = buf.split_mut();
17728        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17729        debug_assert_eq!(tx_header.tx_id, 0);
17730        match tx_header.ordinal {
17731            _ => Err(fidl::Error::UnknownOrdinal {
17732                ordinal: tx_header.ordinal,
17733                protocol_name:
17734                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17735            }),
17736        }
17737    }
17738}
17739
17740/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
17741pub struct UsageAudioConsumerFactoryRequestStream {
17742    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17743    is_terminated: bool,
17744}
17745
17746impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
17747
17748impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
17749    fn is_terminated(&self) -> bool {
17750        self.is_terminated
17751    }
17752}
17753
17754impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
17755    type Protocol = UsageAudioConsumerFactoryMarker;
17756    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
17757
17758    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
17759        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17760    }
17761
17762    fn control_handle(&self) -> Self::ControlHandle {
17763        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
17764    }
17765
17766    fn into_inner(
17767        self,
17768    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
17769    {
17770        (self.inner, self.is_terminated)
17771    }
17772
17773    fn from_inner(
17774        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17775        is_terminated: bool,
17776    ) -> Self {
17777        Self { inner, is_terminated }
17778    }
17779}
17780
17781impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
17782    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
17783
17784    fn poll_next(
17785        mut self: std::pin::Pin<&mut Self>,
17786        cx: &mut std::task::Context<'_>,
17787    ) -> std::task::Poll<Option<Self::Item>> {
17788        let this = &mut *self;
17789        if this.inner.check_shutdown(cx) {
17790            this.is_terminated = true;
17791            return std::task::Poll::Ready(None);
17792        }
17793        if this.is_terminated {
17794            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
17795        }
17796        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
17797            |bytes, handles| {
17798                match this.inner.channel().read_etc(cx, bytes, handles) {
17799                    std::task::Poll::Ready(Ok(())) => {}
17800                    std::task::Poll::Pending => return std::task::Poll::Pending,
17801                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
17802                        this.is_terminated = true;
17803                        return std::task::Poll::Ready(None);
17804                    }
17805                    std::task::Poll::Ready(Err(e)) => {
17806                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17807                            e.into(),
17808                        ))));
17809                    }
17810                }
17811
17812                // A message has been received from the channel
17813                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17814
17815                std::task::Poll::Ready(Some(match header.ordinal {
17816                0x4d975ca9b8f625a3 => {
17817                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17818                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
17819                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
17820                    let control_handle = UsageAudioConsumerFactoryControlHandle {
17821                        inner: this.inner.clone(),
17822                    };
17823                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
17824audio_consumer_request: req.audio_consumer_request,
17825
17826                        control_handle,
17827                    })
17828                }
17829                _ => Err(fidl::Error::UnknownOrdinal {
17830                    ordinal: header.ordinal,
17831                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
17832                }),
17833            }))
17834            },
17835        )
17836    }
17837}
17838
17839/// Interface for creating audio consumers for local rendering.
17840#[derive(Debug)]
17841pub enum UsageAudioConsumerFactoryRequest {
17842    CreateAudioConsumer {
17843        usage: AudioRenderUsage,
17844        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17845        control_handle: UsageAudioConsumerFactoryControlHandle,
17846    },
17847}
17848
17849impl UsageAudioConsumerFactoryRequest {
17850    #[allow(irrefutable_let_patterns)]
17851    pub fn into_create_audio_consumer(
17852        self,
17853    ) -> Option<(
17854        AudioRenderUsage,
17855        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
17856        UsageAudioConsumerFactoryControlHandle,
17857    )> {
17858        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
17859            usage,
17860            audio_consumer_request,
17861            control_handle,
17862        } = self
17863        {
17864            Some((usage, audio_consumer_request, control_handle))
17865        } else {
17866            None
17867        }
17868    }
17869
17870    /// Name of the method defined in FIDL
17871    pub fn method_name(&self) -> &'static str {
17872        match *self {
17873            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
17874        }
17875    }
17876}
17877
17878#[derive(Debug, Clone)]
17879pub struct UsageAudioConsumerFactoryControlHandle {
17880    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17881}
17882
17883impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
17884    fn shutdown(&self) {
17885        self.inner.shutdown()
17886    }
17887
17888    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
17889        self.inner.shutdown_with_epitaph(status)
17890    }
17891
17892    fn is_closed(&self) -> bool {
17893        self.inner.channel().is_closed()
17894    }
17895    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17896        self.inner.channel().on_closed()
17897    }
17898
17899    #[cfg(target_os = "fuchsia")]
17900    fn signal_peer(
17901        &self,
17902        clear_mask: zx::Signals,
17903        set_mask: zx::Signals,
17904    ) -> Result<(), zx_status::Status> {
17905        use fidl::Peered;
17906        self.inner.channel().signal_peer(clear_mask, set_mask)
17907    }
17908}
17909
17910impl UsageAudioConsumerFactoryControlHandle {}
17911
17912#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17913pub struct UsageGainListenerMarker;
17914
17915impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
17916    type Proxy = UsageGainListenerProxy;
17917    type RequestStream = UsageGainListenerRequestStream;
17918    #[cfg(target_os = "fuchsia")]
17919    type SynchronousProxy = UsageGainListenerSynchronousProxy;
17920
17921    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
17922}
17923
17924pub trait UsageGainListenerProxyInterface: Send + Sync {
17925    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17926    fn r#on_gain_mute_changed(
17927        &self,
17928        muted: bool,
17929        gain_dbfs: f32,
17930    ) -> Self::OnGainMuteChangedResponseFut;
17931}
17932#[derive(Debug)]
17933#[cfg(target_os = "fuchsia")]
17934pub struct UsageGainListenerSynchronousProxy {
17935    client: fidl::client::sync::Client,
17936}
17937
17938#[cfg(target_os = "fuchsia")]
17939impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
17940    type Proxy = UsageGainListenerProxy;
17941    type Protocol = UsageGainListenerMarker;
17942
17943    fn from_channel(inner: fidl::Channel) -> Self {
17944        Self::new(inner)
17945    }
17946
17947    fn into_channel(self) -> fidl::Channel {
17948        self.client.into_channel()
17949    }
17950
17951    fn as_channel(&self) -> &fidl::Channel {
17952        self.client.as_channel()
17953    }
17954}
17955
17956#[cfg(target_os = "fuchsia")]
17957impl UsageGainListenerSynchronousProxy {
17958    pub fn new(channel: fidl::Channel) -> Self {
17959        let protocol_name =
17960            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
17961        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
17962    }
17963
17964    pub fn into_channel(self) -> fidl::Channel {
17965        self.client.into_channel()
17966    }
17967
17968    /// Waits until an event arrives and returns it. It is safe for other
17969    /// threads to make concurrent requests while waiting for an event.
17970    pub fn wait_for_event(
17971        &self,
17972        deadline: zx::MonotonicInstant,
17973    ) -> Result<UsageGainListenerEvent, fidl::Error> {
17974        UsageGainListenerEvent::decode(self.client.wait_for_event(deadline)?)
17975    }
17976
17977    /// Called immediately on connection and afterward any time
17978    /// the usage gain setting changes.
17979    ///
17980    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17981    /// events will eventually be disconnected.
17982    ///
17983    /// Note: This API does not have mute reporting implemented; `muted` is always false.
17984    pub fn r#on_gain_mute_changed(
17985        &self,
17986        mut muted: bool,
17987        mut gain_dbfs: f32,
17988        ___deadline: zx::MonotonicInstant,
17989    ) -> Result<(), fidl::Error> {
17990        let _response = self
17991            .client
17992            .send_query::<UsageGainListenerOnGainMuteChangedRequest, fidl::encoding::EmptyPayload>(
17993                (muted, gain_dbfs),
17994                0x681570258eac3a8d,
17995                fidl::encoding::DynamicFlags::empty(),
17996                ___deadline,
17997            )?;
17998        Ok(_response)
17999    }
18000}
18001
18002#[cfg(target_os = "fuchsia")]
18003impl From<UsageGainListenerSynchronousProxy> for zx::NullableHandle {
18004    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
18005        value.into_channel().into()
18006    }
18007}
18008
18009#[cfg(target_os = "fuchsia")]
18010impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
18011    fn from(value: fidl::Channel) -> Self {
18012        Self::new(value)
18013    }
18014}
18015
18016#[cfg(target_os = "fuchsia")]
18017impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
18018    type Protocol = UsageGainListenerMarker;
18019
18020    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
18021        Self::new(value.into_channel())
18022    }
18023}
18024
18025#[derive(Debug, Clone)]
18026pub struct UsageGainListenerProxy {
18027    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18028}
18029
18030impl fidl::endpoints::Proxy for UsageGainListenerProxy {
18031    type Protocol = UsageGainListenerMarker;
18032
18033    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18034        Self::new(inner)
18035    }
18036
18037    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18038        self.client.into_channel().map_err(|client| Self { client })
18039    }
18040
18041    fn as_channel(&self) -> &::fidl::AsyncChannel {
18042        self.client.as_channel()
18043    }
18044}
18045
18046impl UsageGainListenerProxy {
18047    /// Create a new Proxy for fuchsia.media/UsageGainListener.
18048    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18049        let protocol_name =
18050            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18051        Self { client: fidl::client::Client::new(channel, protocol_name) }
18052    }
18053
18054    /// Get a Stream of events from the remote end of the protocol.
18055    ///
18056    /// # Panics
18057    ///
18058    /// Panics if the event stream was already taken.
18059    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
18060        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
18061    }
18062
18063    /// Called immediately on connection and afterward any time
18064    /// the usage gain setting changes.
18065    ///
18066    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18067    /// events will eventually be disconnected.
18068    ///
18069    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18070    pub fn r#on_gain_mute_changed(
18071        &self,
18072        mut muted: bool,
18073        mut gain_dbfs: f32,
18074    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18075        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
18076    }
18077}
18078
18079impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
18080    type OnGainMuteChangedResponseFut =
18081        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18082    fn r#on_gain_mute_changed(
18083        &self,
18084        mut muted: bool,
18085        mut gain_dbfs: f32,
18086    ) -> Self::OnGainMuteChangedResponseFut {
18087        fn _decode(
18088            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18089        ) -> Result<(), fidl::Error> {
18090            let _response = fidl::client::decode_transaction_body::<
18091                fidl::encoding::EmptyPayload,
18092                fidl::encoding::DefaultFuchsiaResourceDialect,
18093                0x681570258eac3a8d,
18094            >(_buf?)?;
18095            Ok(_response)
18096        }
18097        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
18098            (muted, gain_dbfs),
18099            0x681570258eac3a8d,
18100            fidl::encoding::DynamicFlags::empty(),
18101            _decode,
18102        )
18103    }
18104}
18105
18106pub struct UsageGainListenerEventStream {
18107    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18108}
18109
18110impl std::marker::Unpin for UsageGainListenerEventStream {}
18111
18112impl futures::stream::FusedStream for UsageGainListenerEventStream {
18113    fn is_terminated(&self) -> bool {
18114        self.event_receiver.is_terminated()
18115    }
18116}
18117
18118impl futures::Stream for UsageGainListenerEventStream {
18119    type Item = Result<UsageGainListenerEvent, fidl::Error>;
18120
18121    fn poll_next(
18122        mut self: std::pin::Pin<&mut Self>,
18123        cx: &mut std::task::Context<'_>,
18124    ) -> std::task::Poll<Option<Self::Item>> {
18125        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18126            &mut self.event_receiver,
18127            cx
18128        )?) {
18129            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
18130            None => std::task::Poll::Ready(None),
18131        }
18132    }
18133}
18134
18135#[derive(Debug)]
18136pub enum UsageGainListenerEvent {}
18137
18138impl UsageGainListenerEvent {
18139    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
18140    fn decode(
18141        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18142    ) -> Result<UsageGainListenerEvent, fidl::Error> {
18143        let (bytes, _handles) = buf.split_mut();
18144        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18145        debug_assert_eq!(tx_header.tx_id, 0);
18146        match tx_header.ordinal {
18147            _ => Err(fidl::Error::UnknownOrdinal {
18148                ordinal: tx_header.ordinal,
18149                protocol_name:
18150                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18151            }),
18152        }
18153    }
18154}
18155
18156/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
18157pub struct UsageGainListenerRequestStream {
18158    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18159    is_terminated: bool,
18160}
18161
18162impl std::marker::Unpin for UsageGainListenerRequestStream {}
18163
18164impl futures::stream::FusedStream for UsageGainListenerRequestStream {
18165    fn is_terminated(&self) -> bool {
18166        self.is_terminated
18167    }
18168}
18169
18170impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
18171    type Protocol = UsageGainListenerMarker;
18172    type ControlHandle = UsageGainListenerControlHandle;
18173
18174    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18175        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18176    }
18177
18178    fn control_handle(&self) -> Self::ControlHandle {
18179        UsageGainListenerControlHandle { inner: self.inner.clone() }
18180    }
18181
18182    fn into_inner(
18183        self,
18184    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18185    {
18186        (self.inner, self.is_terminated)
18187    }
18188
18189    fn from_inner(
18190        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18191        is_terminated: bool,
18192    ) -> Self {
18193        Self { inner, is_terminated }
18194    }
18195}
18196
18197impl futures::Stream for UsageGainListenerRequestStream {
18198    type Item = Result<UsageGainListenerRequest, fidl::Error>;
18199
18200    fn poll_next(
18201        mut self: std::pin::Pin<&mut Self>,
18202        cx: &mut std::task::Context<'_>,
18203    ) -> std::task::Poll<Option<Self::Item>> {
18204        let this = &mut *self;
18205        if this.inner.check_shutdown(cx) {
18206            this.is_terminated = true;
18207            return std::task::Poll::Ready(None);
18208        }
18209        if this.is_terminated {
18210            panic!("polled UsageGainListenerRequestStream after completion");
18211        }
18212        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18213            |bytes, handles| {
18214                match this.inner.channel().read_etc(cx, bytes, handles) {
18215                    std::task::Poll::Ready(Ok(())) => {}
18216                    std::task::Poll::Pending => return std::task::Poll::Pending,
18217                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18218                        this.is_terminated = true;
18219                        return std::task::Poll::Ready(None);
18220                    }
18221                    std::task::Poll::Ready(Err(e)) => {
18222                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18223                            e.into(),
18224                        ))));
18225                    }
18226                }
18227
18228                // A message has been received from the channel
18229                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18230
18231                std::task::Poll::Ready(Some(match header.ordinal {
18232                    0x681570258eac3a8d => {
18233                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18234                        let mut req = fidl::new_empty!(
18235                            UsageGainListenerOnGainMuteChangedRequest,
18236                            fidl::encoding::DefaultFuchsiaResourceDialect
18237                        );
18238                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
18239                        let control_handle =
18240                            UsageGainListenerControlHandle { inner: this.inner.clone() };
18241                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
18242                            muted: req.muted,
18243                            gain_dbfs: req.gain_dbfs,
18244
18245                            responder: UsageGainListenerOnGainMuteChangedResponder {
18246                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18247                                tx_id: header.tx_id,
18248                            },
18249                        })
18250                    }
18251                    _ => Err(fidl::Error::UnknownOrdinal {
18252                        ordinal: header.ordinal,
18253                        protocol_name:
18254                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18255                    }),
18256                }))
18257            },
18258        )
18259    }
18260}
18261
18262/// A protocol for watching changes to usage gain settings.
18263///
18264/// The channel will close when the device is not present.
18265#[derive(Debug)]
18266pub enum UsageGainListenerRequest {
18267    /// Called immediately on connection and afterward any time
18268    /// the usage gain setting changes.
18269    ///
18270    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18271    /// events will eventually be disconnected.
18272    ///
18273    /// Note: This API does not have mute reporting implemented; `muted` is always false.
18274    OnGainMuteChanged {
18275        muted: bool,
18276        gain_dbfs: f32,
18277        responder: UsageGainListenerOnGainMuteChangedResponder,
18278    },
18279}
18280
18281impl UsageGainListenerRequest {
18282    #[allow(irrefutable_let_patterns)]
18283    pub fn into_on_gain_mute_changed(
18284        self,
18285    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
18286        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
18287            Some((muted, gain_dbfs, responder))
18288        } else {
18289            None
18290        }
18291    }
18292
18293    /// Name of the method defined in FIDL
18294    pub fn method_name(&self) -> &'static str {
18295        match *self {
18296            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
18297        }
18298    }
18299}
18300
18301#[derive(Debug, Clone)]
18302pub struct UsageGainListenerControlHandle {
18303    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18304}
18305
18306impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
18307    fn shutdown(&self) {
18308        self.inner.shutdown()
18309    }
18310
18311    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18312        self.inner.shutdown_with_epitaph(status)
18313    }
18314
18315    fn is_closed(&self) -> bool {
18316        self.inner.channel().is_closed()
18317    }
18318    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18319        self.inner.channel().on_closed()
18320    }
18321
18322    #[cfg(target_os = "fuchsia")]
18323    fn signal_peer(
18324        &self,
18325        clear_mask: zx::Signals,
18326        set_mask: zx::Signals,
18327    ) -> Result<(), zx_status::Status> {
18328        use fidl::Peered;
18329        self.inner.channel().signal_peer(clear_mask, set_mask)
18330    }
18331}
18332
18333impl UsageGainListenerControlHandle {}
18334
18335#[must_use = "FIDL methods require a response to be sent"]
18336#[derive(Debug)]
18337pub struct UsageGainListenerOnGainMuteChangedResponder {
18338    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
18339    tx_id: u32,
18340}
18341
18342/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
18343/// if the responder is dropped without sending a response, so that the client
18344/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18345impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
18346    fn drop(&mut self) {
18347        self.control_handle.shutdown();
18348        // Safety: drops once, never accessed again
18349        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18350    }
18351}
18352
18353impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
18354    type ControlHandle = UsageGainListenerControlHandle;
18355
18356    fn control_handle(&self) -> &UsageGainListenerControlHandle {
18357        &self.control_handle
18358    }
18359
18360    fn drop_without_shutdown(mut self) {
18361        // Safety: drops once, never accessed again due to mem::forget
18362        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18363        // Prevent Drop from running (which would shut down the channel)
18364        std::mem::forget(self);
18365    }
18366}
18367
18368impl UsageGainListenerOnGainMuteChangedResponder {
18369    /// Sends a response to the FIDL transaction.
18370    ///
18371    /// Sets the channel to shutdown if an error occurs.
18372    pub fn send(self) -> Result<(), fidl::Error> {
18373        let _result = self.send_raw();
18374        if _result.is_err() {
18375            self.control_handle.shutdown();
18376        }
18377        self.drop_without_shutdown();
18378        _result
18379    }
18380
18381    /// Similar to "send" but does not shutdown the channel if an error occurs.
18382    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18383        let _result = self.send_raw();
18384        self.drop_without_shutdown();
18385        _result
18386    }
18387
18388    fn send_raw(&self) -> Result<(), fidl::Error> {
18389        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18390            (),
18391            self.tx_id,
18392            0x681570258eac3a8d,
18393            fidl::encoding::DynamicFlags::empty(),
18394        )
18395    }
18396}
18397
18398#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18399pub struct UsageGainReporterMarker;
18400
18401impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
18402    type Proxy = UsageGainReporterProxy;
18403    type RequestStream = UsageGainReporterRequestStream;
18404    #[cfg(target_os = "fuchsia")]
18405    type SynchronousProxy = UsageGainReporterSynchronousProxy;
18406
18407    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
18408}
18409impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
18410
18411pub trait UsageGainReporterProxyInterface: Send + Sync {
18412    fn r#register_listener(
18413        &self,
18414        device_unique_id: &str,
18415        usage: &Usage,
18416        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18417    ) -> Result<(), fidl::Error>;
18418    fn r#register_listener2(
18419        &self,
18420        device_unique_id: &str,
18421        usage: &Usage2,
18422        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18423    ) -> Result<(), fidl::Error>;
18424}
18425#[derive(Debug)]
18426#[cfg(target_os = "fuchsia")]
18427pub struct UsageGainReporterSynchronousProxy {
18428    client: fidl::client::sync::Client,
18429}
18430
18431#[cfg(target_os = "fuchsia")]
18432impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
18433    type Proxy = UsageGainReporterProxy;
18434    type Protocol = UsageGainReporterMarker;
18435
18436    fn from_channel(inner: fidl::Channel) -> Self {
18437        Self::new(inner)
18438    }
18439
18440    fn into_channel(self) -> fidl::Channel {
18441        self.client.into_channel()
18442    }
18443
18444    fn as_channel(&self) -> &fidl::Channel {
18445        self.client.as_channel()
18446    }
18447}
18448
18449#[cfg(target_os = "fuchsia")]
18450impl UsageGainReporterSynchronousProxy {
18451    pub fn new(channel: fidl::Channel) -> Self {
18452        let protocol_name =
18453            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18454        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
18455    }
18456
18457    pub fn into_channel(self) -> fidl::Channel {
18458        self.client.into_channel()
18459    }
18460
18461    /// Waits until an event arrives and returns it. It is safe for other
18462    /// threads to make concurrent requests while waiting for an event.
18463    pub fn wait_for_event(
18464        &self,
18465        deadline: zx::MonotonicInstant,
18466    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18467        UsageGainReporterEvent::decode(self.client.wait_for_event(deadline)?)
18468    }
18469
18470    /// Connects a listener to a stream of usage gain setting changes
18471    /// for `usage` on the device identified by `device_token`. Usage
18472    /// Gain is not set directly by any client; it is a translation of
18473    /// the usage volume setting for each device, summed with active
18474    /// muting/ducking gain adjustments.
18475    ///
18476    /// Devices may map the same volume level to different dbfs, so
18477    /// a `device_unique_id` is needed to identify the device.
18478    ///
18479    /// `AudioDeviceEnumerator` provides programmatic access to devices
18480    /// and their unique ids if it is necessary for a client to select
18481    /// an id at runtime.
18482    pub fn r#register_listener(
18483        &self,
18484        mut device_unique_id: &str,
18485        mut usage: &Usage,
18486        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18487    ) -> Result<(), fidl::Error> {
18488        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18489            (device_unique_id, usage, usage_gain_listener),
18490            0x767107c168c226af,
18491            fidl::encoding::DynamicFlags::empty(),
18492        )
18493    }
18494
18495    /// Connects a listener to a stream of usage gain setting changes
18496    /// for `usage` on the device identified by `device_token`. Usage
18497    /// Gain is not set directly by any client; it is a translation of
18498    /// the usage volume setting for each device, summed with active
18499    /// muting/ducking gain adjustments.
18500    ///
18501    /// Devices may map the same volume level to different dbfs, so
18502    /// a `device_unique_id` is needed to identify the device.
18503    ///
18504    /// `AudioDeviceEnumerator` provides programmatic access to devices
18505    /// and their unique ids if it is necessary for a client to select
18506    /// an id at runtime.
18507    pub fn r#register_listener2(
18508        &self,
18509        mut device_unique_id: &str,
18510        mut usage: &Usage2,
18511        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18512    ) -> Result<(), fidl::Error> {
18513        self.client.send::<UsageGainReporterRegisterListener2Request>(
18514            (device_unique_id, usage, usage_gain_listener),
18515            0x760a8e1c5873629c,
18516            fidl::encoding::DynamicFlags::FLEXIBLE,
18517        )
18518    }
18519}
18520
18521#[cfg(target_os = "fuchsia")]
18522impl From<UsageGainReporterSynchronousProxy> for zx::NullableHandle {
18523    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
18524        value.into_channel().into()
18525    }
18526}
18527
18528#[cfg(target_os = "fuchsia")]
18529impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
18530    fn from(value: fidl::Channel) -> Self {
18531        Self::new(value)
18532    }
18533}
18534
18535#[cfg(target_os = "fuchsia")]
18536impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
18537    type Protocol = UsageGainReporterMarker;
18538
18539    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
18540        Self::new(value.into_channel())
18541    }
18542}
18543
18544#[derive(Debug, Clone)]
18545pub struct UsageGainReporterProxy {
18546    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18547}
18548
18549impl fidl::endpoints::Proxy for UsageGainReporterProxy {
18550    type Protocol = UsageGainReporterMarker;
18551
18552    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18553        Self::new(inner)
18554    }
18555
18556    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18557        self.client.into_channel().map_err(|client| Self { client })
18558    }
18559
18560    fn as_channel(&self) -> &::fidl::AsyncChannel {
18561        self.client.as_channel()
18562    }
18563}
18564
18565impl UsageGainReporterProxy {
18566    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
18567    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18568        let protocol_name =
18569            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18570        Self { client: fidl::client::Client::new(channel, protocol_name) }
18571    }
18572
18573    /// Get a Stream of events from the remote end of the protocol.
18574    ///
18575    /// # Panics
18576    ///
18577    /// Panics if the event stream was already taken.
18578    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
18579        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
18580    }
18581
18582    /// Connects a listener to a stream of usage gain setting changes
18583    /// for `usage` on the device identified by `device_token`. Usage
18584    /// Gain is not set directly by any client; it is a translation of
18585    /// the usage volume setting for each device, summed with active
18586    /// muting/ducking gain adjustments.
18587    ///
18588    /// Devices may map the same volume level to different dbfs, so
18589    /// a `device_unique_id` is needed to identify the device.
18590    ///
18591    /// `AudioDeviceEnumerator` provides programmatic access to devices
18592    /// and their unique ids if it is necessary for a client to select
18593    /// an id at runtime.
18594    pub fn r#register_listener(
18595        &self,
18596        mut device_unique_id: &str,
18597        mut usage: &Usage,
18598        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18599    ) -> Result<(), fidl::Error> {
18600        UsageGainReporterProxyInterface::r#register_listener(
18601            self,
18602            device_unique_id,
18603            usage,
18604            usage_gain_listener,
18605        )
18606    }
18607
18608    /// Connects a listener to a stream of usage gain setting changes
18609    /// for `usage` on the device identified by `device_token`. Usage
18610    /// Gain is not set directly by any client; it is a translation of
18611    /// the usage volume setting for each device, summed with active
18612    /// muting/ducking gain adjustments.
18613    ///
18614    /// Devices may map the same volume level to different dbfs, so
18615    /// a `device_unique_id` is needed to identify the device.
18616    ///
18617    /// `AudioDeviceEnumerator` provides programmatic access to devices
18618    /// and their unique ids if it is necessary for a client to select
18619    /// an id at runtime.
18620    pub fn r#register_listener2(
18621        &self,
18622        mut device_unique_id: &str,
18623        mut usage: &Usage2,
18624        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18625    ) -> Result<(), fidl::Error> {
18626        UsageGainReporterProxyInterface::r#register_listener2(
18627            self,
18628            device_unique_id,
18629            usage,
18630            usage_gain_listener,
18631        )
18632    }
18633}
18634
18635impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
18636    fn r#register_listener(
18637        &self,
18638        mut device_unique_id: &str,
18639        mut usage: &Usage,
18640        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18641    ) -> Result<(), fidl::Error> {
18642        self.client.send::<UsageGainReporterRegisterListenerRequest>(
18643            (device_unique_id, usage, usage_gain_listener),
18644            0x767107c168c226af,
18645            fidl::encoding::DynamicFlags::empty(),
18646        )
18647    }
18648
18649    fn r#register_listener2(
18650        &self,
18651        mut device_unique_id: &str,
18652        mut usage: &Usage2,
18653        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18654    ) -> Result<(), fidl::Error> {
18655        self.client.send::<UsageGainReporterRegisterListener2Request>(
18656            (device_unique_id, usage, usage_gain_listener),
18657            0x760a8e1c5873629c,
18658            fidl::encoding::DynamicFlags::FLEXIBLE,
18659        )
18660    }
18661}
18662
18663pub struct UsageGainReporterEventStream {
18664    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18665}
18666
18667impl std::marker::Unpin for UsageGainReporterEventStream {}
18668
18669impl futures::stream::FusedStream for UsageGainReporterEventStream {
18670    fn is_terminated(&self) -> bool {
18671        self.event_receiver.is_terminated()
18672    }
18673}
18674
18675impl futures::Stream for UsageGainReporterEventStream {
18676    type Item = Result<UsageGainReporterEvent, fidl::Error>;
18677
18678    fn poll_next(
18679        mut self: std::pin::Pin<&mut Self>,
18680        cx: &mut std::task::Context<'_>,
18681    ) -> std::task::Poll<Option<Self::Item>> {
18682        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18683            &mut self.event_receiver,
18684            cx
18685        )?) {
18686            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
18687            None => std::task::Poll::Ready(None),
18688        }
18689    }
18690}
18691
18692#[derive(Debug)]
18693pub enum UsageGainReporterEvent {
18694    #[non_exhaustive]
18695    _UnknownEvent {
18696        /// Ordinal of the event that was sent.
18697        ordinal: u64,
18698    },
18699}
18700
18701impl UsageGainReporterEvent {
18702    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
18703    fn decode(
18704        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18705    ) -> Result<UsageGainReporterEvent, fidl::Error> {
18706        let (bytes, _handles) = buf.split_mut();
18707        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18708        debug_assert_eq!(tx_header.tx_id, 0);
18709        match tx_header.ordinal {
18710            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
18711                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
18712            }
18713            _ => Err(fidl::Error::UnknownOrdinal {
18714                ordinal: tx_header.ordinal,
18715                protocol_name:
18716                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18717            }),
18718        }
18719    }
18720}
18721
18722/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
18723pub struct UsageGainReporterRequestStream {
18724    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18725    is_terminated: bool,
18726}
18727
18728impl std::marker::Unpin for UsageGainReporterRequestStream {}
18729
18730impl futures::stream::FusedStream for UsageGainReporterRequestStream {
18731    fn is_terminated(&self) -> bool {
18732        self.is_terminated
18733    }
18734}
18735
18736impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
18737    type Protocol = UsageGainReporterMarker;
18738    type ControlHandle = UsageGainReporterControlHandle;
18739
18740    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18741        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18742    }
18743
18744    fn control_handle(&self) -> Self::ControlHandle {
18745        UsageGainReporterControlHandle { inner: self.inner.clone() }
18746    }
18747
18748    fn into_inner(
18749        self,
18750    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18751    {
18752        (self.inner, self.is_terminated)
18753    }
18754
18755    fn from_inner(
18756        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18757        is_terminated: bool,
18758    ) -> Self {
18759        Self { inner, is_terminated }
18760    }
18761}
18762
18763impl futures::Stream for UsageGainReporterRequestStream {
18764    type Item = Result<UsageGainReporterRequest, fidl::Error>;
18765
18766    fn poll_next(
18767        mut self: std::pin::Pin<&mut Self>,
18768        cx: &mut std::task::Context<'_>,
18769    ) -> std::task::Poll<Option<Self::Item>> {
18770        let this = &mut *self;
18771        if this.inner.check_shutdown(cx) {
18772            this.is_terminated = true;
18773            return std::task::Poll::Ready(None);
18774        }
18775        if this.is_terminated {
18776            panic!("polled UsageGainReporterRequestStream after completion");
18777        }
18778        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18779            |bytes, handles| {
18780                match this.inner.channel().read_etc(cx, bytes, handles) {
18781                    std::task::Poll::Ready(Ok(())) => {}
18782                    std::task::Poll::Pending => return std::task::Poll::Pending,
18783                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18784                        this.is_terminated = true;
18785                        return std::task::Poll::Ready(None);
18786                    }
18787                    std::task::Poll::Ready(Err(e)) => {
18788                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18789                            e.into(),
18790                        ))));
18791                    }
18792                }
18793
18794                // A message has been received from the channel
18795                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18796
18797                std::task::Poll::Ready(Some(match header.ordinal {
18798                    0x767107c168c226af => {
18799                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18800                        let mut req = fidl::new_empty!(
18801                            UsageGainReporterRegisterListenerRequest,
18802                            fidl::encoding::DefaultFuchsiaResourceDialect
18803                        );
18804                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
18805                        let control_handle =
18806                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18807                        Ok(UsageGainReporterRequest::RegisterListener {
18808                            device_unique_id: req.device_unique_id,
18809                            usage: req.usage,
18810                            usage_gain_listener: req.usage_gain_listener,
18811
18812                            control_handle,
18813                        })
18814                    }
18815                    0x760a8e1c5873629c => {
18816                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18817                        let mut req = fidl::new_empty!(
18818                            UsageGainReporterRegisterListener2Request,
18819                            fidl::encoding::DefaultFuchsiaResourceDialect
18820                        );
18821                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
18822                        let control_handle =
18823                            UsageGainReporterControlHandle { inner: this.inner.clone() };
18824                        Ok(UsageGainReporterRequest::RegisterListener2 {
18825                            device_unique_id: req.device_unique_id,
18826                            usage: req.usage,
18827                            usage_gain_listener: req.usage_gain_listener,
18828
18829                            control_handle,
18830                        })
18831                    }
18832                    _ if header.tx_id == 0
18833                        && header
18834                            .dynamic_flags()
18835                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18836                    {
18837                        Ok(UsageGainReporterRequest::_UnknownMethod {
18838                            ordinal: header.ordinal,
18839                            control_handle: UsageGainReporterControlHandle {
18840                                inner: this.inner.clone(),
18841                            },
18842                            method_type: fidl::MethodType::OneWay,
18843                        })
18844                    }
18845                    _ if header
18846                        .dynamic_flags()
18847                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
18848                    {
18849                        this.inner.send_framework_err(
18850                            fidl::encoding::FrameworkErr::UnknownMethod,
18851                            header.tx_id,
18852                            header.ordinal,
18853                            header.dynamic_flags(),
18854                            (bytes, handles),
18855                        )?;
18856                        Ok(UsageGainReporterRequest::_UnknownMethod {
18857                            ordinal: header.ordinal,
18858                            control_handle: UsageGainReporterControlHandle {
18859                                inner: this.inner.clone(),
18860                            },
18861                            method_type: fidl::MethodType::TwoWay,
18862                        })
18863                    }
18864                    _ => Err(fidl::Error::UnknownOrdinal {
18865                        ordinal: header.ordinal,
18866                        protocol_name:
18867                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18868                    }),
18869                }))
18870            },
18871        )
18872    }
18873}
18874
18875/// A protocol for setting up watchers of usage gain.
18876#[derive(Debug)]
18877pub enum UsageGainReporterRequest {
18878    /// Connects a listener to a stream of usage gain setting changes
18879    /// for `usage` on the device identified by `device_token`. Usage
18880    /// Gain is not set directly by any client; it is a translation of
18881    /// the usage volume setting for each device, summed with active
18882    /// muting/ducking gain adjustments.
18883    ///
18884    /// Devices may map the same volume level to different dbfs, so
18885    /// a `device_unique_id` is needed to identify the device.
18886    ///
18887    /// `AudioDeviceEnumerator` provides programmatic access to devices
18888    /// and their unique ids if it is necessary for a client to select
18889    /// an id at runtime.
18890    RegisterListener {
18891        device_unique_id: String,
18892        usage: Usage,
18893        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18894        control_handle: UsageGainReporterControlHandle,
18895    },
18896    /// Connects a listener to a stream of usage gain setting changes
18897    /// for `usage` on the device identified by `device_token`. Usage
18898    /// Gain is not set directly by any client; it is a translation of
18899    /// the usage volume setting for each device, summed with active
18900    /// muting/ducking gain adjustments.
18901    ///
18902    /// Devices may map the same volume level to different dbfs, so
18903    /// a `device_unique_id` is needed to identify the device.
18904    ///
18905    /// `AudioDeviceEnumerator` provides programmatic access to devices
18906    /// and their unique ids if it is necessary for a client to select
18907    /// an id at runtime.
18908    RegisterListener2 {
18909        device_unique_id: String,
18910        usage: Usage2,
18911        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18912        control_handle: UsageGainReporterControlHandle,
18913    },
18914    /// An interaction was received which does not match any known method.
18915    #[non_exhaustive]
18916    _UnknownMethod {
18917        /// Ordinal of the method that was called.
18918        ordinal: u64,
18919        control_handle: UsageGainReporterControlHandle,
18920        method_type: fidl::MethodType,
18921    },
18922}
18923
18924impl UsageGainReporterRequest {
18925    #[allow(irrefutable_let_patterns)]
18926    pub fn into_register_listener(
18927        self,
18928    ) -> Option<(
18929        String,
18930        Usage,
18931        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18932        UsageGainReporterControlHandle,
18933    )> {
18934        if let UsageGainReporterRequest::RegisterListener {
18935            device_unique_id,
18936            usage,
18937            usage_gain_listener,
18938            control_handle,
18939        } = self
18940        {
18941            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18942        } else {
18943            None
18944        }
18945    }
18946
18947    #[allow(irrefutable_let_patterns)]
18948    pub fn into_register_listener2(
18949        self,
18950    ) -> Option<(
18951        String,
18952        Usage2,
18953        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
18954        UsageGainReporterControlHandle,
18955    )> {
18956        if let UsageGainReporterRequest::RegisterListener2 {
18957            device_unique_id,
18958            usage,
18959            usage_gain_listener,
18960            control_handle,
18961        } = self
18962        {
18963            Some((device_unique_id, usage, usage_gain_listener, control_handle))
18964        } else {
18965            None
18966        }
18967    }
18968
18969    /// Name of the method defined in FIDL
18970    pub fn method_name(&self) -> &'static str {
18971        match *self {
18972            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
18973            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
18974            UsageGainReporterRequest::_UnknownMethod {
18975                method_type: fidl::MethodType::OneWay,
18976                ..
18977            } => "unknown one-way method",
18978            UsageGainReporterRequest::_UnknownMethod {
18979                method_type: fidl::MethodType::TwoWay,
18980                ..
18981            } => "unknown two-way method",
18982        }
18983    }
18984}
18985
18986#[derive(Debug, Clone)]
18987pub struct UsageGainReporterControlHandle {
18988    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18989}
18990
18991impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
18992    fn shutdown(&self) {
18993        self.inner.shutdown()
18994    }
18995
18996    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
18997        self.inner.shutdown_with_epitaph(status)
18998    }
18999
19000    fn is_closed(&self) -> bool {
19001        self.inner.channel().is_closed()
19002    }
19003    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19004        self.inner.channel().on_closed()
19005    }
19006
19007    #[cfg(target_os = "fuchsia")]
19008    fn signal_peer(
19009        &self,
19010        clear_mask: zx::Signals,
19011        set_mask: zx::Signals,
19012    ) -> Result<(), zx_status::Status> {
19013        use fidl::Peered;
19014        self.inner.channel().signal_peer(clear_mask, set_mask)
19015    }
19016}
19017
19018impl UsageGainReporterControlHandle {}
19019
19020#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19021pub struct UsageReporterMarker;
19022
19023impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
19024    type Proxy = UsageReporterProxy;
19025    type RequestStream = UsageReporterRequestStream;
19026    #[cfg(target_os = "fuchsia")]
19027    type SynchronousProxy = UsageReporterSynchronousProxy;
19028
19029    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
19030}
19031impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
19032
19033pub trait UsageReporterProxyInterface: Send + Sync {
19034    fn r#watch(
19035        &self,
19036        usage: &Usage,
19037        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19038    ) -> Result<(), fidl::Error>;
19039    fn r#watch2(
19040        &self,
19041        usage: &Usage2,
19042        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19043    ) -> Result<(), fidl::Error>;
19044}
19045#[derive(Debug)]
19046#[cfg(target_os = "fuchsia")]
19047pub struct UsageReporterSynchronousProxy {
19048    client: fidl::client::sync::Client,
19049}
19050
19051#[cfg(target_os = "fuchsia")]
19052impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
19053    type Proxy = UsageReporterProxy;
19054    type Protocol = UsageReporterMarker;
19055
19056    fn from_channel(inner: fidl::Channel) -> Self {
19057        Self::new(inner)
19058    }
19059
19060    fn into_channel(self) -> fidl::Channel {
19061        self.client.into_channel()
19062    }
19063
19064    fn as_channel(&self) -> &fidl::Channel {
19065        self.client.as_channel()
19066    }
19067}
19068
19069#[cfg(target_os = "fuchsia")]
19070impl UsageReporterSynchronousProxy {
19071    pub fn new(channel: fidl::Channel) -> Self {
19072        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19073        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19074    }
19075
19076    pub fn into_channel(self) -> fidl::Channel {
19077        self.client.into_channel()
19078    }
19079
19080    /// Waits until an event arrives and returns it. It is safe for other
19081    /// threads to make concurrent requests while waiting for an event.
19082    pub fn wait_for_event(
19083        &self,
19084        deadline: zx::MonotonicInstant,
19085    ) -> Result<UsageReporterEvent, fidl::Error> {
19086        UsageReporterEvent::decode(self.client.wait_for_event(deadline)?)
19087    }
19088
19089    pub fn r#watch(
19090        &self,
19091        mut usage: &Usage,
19092        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19093    ) -> Result<(), fidl::Error> {
19094        self.client.send::<UsageReporterWatchRequest>(
19095            (usage, usage_watcher),
19096            0x769e6fb17075c959,
19097            fidl::encoding::DynamicFlags::empty(),
19098        )
19099    }
19100
19101    pub fn r#watch2(
19102        &self,
19103        mut usage: &Usage2,
19104        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19105    ) -> Result<(), fidl::Error> {
19106        self.client.send::<UsageReporterWatch2Request>(
19107            (usage, usage_watcher),
19108            0x4a43c4c82f5d8ce8,
19109            fidl::encoding::DynamicFlags::FLEXIBLE,
19110        )
19111    }
19112}
19113
19114#[cfg(target_os = "fuchsia")]
19115impl From<UsageReporterSynchronousProxy> for zx::NullableHandle {
19116    fn from(value: UsageReporterSynchronousProxy) -> Self {
19117        value.into_channel().into()
19118    }
19119}
19120
19121#[cfg(target_os = "fuchsia")]
19122impl From<fidl::Channel> for UsageReporterSynchronousProxy {
19123    fn from(value: fidl::Channel) -> Self {
19124        Self::new(value)
19125    }
19126}
19127
19128#[cfg(target_os = "fuchsia")]
19129impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
19130    type Protocol = UsageReporterMarker;
19131
19132    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
19133        Self::new(value.into_channel())
19134    }
19135}
19136
19137#[derive(Debug, Clone)]
19138pub struct UsageReporterProxy {
19139    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19140}
19141
19142impl fidl::endpoints::Proxy for UsageReporterProxy {
19143    type Protocol = UsageReporterMarker;
19144
19145    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19146        Self::new(inner)
19147    }
19148
19149    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19150        self.client.into_channel().map_err(|client| Self { client })
19151    }
19152
19153    fn as_channel(&self) -> &::fidl::AsyncChannel {
19154        self.client.as_channel()
19155    }
19156}
19157
19158impl UsageReporterProxy {
19159    /// Create a new Proxy for fuchsia.media/UsageReporter.
19160    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19161        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19162        Self { client: fidl::client::Client::new(channel, protocol_name) }
19163    }
19164
19165    /// Get a Stream of events from the remote end of the protocol.
19166    ///
19167    /// # Panics
19168    ///
19169    /// Panics if the event stream was already taken.
19170    pub fn take_event_stream(&self) -> UsageReporterEventStream {
19171        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
19172    }
19173
19174    pub fn r#watch(
19175        &self,
19176        mut usage: &Usage,
19177        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19178    ) -> Result<(), fidl::Error> {
19179        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
19180    }
19181
19182    pub fn r#watch2(
19183        &self,
19184        mut usage: &Usage2,
19185        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19186    ) -> Result<(), fidl::Error> {
19187        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
19188    }
19189}
19190
19191impl UsageReporterProxyInterface for UsageReporterProxy {
19192    fn r#watch(
19193        &self,
19194        mut usage: &Usage,
19195        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19196    ) -> Result<(), fidl::Error> {
19197        self.client.send::<UsageReporterWatchRequest>(
19198            (usage, usage_watcher),
19199            0x769e6fb17075c959,
19200            fidl::encoding::DynamicFlags::empty(),
19201        )
19202    }
19203
19204    fn r#watch2(
19205        &self,
19206        mut usage: &Usage2,
19207        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19208    ) -> Result<(), fidl::Error> {
19209        self.client.send::<UsageReporterWatch2Request>(
19210            (usage, usage_watcher),
19211            0x4a43c4c82f5d8ce8,
19212            fidl::encoding::DynamicFlags::FLEXIBLE,
19213        )
19214    }
19215}
19216
19217pub struct UsageReporterEventStream {
19218    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19219}
19220
19221impl std::marker::Unpin for UsageReporterEventStream {}
19222
19223impl futures::stream::FusedStream for UsageReporterEventStream {
19224    fn is_terminated(&self) -> bool {
19225        self.event_receiver.is_terminated()
19226    }
19227}
19228
19229impl futures::Stream for UsageReporterEventStream {
19230    type Item = Result<UsageReporterEvent, fidl::Error>;
19231
19232    fn poll_next(
19233        mut self: std::pin::Pin<&mut Self>,
19234        cx: &mut std::task::Context<'_>,
19235    ) -> std::task::Poll<Option<Self::Item>> {
19236        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19237            &mut self.event_receiver,
19238            cx
19239        )?) {
19240            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
19241            None => std::task::Poll::Ready(None),
19242        }
19243    }
19244}
19245
19246#[derive(Debug)]
19247pub enum UsageReporterEvent {
19248    #[non_exhaustive]
19249    _UnknownEvent {
19250        /// Ordinal of the event that was sent.
19251        ordinal: u64,
19252    },
19253}
19254
19255impl UsageReporterEvent {
19256    /// Decodes a message buffer as a [`UsageReporterEvent`].
19257    fn decode(
19258        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19259    ) -> Result<UsageReporterEvent, fidl::Error> {
19260        let (bytes, _handles) = buf.split_mut();
19261        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19262        debug_assert_eq!(tx_header.tx_id, 0);
19263        match tx_header.ordinal {
19264            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19265                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
19266            }
19267            _ => Err(fidl::Error::UnknownOrdinal {
19268                ordinal: tx_header.ordinal,
19269                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19270            }),
19271        }
19272    }
19273}
19274
19275/// A Stream of incoming requests for fuchsia.media/UsageReporter.
19276pub struct UsageReporterRequestStream {
19277    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19278    is_terminated: bool,
19279}
19280
19281impl std::marker::Unpin for UsageReporterRequestStream {}
19282
19283impl futures::stream::FusedStream for UsageReporterRequestStream {
19284    fn is_terminated(&self) -> bool {
19285        self.is_terminated
19286    }
19287}
19288
19289impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
19290    type Protocol = UsageReporterMarker;
19291    type ControlHandle = UsageReporterControlHandle;
19292
19293    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19294        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19295    }
19296
19297    fn control_handle(&self) -> Self::ControlHandle {
19298        UsageReporterControlHandle { inner: self.inner.clone() }
19299    }
19300
19301    fn into_inner(
19302        self,
19303    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19304    {
19305        (self.inner, self.is_terminated)
19306    }
19307
19308    fn from_inner(
19309        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19310        is_terminated: bool,
19311    ) -> Self {
19312        Self { inner, is_terminated }
19313    }
19314}
19315
19316impl futures::Stream for UsageReporterRequestStream {
19317    type Item = Result<UsageReporterRequest, fidl::Error>;
19318
19319    fn poll_next(
19320        mut self: std::pin::Pin<&mut Self>,
19321        cx: &mut std::task::Context<'_>,
19322    ) -> std::task::Poll<Option<Self::Item>> {
19323        let this = &mut *self;
19324        if this.inner.check_shutdown(cx) {
19325            this.is_terminated = true;
19326            return std::task::Poll::Ready(None);
19327        }
19328        if this.is_terminated {
19329            panic!("polled UsageReporterRequestStream after completion");
19330        }
19331        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19332            |bytes, handles| {
19333                match this.inner.channel().read_etc(cx, bytes, handles) {
19334                    std::task::Poll::Ready(Ok(())) => {}
19335                    std::task::Poll::Pending => return std::task::Poll::Pending,
19336                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19337                        this.is_terminated = true;
19338                        return std::task::Poll::Ready(None);
19339                    }
19340                    std::task::Poll::Ready(Err(e)) => {
19341                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19342                            e.into(),
19343                        ))));
19344                    }
19345                }
19346
19347                // A message has been received from the channel
19348                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19349
19350                std::task::Poll::Ready(Some(match header.ordinal {
19351                    0x769e6fb17075c959 => {
19352                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19353                        let mut req = fidl::new_empty!(
19354                            UsageReporterWatchRequest,
19355                            fidl::encoding::DefaultFuchsiaResourceDialect
19356                        );
19357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
19358                        let control_handle =
19359                            UsageReporterControlHandle { inner: this.inner.clone() };
19360                        Ok(UsageReporterRequest::Watch {
19361                            usage: req.usage,
19362                            usage_watcher: req.usage_watcher,
19363
19364                            control_handle,
19365                        })
19366                    }
19367                    0x4a43c4c82f5d8ce8 => {
19368                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19369                        let mut req = fidl::new_empty!(
19370                            UsageReporterWatch2Request,
19371                            fidl::encoding::DefaultFuchsiaResourceDialect
19372                        );
19373                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
19374                        let control_handle =
19375                            UsageReporterControlHandle { inner: this.inner.clone() };
19376                        Ok(UsageReporterRequest::Watch2 {
19377                            usage: req.usage,
19378                            usage_watcher: req.usage_watcher,
19379
19380                            control_handle,
19381                        })
19382                    }
19383                    _ if header.tx_id == 0
19384                        && header
19385                            .dynamic_flags()
19386                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19387                    {
19388                        Ok(UsageReporterRequest::_UnknownMethod {
19389                            ordinal: header.ordinal,
19390                            control_handle: UsageReporterControlHandle {
19391                                inner: this.inner.clone(),
19392                            },
19393                            method_type: fidl::MethodType::OneWay,
19394                        })
19395                    }
19396                    _ if header
19397                        .dynamic_flags()
19398                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
19399                    {
19400                        this.inner.send_framework_err(
19401                            fidl::encoding::FrameworkErr::UnknownMethod,
19402                            header.tx_id,
19403                            header.ordinal,
19404                            header.dynamic_flags(),
19405                            (bytes, handles),
19406                        )?;
19407                        Ok(UsageReporterRequest::_UnknownMethod {
19408                            ordinal: header.ordinal,
19409                            control_handle: UsageReporterControlHandle {
19410                                inner: this.inner.clone(),
19411                            },
19412                            method_type: fidl::MethodType::TwoWay,
19413                        })
19414                    }
19415                    _ => Err(fidl::Error::UnknownOrdinal {
19416                        ordinal: header.ordinal,
19417                        protocol_name:
19418                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19419                    }),
19420                }))
19421            },
19422        )
19423    }
19424}
19425
19426/// A protocol for setting up watchers of audio usages.
19427#[derive(Debug)]
19428pub enum UsageReporterRequest {
19429    Watch {
19430        usage: Usage,
19431        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
19432        control_handle: UsageReporterControlHandle,
19433    },
19434    Watch2 {
19435        usage: Usage2,
19436        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
19437        control_handle: UsageReporterControlHandle,
19438    },
19439    /// An interaction was received which does not match any known method.
19440    #[non_exhaustive]
19441    _UnknownMethod {
19442        /// Ordinal of the method that was called.
19443        ordinal: u64,
19444        control_handle: UsageReporterControlHandle,
19445        method_type: fidl::MethodType,
19446    },
19447}
19448
19449impl UsageReporterRequest {
19450    #[allow(irrefutable_let_patterns)]
19451    pub fn into_watch(
19452        self,
19453    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
19454    {
19455        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
19456            Some((usage, usage_watcher, control_handle))
19457        } else {
19458            None
19459        }
19460    }
19461
19462    #[allow(irrefutable_let_patterns)]
19463    pub fn into_watch2(
19464        self,
19465    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
19466    {
19467        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
19468            Some((usage, usage_watcher, control_handle))
19469        } else {
19470            None
19471        }
19472    }
19473
19474    /// Name of the method defined in FIDL
19475    pub fn method_name(&self) -> &'static str {
19476        match *self {
19477            UsageReporterRequest::Watch { .. } => "watch",
19478            UsageReporterRequest::Watch2 { .. } => "watch2",
19479            UsageReporterRequest::_UnknownMethod {
19480                method_type: fidl::MethodType::OneWay, ..
19481            } => "unknown one-way method",
19482            UsageReporterRequest::_UnknownMethod {
19483                method_type: fidl::MethodType::TwoWay, ..
19484            } => "unknown two-way method",
19485        }
19486    }
19487}
19488
19489#[derive(Debug, Clone)]
19490pub struct UsageReporterControlHandle {
19491    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19492}
19493
19494impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
19495    fn shutdown(&self) {
19496        self.inner.shutdown()
19497    }
19498
19499    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19500        self.inner.shutdown_with_epitaph(status)
19501    }
19502
19503    fn is_closed(&self) -> bool {
19504        self.inner.channel().is_closed()
19505    }
19506    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19507        self.inner.channel().on_closed()
19508    }
19509
19510    #[cfg(target_os = "fuchsia")]
19511    fn signal_peer(
19512        &self,
19513        clear_mask: zx::Signals,
19514        set_mask: zx::Signals,
19515    ) -> Result<(), zx_status::Status> {
19516        use fidl::Peered;
19517        self.inner.channel().signal_peer(clear_mask, set_mask)
19518    }
19519}
19520
19521impl UsageReporterControlHandle {}
19522
19523#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19524pub struct UsageWatcherMarker;
19525
19526impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
19527    type Proxy = UsageWatcherProxy;
19528    type RequestStream = UsageWatcherRequestStream;
19529    #[cfg(target_os = "fuchsia")]
19530    type SynchronousProxy = UsageWatcherSynchronousProxy;
19531
19532    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
19533}
19534
19535pub trait UsageWatcherProxyInterface: Send + Sync {
19536    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
19537    fn r#on_state_changed(
19538        &self,
19539        usage: &Usage,
19540        state: &UsageState,
19541    ) -> Self::OnStateChangedResponseFut;
19542}
19543#[derive(Debug)]
19544#[cfg(target_os = "fuchsia")]
19545pub struct UsageWatcherSynchronousProxy {
19546    client: fidl::client::sync::Client,
19547}
19548
19549#[cfg(target_os = "fuchsia")]
19550impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
19551    type Proxy = UsageWatcherProxy;
19552    type Protocol = UsageWatcherMarker;
19553
19554    fn from_channel(inner: fidl::Channel) -> Self {
19555        Self::new(inner)
19556    }
19557
19558    fn into_channel(self) -> fidl::Channel {
19559        self.client.into_channel()
19560    }
19561
19562    fn as_channel(&self) -> &fidl::Channel {
19563        self.client.as_channel()
19564    }
19565}
19566
19567#[cfg(target_os = "fuchsia")]
19568impl UsageWatcherSynchronousProxy {
19569    pub fn new(channel: fidl::Channel) -> Self {
19570        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19571        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
19572    }
19573
19574    pub fn into_channel(self) -> fidl::Channel {
19575        self.client.into_channel()
19576    }
19577
19578    /// Waits until an event arrives and returns it. It is safe for other
19579    /// threads to make concurrent requests while waiting for an event.
19580    pub fn wait_for_event(
19581        &self,
19582        deadline: zx::MonotonicInstant,
19583    ) -> Result<UsageWatcherEvent, fidl::Error> {
19584        UsageWatcherEvent::decode(self.client.wait_for_event(deadline)?)
19585    }
19586
19587    /// Called on first connection and whenever the watched usage changes. The provided
19588    /// usage will always be the bound usage; it is provided so that an implementation of
19589    /// this protocol may be bound to more than one usage.
19590    ///
19591    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19592    /// events will eventually be disconnected.
19593    pub fn r#on_state_changed(
19594        &self,
19595        mut usage: &Usage,
19596        mut state: &UsageState,
19597        ___deadline: zx::MonotonicInstant,
19598    ) -> Result<(), fidl::Error> {
19599        let _response = self
19600            .client
19601            .send_query::<UsageWatcherOnStateChangedRequest, fidl::encoding::EmptyPayload>(
19602                (usage, state),
19603                0x5b955c5768ec75c5,
19604                fidl::encoding::DynamicFlags::empty(),
19605                ___deadline,
19606            )?;
19607        Ok(_response)
19608    }
19609}
19610
19611#[cfg(target_os = "fuchsia")]
19612impl From<UsageWatcherSynchronousProxy> for zx::NullableHandle {
19613    fn from(value: UsageWatcherSynchronousProxy) -> Self {
19614        value.into_channel().into()
19615    }
19616}
19617
19618#[cfg(target_os = "fuchsia")]
19619impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
19620    fn from(value: fidl::Channel) -> Self {
19621        Self::new(value)
19622    }
19623}
19624
19625#[cfg(target_os = "fuchsia")]
19626impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
19627    type Protocol = UsageWatcherMarker;
19628
19629    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
19630        Self::new(value.into_channel())
19631    }
19632}
19633
19634#[derive(Debug, Clone)]
19635pub struct UsageWatcherProxy {
19636    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19637}
19638
19639impl fidl::endpoints::Proxy for UsageWatcherProxy {
19640    type Protocol = UsageWatcherMarker;
19641
19642    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19643        Self::new(inner)
19644    }
19645
19646    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19647        self.client.into_channel().map_err(|client| Self { client })
19648    }
19649
19650    fn as_channel(&self) -> &::fidl::AsyncChannel {
19651        self.client.as_channel()
19652    }
19653}
19654
19655impl UsageWatcherProxy {
19656    /// Create a new Proxy for fuchsia.media/UsageWatcher.
19657    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19658        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19659        Self { client: fidl::client::Client::new(channel, protocol_name) }
19660    }
19661
19662    /// Get a Stream of events from the remote end of the protocol.
19663    ///
19664    /// # Panics
19665    ///
19666    /// Panics if the event stream was already taken.
19667    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
19668        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
19669    }
19670
19671    /// Called on first connection and whenever the watched usage changes. The provided
19672    /// usage will always be the bound usage; it is provided so that an implementation of
19673    /// this protocol may be bound to more than one usage.
19674    ///
19675    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19676    /// events will eventually be disconnected.
19677    pub fn r#on_state_changed(
19678        &self,
19679        mut usage: &Usage,
19680        mut state: &UsageState,
19681    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
19682        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
19683    }
19684}
19685
19686impl UsageWatcherProxyInterface for UsageWatcherProxy {
19687    type OnStateChangedResponseFut =
19688        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
19689    fn r#on_state_changed(
19690        &self,
19691        mut usage: &Usage,
19692        mut state: &UsageState,
19693    ) -> Self::OnStateChangedResponseFut {
19694        fn _decode(
19695            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
19696        ) -> Result<(), fidl::Error> {
19697            let _response = fidl::client::decode_transaction_body::<
19698                fidl::encoding::EmptyPayload,
19699                fidl::encoding::DefaultFuchsiaResourceDialect,
19700                0x5b955c5768ec75c5,
19701            >(_buf?)?;
19702            Ok(_response)
19703        }
19704        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
19705            (usage, state),
19706            0x5b955c5768ec75c5,
19707            fidl::encoding::DynamicFlags::empty(),
19708            _decode,
19709        )
19710    }
19711}
19712
19713pub struct UsageWatcherEventStream {
19714    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19715}
19716
19717impl std::marker::Unpin for UsageWatcherEventStream {}
19718
19719impl futures::stream::FusedStream for UsageWatcherEventStream {
19720    fn is_terminated(&self) -> bool {
19721        self.event_receiver.is_terminated()
19722    }
19723}
19724
19725impl futures::Stream for UsageWatcherEventStream {
19726    type Item = Result<UsageWatcherEvent, fidl::Error>;
19727
19728    fn poll_next(
19729        mut self: std::pin::Pin<&mut Self>,
19730        cx: &mut std::task::Context<'_>,
19731    ) -> std::task::Poll<Option<Self::Item>> {
19732        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19733            &mut self.event_receiver,
19734            cx
19735        )?) {
19736            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
19737            None => std::task::Poll::Ready(None),
19738        }
19739    }
19740}
19741
19742#[derive(Debug)]
19743pub enum UsageWatcherEvent {}
19744
19745impl UsageWatcherEvent {
19746    /// Decodes a message buffer as a [`UsageWatcherEvent`].
19747    fn decode(
19748        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19749    ) -> Result<UsageWatcherEvent, fidl::Error> {
19750        let (bytes, _handles) = buf.split_mut();
19751        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19752        debug_assert_eq!(tx_header.tx_id, 0);
19753        match tx_header.ordinal {
19754            _ => Err(fidl::Error::UnknownOrdinal {
19755                ordinal: tx_header.ordinal,
19756                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19757            }),
19758        }
19759    }
19760}
19761
19762/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
19763pub struct UsageWatcherRequestStream {
19764    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19765    is_terminated: bool,
19766}
19767
19768impl std::marker::Unpin for UsageWatcherRequestStream {}
19769
19770impl futures::stream::FusedStream for UsageWatcherRequestStream {
19771    fn is_terminated(&self) -> bool {
19772        self.is_terminated
19773    }
19774}
19775
19776impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
19777    type Protocol = UsageWatcherMarker;
19778    type ControlHandle = UsageWatcherControlHandle;
19779
19780    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19781        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19782    }
19783
19784    fn control_handle(&self) -> Self::ControlHandle {
19785        UsageWatcherControlHandle { inner: self.inner.clone() }
19786    }
19787
19788    fn into_inner(
19789        self,
19790    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19791    {
19792        (self.inner, self.is_terminated)
19793    }
19794
19795    fn from_inner(
19796        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19797        is_terminated: bool,
19798    ) -> Self {
19799        Self { inner, is_terminated }
19800    }
19801}
19802
19803impl futures::Stream for UsageWatcherRequestStream {
19804    type Item = Result<UsageWatcherRequest, fidl::Error>;
19805
19806    fn poll_next(
19807        mut self: std::pin::Pin<&mut Self>,
19808        cx: &mut std::task::Context<'_>,
19809    ) -> std::task::Poll<Option<Self::Item>> {
19810        let this = &mut *self;
19811        if this.inner.check_shutdown(cx) {
19812            this.is_terminated = true;
19813            return std::task::Poll::Ready(None);
19814        }
19815        if this.is_terminated {
19816            panic!("polled UsageWatcherRequestStream after completion");
19817        }
19818        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19819            |bytes, handles| {
19820                match this.inner.channel().read_etc(cx, bytes, handles) {
19821                    std::task::Poll::Ready(Ok(())) => {}
19822                    std::task::Poll::Pending => return std::task::Poll::Pending,
19823                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19824                        this.is_terminated = true;
19825                        return std::task::Poll::Ready(None);
19826                    }
19827                    std::task::Poll::Ready(Err(e)) => {
19828                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19829                            e.into(),
19830                        ))));
19831                    }
19832                }
19833
19834                // A message has been received from the channel
19835                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19836
19837                std::task::Poll::Ready(Some(match header.ordinal {
19838                    0x5b955c5768ec75c5 => {
19839                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19840                        let mut req = fidl::new_empty!(
19841                            UsageWatcherOnStateChangedRequest,
19842                            fidl::encoding::DefaultFuchsiaResourceDialect
19843                        );
19844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
19845                        let control_handle =
19846                            UsageWatcherControlHandle { inner: this.inner.clone() };
19847                        Ok(UsageWatcherRequest::OnStateChanged {
19848                            usage: req.usage,
19849                            state: req.state,
19850
19851                            responder: UsageWatcherOnStateChangedResponder {
19852                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19853                                tx_id: header.tx_id,
19854                            },
19855                        })
19856                    }
19857                    _ => Err(fidl::Error::UnknownOrdinal {
19858                        ordinal: header.ordinal,
19859                        protocol_name:
19860                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19861                    }),
19862                }))
19863            },
19864        )
19865    }
19866}
19867
19868/// A protocol for listening to changes to the policy state of an audio usage.
19869///
19870/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
19871#[derive(Debug)]
19872pub enum UsageWatcherRequest {
19873    /// Called on first connection and whenever the watched usage changes. The provided
19874    /// usage will always be the bound usage; it is provided so that an implementation of
19875    /// this protocol may be bound to more than one usage.
19876    ///
19877    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
19878    /// events will eventually be disconnected.
19879    OnStateChanged {
19880        usage: Usage,
19881        state: UsageState,
19882        responder: UsageWatcherOnStateChangedResponder,
19883    },
19884}
19885
19886impl UsageWatcherRequest {
19887    #[allow(irrefutable_let_patterns)]
19888    pub fn into_on_state_changed(
19889        self,
19890    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
19891        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
19892            Some((usage, state, responder))
19893        } else {
19894            None
19895        }
19896    }
19897
19898    /// Name of the method defined in FIDL
19899    pub fn method_name(&self) -> &'static str {
19900        match *self {
19901            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
19902        }
19903    }
19904}
19905
19906#[derive(Debug, Clone)]
19907pub struct UsageWatcherControlHandle {
19908    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19909}
19910
19911impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
19912    fn shutdown(&self) {
19913        self.inner.shutdown()
19914    }
19915
19916    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
19917        self.inner.shutdown_with_epitaph(status)
19918    }
19919
19920    fn is_closed(&self) -> bool {
19921        self.inner.channel().is_closed()
19922    }
19923    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19924        self.inner.channel().on_closed()
19925    }
19926
19927    #[cfg(target_os = "fuchsia")]
19928    fn signal_peer(
19929        &self,
19930        clear_mask: zx::Signals,
19931        set_mask: zx::Signals,
19932    ) -> Result<(), zx_status::Status> {
19933        use fidl::Peered;
19934        self.inner.channel().signal_peer(clear_mask, set_mask)
19935    }
19936}
19937
19938impl UsageWatcherControlHandle {}
19939
19940#[must_use = "FIDL methods require a response to be sent"]
19941#[derive(Debug)]
19942pub struct UsageWatcherOnStateChangedResponder {
19943    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
19944    tx_id: u32,
19945}
19946
19947/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
19948/// if the responder is dropped without sending a response, so that the client
19949/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19950impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
19951    fn drop(&mut self) {
19952        self.control_handle.shutdown();
19953        // Safety: drops once, never accessed again
19954        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19955    }
19956}
19957
19958impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
19959    type ControlHandle = UsageWatcherControlHandle;
19960
19961    fn control_handle(&self) -> &UsageWatcherControlHandle {
19962        &self.control_handle
19963    }
19964
19965    fn drop_without_shutdown(mut self) {
19966        // Safety: drops once, never accessed again due to mem::forget
19967        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19968        // Prevent Drop from running (which would shut down the channel)
19969        std::mem::forget(self);
19970    }
19971}
19972
19973impl UsageWatcherOnStateChangedResponder {
19974    /// Sends a response to the FIDL transaction.
19975    ///
19976    /// Sets the channel to shutdown if an error occurs.
19977    pub fn send(self) -> Result<(), fidl::Error> {
19978        let _result = self.send_raw();
19979        if _result.is_err() {
19980            self.control_handle.shutdown();
19981        }
19982        self.drop_without_shutdown();
19983        _result
19984    }
19985
19986    /// Similar to "send" but does not shutdown the channel if an error occurs.
19987    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
19988        let _result = self.send_raw();
19989        self.drop_without_shutdown();
19990        _result
19991    }
19992
19993    fn send_raw(&self) -> Result<(), fidl::Error> {
19994        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
19995            (),
19996            self.tx_id,
19997            0x5b955c5768ec75c5,
19998            fidl::encoding::DynamicFlags::empty(),
19999        )
20000    }
20001}
20002
20003#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20004pub struct UsageWatcher2Marker;
20005
20006impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
20007    type Proxy = UsageWatcher2Proxy;
20008    type RequestStream = UsageWatcher2RequestStream;
20009    #[cfg(target_os = "fuchsia")]
20010    type SynchronousProxy = UsageWatcher2SynchronousProxy;
20011
20012    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
20013}
20014
20015pub trait UsageWatcher2ProxyInterface: Send + Sync {
20016    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
20017    fn r#on_state_changed(
20018        &self,
20019        usage: &Usage2,
20020        state: &UsageState,
20021    ) -> Self::OnStateChangedResponseFut;
20022}
20023#[derive(Debug)]
20024#[cfg(target_os = "fuchsia")]
20025pub struct UsageWatcher2SynchronousProxy {
20026    client: fidl::client::sync::Client,
20027}
20028
20029#[cfg(target_os = "fuchsia")]
20030impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
20031    type Proxy = UsageWatcher2Proxy;
20032    type Protocol = UsageWatcher2Marker;
20033
20034    fn from_channel(inner: fidl::Channel) -> Self {
20035        Self::new(inner)
20036    }
20037
20038    fn into_channel(self) -> fidl::Channel {
20039        self.client.into_channel()
20040    }
20041
20042    fn as_channel(&self) -> &fidl::Channel {
20043        self.client.as_channel()
20044    }
20045}
20046
20047#[cfg(target_os = "fuchsia")]
20048impl UsageWatcher2SynchronousProxy {
20049    pub fn new(channel: fidl::Channel) -> Self {
20050        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20051        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
20052    }
20053
20054    pub fn into_channel(self) -> fidl::Channel {
20055        self.client.into_channel()
20056    }
20057
20058    /// Waits until an event arrives and returns it. It is safe for other
20059    /// threads to make concurrent requests while waiting for an event.
20060    pub fn wait_for_event(
20061        &self,
20062        deadline: zx::MonotonicInstant,
20063    ) -> Result<UsageWatcher2Event, fidl::Error> {
20064        UsageWatcher2Event::decode(self.client.wait_for_event(deadline)?)
20065    }
20066
20067    /// Called on first connection and whenever the watched usage changes. The provided
20068    /// usage will always be the bound usage; it is provided so that an implementation of
20069    /// this protocol may be bound to more than one usage.
20070    ///
20071    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20072    /// events will eventually be disconnected.
20073    pub fn r#on_state_changed(
20074        &self,
20075        mut usage: &Usage2,
20076        mut state: &UsageState,
20077        ___deadline: zx::MonotonicInstant,
20078    ) -> Result<(), fidl::Error> {
20079        let _response = self
20080            .client
20081            .send_query::<UsageWatcher2OnStateChangedRequest, fidl::encoding::EmptyPayload>(
20082                (usage, state),
20083                0xca31a8b13c324d4,
20084                fidl::encoding::DynamicFlags::empty(),
20085                ___deadline,
20086            )?;
20087        Ok(_response)
20088    }
20089}
20090
20091#[cfg(target_os = "fuchsia")]
20092impl From<UsageWatcher2SynchronousProxy> for zx::NullableHandle {
20093    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
20094        value.into_channel().into()
20095    }
20096}
20097
20098#[cfg(target_os = "fuchsia")]
20099impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
20100    fn from(value: fidl::Channel) -> Self {
20101        Self::new(value)
20102    }
20103}
20104
20105#[cfg(target_os = "fuchsia")]
20106impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
20107    type Protocol = UsageWatcher2Marker;
20108
20109    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
20110        Self::new(value.into_channel())
20111    }
20112}
20113
20114#[derive(Debug, Clone)]
20115pub struct UsageWatcher2Proxy {
20116    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20117}
20118
20119impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
20120    type Protocol = UsageWatcher2Marker;
20121
20122    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20123        Self::new(inner)
20124    }
20125
20126    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20127        self.client.into_channel().map_err(|client| Self { client })
20128    }
20129
20130    fn as_channel(&self) -> &::fidl::AsyncChannel {
20131        self.client.as_channel()
20132    }
20133}
20134
20135impl UsageWatcher2Proxy {
20136    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
20137    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20138        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20139        Self { client: fidl::client::Client::new(channel, protocol_name) }
20140    }
20141
20142    /// Get a Stream of events from the remote end of the protocol.
20143    ///
20144    /// # Panics
20145    ///
20146    /// Panics if the event stream was already taken.
20147    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
20148        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
20149    }
20150
20151    /// Called on first connection and whenever the watched usage changes. The provided
20152    /// usage will always be the bound usage; it is provided so that an implementation of
20153    /// this protocol may be bound to more than one usage.
20154    ///
20155    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20156    /// events will eventually be disconnected.
20157    pub fn r#on_state_changed(
20158        &self,
20159        mut usage: &Usage2,
20160        mut state: &UsageState,
20161    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20162        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
20163    }
20164}
20165
20166impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
20167    type OnStateChangedResponseFut =
20168        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20169    fn r#on_state_changed(
20170        &self,
20171        mut usage: &Usage2,
20172        mut state: &UsageState,
20173    ) -> Self::OnStateChangedResponseFut {
20174        fn _decode(
20175            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20176        ) -> Result<(), fidl::Error> {
20177            let _response = fidl::client::decode_transaction_body::<
20178                fidl::encoding::EmptyPayload,
20179                fidl::encoding::DefaultFuchsiaResourceDialect,
20180                0xca31a8b13c324d4,
20181            >(_buf?)?;
20182            Ok(_response)
20183        }
20184        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
20185            (usage, state),
20186            0xca31a8b13c324d4,
20187            fidl::encoding::DynamicFlags::empty(),
20188            _decode,
20189        )
20190    }
20191}
20192
20193pub struct UsageWatcher2EventStream {
20194    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20195}
20196
20197impl std::marker::Unpin for UsageWatcher2EventStream {}
20198
20199impl futures::stream::FusedStream for UsageWatcher2EventStream {
20200    fn is_terminated(&self) -> bool {
20201        self.event_receiver.is_terminated()
20202    }
20203}
20204
20205impl futures::Stream for UsageWatcher2EventStream {
20206    type Item = Result<UsageWatcher2Event, fidl::Error>;
20207
20208    fn poll_next(
20209        mut self: std::pin::Pin<&mut Self>,
20210        cx: &mut std::task::Context<'_>,
20211    ) -> std::task::Poll<Option<Self::Item>> {
20212        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20213            &mut self.event_receiver,
20214            cx
20215        )?) {
20216            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
20217            None => std::task::Poll::Ready(None),
20218        }
20219    }
20220}
20221
20222#[derive(Debug)]
20223pub enum UsageWatcher2Event {}
20224
20225impl UsageWatcher2Event {
20226    /// Decodes a message buffer as a [`UsageWatcher2Event`].
20227    fn decode(
20228        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20229    ) -> Result<UsageWatcher2Event, fidl::Error> {
20230        let (bytes, _handles) = buf.split_mut();
20231        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20232        debug_assert_eq!(tx_header.tx_id, 0);
20233        match tx_header.ordinal {
20234            _ => Err(fidl::Error::UnknownOrdinal {
20235                ordinal: tx_header.ordinal,
20236                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20237            }),
20238        }
20239    }
20240}
20241
20242/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
20243pub struct UsageWatcher2RequestStream {
20244    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20245    is_terminated: bool,
20246}
20247
20248impl std::marker::Unpin for UsageWatcher2RequestStream {}
20249
20250impl futures::stream::FusedStream for UsageWatcher2RequestStream {
20251    fn is_terminated(&self) -> bool {
20252        self.is_terminated
20253    }
20254}
20255
20256impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
20257    type Protocol = UsageWatcher2Marker;
20258    type ControlHandle = UsageWatcher2ControlHandle;
20259
20260    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20261        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20262    }
20263
20264    fn control_handle(&self) -> Self::ControlHandle {
20265        UsageWatcher2ControlHandle { inner: self.inner.clone() }
20266    }
20267
20268    fn into_inner(
20269        self,
20270    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20271    {
20272        (self.inner, self.is_terminated)
20273    }
20274
20275    fn from_inner(
20276        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20277        is_terminated: bool,
20278    ) -> Self {
20279        Self { inner, is_terminated }
20280    }
20281}
20282
20283impl futures::Stream for UsageWatcher2RequestStream {
20284    type Item = Result<UsageWatcher2Request, fidl::Error>;
20285
20286    fn poll_next(
20287        mut self: std::pin::Pin<&mut Self>,
20288        cx: &mut std::task::Context<'_>,
20289    ) -> std::task::Poll<Option<Self::Item>> {
20290        let this = &mut *self;
20291        if this.inner.check_shutdown(cx) {
20292            this.is_terminated = true;
20293            return std::task::Poll::Ready(None);
20294        }
20295        if this.is_terminated {
20296            panic!("polled UsageWatcher2RequestStream after completion");
20297        }
20298        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20299            |bytes, handles| {
20300                match this.inner.channel().read_etc(cx, bytes, handles) {
20301                    std::task::Poll::Ready(Ok(())) => {}
20302                    std::task::Poll::Pending => return std::task::Poll::Pending,
20303                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20304                        this.is_terminated = true;
20305                        return std::task::Poll::Ready(None);
20306                    }
20307                    std::task::Poll::Ready(Err(e)) => {
20308                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20309                            e.into(),
20310                        ))));
20311                    }
20312                }
20313
20314                // A message has been received from the channel
20315                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20316
20317                std::task::Poll::Ready(Some(match header.ordinal {
20318                    0xca31a8b13c324d4 => {
20319                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20320                        let mut req = fidl::new_empty!(
20321                            UsageWatcher2OnStateChangedRequest,
20322                            fidl::encoding::DefaultFuchsiaResourceDialect
20323                        );
20324                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20325                        let control_handle =
20326                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
20327                        Ok(UsageWatcher2Request::OnStateChanged {
20328                            usage: req.usage,
20329                            state: req.state,
20330
20331                            responder: UsageWatcher2OnStateChangedResponder {
20332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20333                                tx_id: header.tx_id,
20334                            },
20335                        })
20336                    }
20337                    _ => Err(fidl::Error::UnknownOrdinal {
20338                        ordinal: header.ordinal,
20339                        protocol_name:
20340                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20341                    }),
20342                }))
20343            },
20344        )
20345    }
20346}
20347
20348#[derive(Debug)]
20349pub enum UsageWatcher2Request {
20350    /// Called on first connection and whenever the watched usage changes. The provided
20351    /// usage will always be the bound usage; it is provided so that an implementation of
20352    /// this protocol may be bound to more than one usage.
20353    ///
20354    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20355    /// events will eventually be disconnected.
20356    OnStateChanged {
20357        usage: Usage2,
20358        state: UsageState,
20359        responder: UsageWatcher2OnStateChangedResponder,
20360    },
20361}
20362
20363impl UsageWatcher2Request {
20364    #[allow(irrefutable_let_patterns)]
20365    pub fn into_on_state_changed(
20366        self,
20367    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
20368        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
20369            Some((usage, state, responder))
20370        } else {
20371            None
20372        }
20373    }
20374
20375    /// Name of the method defined in FIDL
20376    pub fn method_name(&self) -> &'static str {
20377        match *self {
20378            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
20379        }
20380    }
20381}
20382
20383#[derive(Debug, Clone)]
20384pub struct UsageWatcher2ControlHandle {
20385    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20386}
20387
20388impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
20389    fn shutdown(&self) {
20390        self.inner.shutdown()
20391    }
20392
20393    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
20394        self.inner.shutdown_with_epitaph(status)
20395    }
20396
20397    fn is_closed(&self) -> bool {
20398        self.inner.channel().is_closed()
20399    }
20400    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20401        self.inner.channel().on_closed()
20402    }
20403
20404    #[cfg(target_os = "fuchsia")]
20405    fn signal_peer(
20406        &self,
20407        clear_mask: zx::Signals,
20408        set_mask: zx::Signals,
20409    ) -> Result<(), zx_status::Status> {
20410        use fidl::Peered;
20411        self.inner.channel().signal_peer(clear_mask, set_mask)
20412    }
20413}
20414
20415impl UsageWatcher2ControlHandle {}
20416
20417#[must_use = "FIDL methods require a response to be sent"]
20418#[derive(Debug)]
20419pub struct UsageWatcher2OnStateChangedResponder {
20420    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
20421    tx_id: u32,
20422}
20423
20424/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
20425/// if the responder is dropped without sending a response, so that the client
20426/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20427impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
20428    fn drop(&mut self) {
20429        self.control_handle.shutdown();
20430        // Safety: drops once, never accessed again
20431        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20432    }
20433}
20434
20435impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
20436    type ControlHandle = UsageWatcher2ControlHandle;
20437
20438    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
20439        &self.control_handle
20440    }
20441
20442    fn drop_without_shutdown(mut self) {
20443        // Safety: drops once, never accessed again due to mem::forget
20444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20445        // Prevent Drop from running (which would shut down the channel)
20446        std::mem::forget(self);
20447    }
20448}
20449
20450impl UsageWatcher2OnStateChangedResponder {
20451    /// Sends a response to the FIDL transaction.
20452    ///
20453    /// Sets the channel to shutdown if an error occurs.
20454    pub fn send(self) -> Result<(), fidl::Error> {
20455        let _result = self.send_raw();
20456        if _result.is_err() {
20457            self.control_handle.shutdown();
20458        }
20459        self.drop_without_shutdown();
20460        _result
20461    }
20462
20463    /// Similar to "send" but does not shutdown the channel if an error occurs.
20464    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20465        let _result = self.send_raw();
20466        self.drop_without_shutdown();
20467        _result
20468    }
20469
20470    fn send_raw(&self) -> Result<(), fidl::Error> {
20471        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20472            (),
20473            self.tx_id,
20474            0xca31a8b13c324d4,
20475            fidl::encoding::DynamicFlags::empty(),
20476        )
20477    }
20478}
20479
20480mod internal {
20481    use super::*;
20482
20483    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
20484        type Borrowed<'a> = &'a mut Self;
20485        fn take_or_borrow<'a>(
20486            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20487        ) -> Self::Borrowed<'a> {
20488            value
20489        }
20490    }
20491
20492    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
20493        type Owned = Self;
20494
20495        #[inline(always)]
20496        fn inline_align(_context: fidl::encoding::Context) -> usize {
20497            4
20498        }
20499
20500        #[inline(always)]
20501        fn inline_size(_context: fidl::encoding::Context) -> usize {
20502            4
20503        }
20504    }
20505
20506    unsafe impl
20507        fidl::encoding::Encode<
20508            AudioCapturerBindGainControlRequest,
20509            fidl::encoding::DefaultFuchsiaResourceDialect,
20510        > for &mut AudioCapturerBindGainControlRequest
20511    {
20512        #[inline]
20513        unsafe fn encode(
20514            self,
20515            encoder: &mut fidl::encoding::Encoder<
20516                '_,
20517                fidl::encoding::DefaultFuchsiaResourceDialect,
20518            >,
20519            offset: usize,
20520            _depth: fidl::encoding::Depth,
20521        ) -> fidl::Result<()> {
20522            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20523            // Delegate to tuple encoding.
20524            fidl::encoding::Encode::<
20525                AudioCapturerBindGainControlRequest,
20526                fidl::encoding::DefaultFuchsiaResourceDialect,
20527            >::encode(
20528                (<fidl::encoding::Endpoint<
20529                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20530                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20531                    &mut self.gain_control_request,
20532                ),),
20533                encoder,
20534                offset,
20535                _depth,
20536            )
20537        }
20538    }
20539    unsafe impl<
20540        T0: fidl::encoding::Encode<
20541                fidl::encoding::Endpoint<
20542                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20543                >,
20544                fidl::encoding::DefaultFuchsiaResourceDialect,
20545            >,
20546    >
20547        fidl::encoding::Encode<
20548            AudioCapturerBindGainControlRequest,
20549            fidl::encoding::DefaultFuchsiaResourceDialect,
20550        > for (T0,)
20551    {
20552        #[inline]
20553        unsafe fn encode(
20554            self,
20555            encoder: &mut fidl::encoding::Encoder<
20556                '_,
20557                fidl::encoding::DefaultFuchsiaResourceDialect,
20558            >,
20559            offset: usize,
20560            depth: fidl::encoding::Depth,
20561        ) -> fidl::Result<()> {
20562            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
20563            // Zero out padding regions. There's no need to apply masks
20564            // because the unmasked parts will be overwritten by fields.
20565            // Write the fields.
20566            self.0.encode(encoder, offset + 0, depth)?;
20567            Ok(())
20568        }
20569    }
20570
20571    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20572        for AudioCapturerBindGainControlRequest
20573    {
20574        #[inline(always)]
20575        fn new_empty() -> Self {
20576            Self {
20577                gain_control_request: fidl::new_empty!(
20578                    fidl::encoding::Endpoint<
20579                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20580                    >,
20581                    fidl::encoding::DefaultFuchsiaResourceDialect
20582                ),
20583            }
20584        }
20585
20586        #[inline]
20587        unsafe fn decode(
20588            &mut self,
20589            decoder: &mut fidl::encoding::Decoder<
20590                '_,
20591                fidl::encoding::DefaultFuchsiaResourceDialect,
20592            >,
20593            offset: usize,
20594            _depth: fidl::encoding::Depth,
20595        ) -> fidl::Result<()> {
20596            decoder.debug_check_bounds::<Self>(offset);
20597            // Verify that padding bytes are zero.
20598            fidl::decode!(
20599                fidl::encoding::Endpoint<
20600                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
20601                >,
20602                fidl::encoding::DefaultFuchsiaResourceDialect,
20603                &mut self.gain_control_request,
20604                decoder,
20605                offset + 0,
20606                _depth
20607            )?;
20608            Ok(())
20609        }
20610    }
20611
20612    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
20613        type Borrowed<'a> = &'a mut Self;
20614        fn take_or_borrow<'a>(
20615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20616        ) -> Self::Borrowed<'a> {
20617            value
20618        }
20619    }
20620
20621    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
20622        type Owned = Self;
20623
20624        #[inline(always)]
20625        fn inline_align(_context: fidl::encoding::Context) -> usize {
20626            4
20627        }
20628
20629        #[inline(always)]
20630        fn inline_size(_context: fidl::encoding::Context) -> usize {
20631            4
20632        }
20633    }
20634
20635    unsafe impl
20636        fidl::encoding::Encode<
20637            AudioCapturerGetReferenceClockResponse,
20638            fidl::encoding::DefaultFuchsiaResourceDialect,
20639        > for &mut AudioCapturerGetReferenceClockResponse
20640    {
20641        #[inline]
20642        unsafe fn encode(
20643            self,
20644            encoder: &mut fidl::encoding::Encoder<
20645                '_,
20646                fidl::encoding::DefaultFuchsiaResourceDialect,
20647            >,
20648            offset: usize,
20649            _depth: fidl::encoding::Depth,
20650        ) -> fidl::Result<()> {
20651            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20652            // Delegate to tuple encoding.
20653            fidl::encoding::Encode::<
20654                AudioCapturerGetReferenceClockResponse,
20655                fidl::encoding::DefaultFuchsiaResourceDialect,
20656            >::encode(
20657                (<fidl::encoding::HandleType<
20658                    fidl::Clock,
20659                    { fidl::ObjectType::CLOCK.into_raw() },
20660                    2147483648,
20661                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20662                    &mut self.reference_clock,
20663                ),),
20664                encoder,
20665                offset,
20666                _depth,
20667            )
20668        }
20669    }
20670    unsafe impl<
20671        T0: fidl::encoding::Encode<
20672                fidl::encoding::HandleType<
20673                    fidl::Clock,
20674                    { fidl::ObjectType::CLOCK.into_raw() },
20675                    2147483648,
20676                >,
20677                fidl::encoding::DefaultFuchsiaResourceDialect,
20678            >,
20679    >
20680        fidl::encoding::Encode<
20681            AudioCapturerGetReferenceClockResponse,
20682            fidl::encoding::DefaultFuchsiaResourceDialect,
20683        > for (T0,)
20684    {
20685        #[inline]
20686        unsafe fn encode(
20687            self,
20688            encoder: &mut fidl::encoding::Encoder<
20689                '_,
20690                fidl::encoding::DefaultFuchsiaResourceDialect,
20691            >,
20692            offset: usize,
20693            depth: fidl::encoding::Depth,
20694        ) -> fidl::Result<()> {
20695            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
20696            // Zero out padding regions. There's no need to apply masks
20697            // because the unmasked parts will be overwritten by fields.
20698            // Write the fields.
20699            self.0.encode(encoder, offset + 0, depth)?;
20700            Ok(())
20701        }
20702    }
20703
20704    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20705        for AudioCapturerGetReferenceClockResponse
20706    {
20707        #[inline(always)]
20708        fn new_empty() -> Self {
20709            Self {
20710                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
20711            }
20712        }
20713
20714        #[inline]
20715        unsafe fn decode(
20716            &mut self,
20717            decoder: &mut fidl::encoding::Decoder<
20718                '_,
20719                fidl::encoding::DefaultFuchsiaResourceDialect,
20720            >,
20721            offset: usize,
20722            _depth: fidl::encoding::Depth,
20723        ) -> fidl::Result<()> {
20724            decoder.debug_check_bounds::<Self>(offset);
20725            // Verify that padding bytes are zero.
20726            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20727            Ok(())
20728        }
20729    }
20730
20731    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
20732        type Borrowed<'a> = &'a mut Self;
20733        fn take_or_borrow<'a>(
20734            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20735        ) -> Self::Borrowed<'a> {
20736            value
20737        }
20738    }
20739
20740    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
20741        type Owned = Self;
20742
20743        #[inline(always)]
20744        fn inline_align(_context: fidl::encoding::Context) -> usize {
20745            4
20746        }
20747
20748        #[inline(always)]
20749        fn inline_size(_context: fidl::encoding::Context) -> usize {
20750            4
20751        }
20752    }
20753
20754    unsafe impl
20755        fidl::encoding::Encode<
20756            AudioCapturerSetReferenceClockRequest,
20757            fidl::encoding::DefaultFuchsiaResourceDialect,
20758        > for &mut AudioCapturerSetReferenceClockRequest
20759    {
20760        #[inline]
20761        unsafe fn encode(
20762            self,
20763            encoder: &mut fidl::encoding::Encoder<
20764                '_,
20765                fidl::encoding::DefaultFuchsiaResourceDialect,
20766            >,
20767            offset: usize,
20768            _depth: fidl::encoding::Depth,
20769        ) -> fidl::Result<()> {
20770            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20771            // Delegate to tuple encoding.
20772            fidl::encoding::Encode::<
20773                AudioCapturerSetReferenceClockRequest,
20774                fidl::encoding::DefaultFuchsiaResourceDialect,
20775            >::encode(
20776                (<fidl::encoding::Optional<
20777                    fidl::encoding::HandleType<
20778                        fidl::Clock,
20779                        { fidl::ObjectType::CLOCK.into_raw() },
20780                        2147483648,
20781                    >,
20782                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20783                    &mut self.reference_clock,
20784                ),),
20785                encoder,
20786                offset,
20787                _depth,
20788            )
20789        }
20790    }
20791    unsafe impl<
20792        T0: fidl::encoding::Encode<
20793                fidl::encoding::Optional<
20794                    fidl::encoding::HandleType<
20795                        fidl::Clock,
20796                        { fidl::ObjectType::CLOCK.into_raw() },
20797                        2147483648,
20798                    >,
20799                >,
20800                fidl::encoding::DefaultFuchsiaResourceDialect,
20801            >,
20802    >
20803        fidl::encoding::Encode<
20804            AudioCapturerSetReferenceClockRequest,
20805            fidl::encoding::DefaultFuchsiaResourceDialect,
20806        > for (T0,)
20807    {
20808        #[inline]
20809        unsafe fn encode(
20810            self,
20811            encoder: &mut fidl::encoding::Encoder<
20812                '_,
20813                fidl::encoding::DefaultFuchsiaResourceDialect,
20814            >,
20815            offset: usize,
20816            depth: fidl::encoding::Depth,
20817        ) -> fidl::Result<()> {
20818            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
20819            // Zero out padding regions. There's no need to apply masks
20820            // because the unmasked parts will be overwritten by fields.
20821            // Write the fields.
20822            self.0.encode(encoder, offset + 0, depth)?;
20823            Ok(())
20824        }
20825    }
20826
20827    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20828        for AudioCapturerSetReferenceClockRequest
20829    {
20830        #[inline(always)]
20831        fn new_empty() -> Self {
20832            Self {
20833                reference_clock: fidl::new_empty!(
20834                    fidl::encoding::Optional<
20835                        fidl::encoding::HandleType<
20836                            fidl::Clock,
20837                            { fidl::ObjectType::CLOCK.into_raw() },
20838                            2147483648,
20839                        >,
20840                    >,
20841                    fidl::encoding::DefaultFuchsiaResourceDialect
20842                ),
20843            }
20844        }
20845
20846        #[inline]
20847        unsafe fn decode(
20848            &mut self,
20849            decoder: &mut fidl::encoding::Decoder<
20850                '_,
20851                fidl::encoding::DefaultFuchsiaResourceDialect,
20852            >,
20853            offset: usize,
20854            _depth: fidl::encoding::Depth,
20855        ) -> fidl::Result<()> {
20856            decoder.debug_check_bounds::<Self>(offset);
20857            // Verify that padding bytes are zero.
20858            fidl::decode!(
20859                fidl::encoding::Optional<
20860                    fidl::encoding::HandleType<
20861                        fidl::Clock,
20862                        { fidl::ObjectType::CLOCK.into_raw() },
20863                        2147483648,
20864                    >,
20865                >,
20866                fidl::encoding::DefaultFuchsiaResourceDialect,
20867                &mut self.reference_clock,
20868                decoder,
20869                offset + 0,
20870                _depth
20871            )?;
20872            Ok(())
20873        }
20874    }
20875
20876    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
20877        type Borrowed<'a> = &'a mut Self;
20878        fn take_or_borrow<'a>(
20879            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20880        ) -> Self::Borrowed<'a> {
20881            value
20882        }
20883    }
20884
20885    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
20886        type Owned = Self;
20887
20888        #[inline(always)]
20889        fn inline_align(_context: fidl::encoding::Context) -> usize {
20890            4
20891        }
20892
20893        #[inline(always)]
20894        fn inline_size(_context: fidl::encoding::Context) -> usize {
20895            4
20896        }
20897    }
20898
20899    unsafe impl
20900        fidl::encoding::Encode<
20901            AudioConsumerBindVolumeControlRequest,
20902            fidl::encoding::DefaultFuchsiaResourceDialect,
20903        > for &mut AudioConsumerBindVolumeControlRequest
20904    {
20905        #[inline]
20906        unsafe fn encode(
20907            self,
20908            encoder: &mut fidl::encoding::Encoder<
20909                '_,
20910                fidl::encoding::DefaultFuchsiaResourceDialect,
20911            >,
20912            offset: usize,
20913            _depth: fidl::encoding::Depth,
20914        ) -> fidl::Result<()> {
20915            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20916            // Delegate to tuple encoding.
20917            fidl::encoding::Encode::<
20918                AudioConsumerBindVolumeControlRequest,
20919                fidl::encoding::DefaultFuchsiaResourceDialect,
20920            >::encode(
20921                (<fidl::encoding::Endpoint<
20922                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20923                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20924                    &mut self.volume_control_request,
20925                ),),
20926                encoder,
20927                offset,
20928                _depth,
20929            )
20930        }
20931    }
20932    unsafe impl<
20933        T0: fidl::encoding::Encode<
20934                fidl::encoding::Endpoint<
20935                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20936                >,
20937                fidl::encoding::DefaultFuchsiaResourceDialect,
20938            >,
20939    >
20940        fidl::encoding::Encode<
20941            AudioConsumerBindVolumeControlRequest,
20942            fidl::encoding::DefaultFuchsiaResourceDialect,
20943        > for (T0,)
20944    {
20945        #[inline]
20946        unsafe fn encode(
20947            self,
20948            encoder: &mut fidl::encoding::Encoder<
20949                '_,
20950                fidl::encoding::DefaultFuchsiaResourceDialect,
20951            >,
20952            offset: usize,
20953            depth: fidl::encoding::Depth,
20954        ) -> fidl::Result<()> {
20955            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
20956            // Zero out padding regions. There's no need to apply masks
20957            // because the unmasked parts will be overwritten by fields.
20958            // Write the fields.
20959            self.0.encode(encoder, offset + 0, depth)?;
20960            Ok(())
20961        }
20962    }
20963
20964    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
20965        for AudioConsumerBindVolumeControlRequest
20966    {
20967        #[inline(always)]
20968        fn new_empty() -> Self {
20969            Self {
20970                volume_control_request: fidl::new_empty!(
20971                    fidl::encoding::Endpoint<
20972                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20973                    >,
20974                    fidl::encoding::DefaultFuchsiaResourceDialect
20975                ),
20976            }
20977        }
20978
20979        #[inline]
20980        unsafe fn decode(
20981            &mut self,
20982            decoder: &mut fidl::encoding::Decoder<
20983                '_,
20984                fidl::encoding::DefaultFuchsiaResourceDialect,
20985            >,
20986            offset: usize,
20987            _depth: fidl::encoding::Depth,
20988        ) -> fidl::Result<()> {
20989            decoder.debug_check_bounds::<Self>(offset);
20990            // Verify that padding bytes are zero.
20991            fidl::decode!(
20992                fidl::encoding::Endpoint<
20993                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
20994                >,
20995                fidl::encoding::DefaultFuchsiaResourceDialect,
20996                &mut self.volume_control_request,
20997                decoder,
20998                offset + 0,
20999                _depth
21000            )?;
21001            Ok(())
21002        }
21003    }
21004
21005    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
21006        type Borrowed<'a> = &'a mut Self;
21007        fn take_or_borrow<'a>(
21008            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21009        ) -> Self::Borrowed<'a> {
21010            value
21011        }
21012    }
21013
21014    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
21015        type Owned = Self;
21016
21017        #[inline(always)]
21018        fn inline_align(_context: fidl::encoding::Context) -> usize {
21019            8
21020        }
21021
21022        #[inline(always)]
21023        fn inline_size(_context: fidl::encoding::Context) -> usize {
21024            48
21025        }
21026    }
21027
21028    unsafe impl
21029        fidl::encoding::Encode<
21030            AudioConsumerCreateStreamSinkRequest,
21031            fidl::encoding::DefaultFuchsiaResourceDialect,
21032        > for &mut AudioConsumerCreateStreamSinkRequest
21033    {
21034        #[inline]
21035        unsafe fn encode(
21036            self,
21037            encoder: &mut fidl::encoding::Encoder<
21038                '_,
21039                fidl::encoding::DefaultFuchsiaResourceDialect,
21040            >,
21041            offset: usize,
21042            _depth: fidl::encoding::Depth,
21043        ) -> fidl::Result<()> {
21044            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21045            // Delegate to tuple encoding.
21046            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21047                (
21048                    <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),
21049                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21050                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
21051                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
21052                ),
21053                encoder, offset, _depth
21054            )
21055        }
21056    }
21057    unsafe impl<
21058        T0: fidl::encoding::Encode<
21059                fidl::encoding::Vector<
21060                    fidl::encoding::HandleType<
21061                        fidl::Vmo,
21062                        { fidl::ObjectType::VMO.into_raw() },
21063                        2147483648,
21064                    >,
21065                    16,
21066                >,
21067                fidl::encoding::DefaultFuchsiaResourceDialect,
21068            >,
21069        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21070        T2: fidl::encoding::Encode<
21071                fidl::encoding::Boxed<Compression>,
21072                fidl::encoding::DefaultFuchsiaResourceDialect,
21073            >,
21074        T3: fidl::encoding::Encode<
21075                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21076                fidl::encoding::DefaultFuchsiaResourceDialect,
21077            >,
21078    >
21079        fidl::encoding::Encode<
21080            AudioConsumerCreateStreamSinkRequest,
21081            fidl::encoding::DefaultFuchsiaResourceDialect,
21082        > for (T0, T1, T2, T3)
21083    {
21084        #[inline]
21085        unsafe fn encode(
21086            self,
21087            encoder: &mut fidl::encoding::Encoder<
21088                '_,
21089                fidl::encoding::DefaultFuchsiaResourceDialect,
21090            >,
21091            offset: usize,
21092            depth: fidl::encoding::Depth,
21093        ) -> fidl::Result<()> {
21094            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
21095            // Zero out padding regions. There's no need to apply masks
21096            // because the unmasked parts will be overwritten by fields.
21097            unsafe {
21098                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
21099                (ptr as *mut u64).write_unaligned(0);
21100            }
21101            unsafe {
21102                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
21103                (ptr as *mut u64).write_unaligned(0);
21104            }
21105            // Write the fields.
21106            self.0.encode(encoder, offset + 0, depth)?;
21107            self.1.encode(encoder, offset + 16, depth)?;
21108            self.2.encode(encoder, offset + 32, depth)?;
21109            self.3.encode(encoder, offset + 40, depth)?;
21110            Ok(())
21111        }
21112    }
21113
21114    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21115        for AudioConsumerCreateStreamSinkRequest
21116    {
21117        #[inline(always)]
21118        fn new_empty() -> Self {
21119            Self {
21120                buffers: fidl::new_empty!(
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                ),
21131                stream_type: fidl::new_empty!(
21132                    AudioStreamType,
21133                    fidl::encoding::DefaultFuchsiaResourceDialect
21134                ),
21135                compression: fidl::new_empty!(
21136                    fidl::encoding::Boxed<Compression>,
21137                    fidl::encoding::DefaultFuchsiaResourceDialect
21138                ),
21139                stream_sink_request: fidl::new_empty!(
21140                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21141                    fidl::encoding::DefaultFuchsiaResourceDialect
21142                ),
21143            }
21144        }
21145
21146        #[inline]
21147        unsafe fn decode(
21148            &mut self,
21149            decoder: &mut fidl::encoding::Decoder<
21150                '_,
21151                fidl::encoding::DefaultFuchsiaResourceDialect,
21152            >,
21153            offset: usize,
21154            _depth: fidl::encoding::Depth,
21155        ) -> fidl::Result<()> {
21156            decoder.debug_check_bounds::<Self>(offset);
21157            // Verify that padding bytes are zero.
21158            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
21159            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21160            let mask = 0xffffffff00000000u64;
21161            let maskedval = padval & mask;
21162            if maskedval != 0 {
21163                return Err(fidl::Error::NonZeroPadding {
21164                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
21165                });
21166            }
21167            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
21168            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21169            let mask = 0xffffffff00000000u64;
21170            let maskedval = padval & mask;
21171            if maskedval != 0 {
21172                return Err(fidl::Error::NonZeroPadding {
21173                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
21174                });
21175            }
21176            fidl::decode!(
21177                fidl::encoding::Vector<
21178                    fidl::encoding::HandleType<
21179                        fidl::Vmo,
21180                        { fidl::ObjectType::VMO.into_raw() },
21181                        2147483648,
21182                    >,
21183                    16,
21184                >,
21185                fidl::encoding::DefaultFuchsiaResourceDialect,
21186                &mut self.buffers,
21187                decoder,
21188                offset + 0,
21189                _depth
21190            )?;
21191            fidl::decode!(
21192                AudioStreamType,
21193                fidl::encoding::DefaultFuchsiaResourceDialect,
21194                &mut self.stream_type,
21195                decoder,
21196                offset + 16,
21197                _depth
21198            )?;
21199            fidl::decode!(
21200                fidl::encoding::Boxed<Compression>,
21201                fidl::encoding::DefaultFuchsiaResourceDialect,
21202                &mut self.compression,
21203                decoder,
21204                offset + 32,
21205                _depth
21206            )?;
21207            fidl::decode!(
21208                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
21209                fidl::encoding::DefaultFuchsiaResourceDialect,
21210                &mut self.stream_sink_request,
21211                decoder,
21212                offset + 40,
21213                _depth
21214            )?;
21215            Ok(())
21216        }
21217    }
21218
21219    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
21220        type Borrowed<'a> = &'a mut Self;
21221        fn take_or_borrow<'a>(
21222            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21223        ) -> Self::Borrowed<'a> {
21224            value
21225        }
21226    }
21227
21228    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
21229        type Owned = Self;
21230
21231        #[inline(always)]
21232        fn inline_align(_context: fidl::encoding::Context) -> usize {
21233            8
21234        }
21235
21236        #[inline(always)]
21237        fn inline_size(_context: fidl::encoding::Context) -> usize {
21238            24
21239        }
21240    }
21241
21242    unsafe impl
21243        fidl::encoding::Encode<
21244            AudioCoreBindUsageVolumeControl2Request,
21245            fidl::encoding::DefaultFuchsiaResourceDialect,
21246        > for &mut AudioCoreBindUsageVolumeControl2Request
21247    {
21248        #[inline]
21249        unsafe fn encode(
21250            self,
21251            encoder: &mut fidl::encoding::Encoder<
21252                '_,
21253                fidl::encoding::DefaultFuchsiaResourceDialect,
21254            >,
21255            offset: usize,
21256            _depth: fidl::encoding::Depth,
21257        ) -> fidl::Result<()> {
21258            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21259            // Delegate to tuple encoding.
21260            fidl::encoding::Encode::<
21261                AudioCoreBindUsageVolumeControl2Request,
21262                fidl::encoding::DefaultFuchsiaResourceDialect,
21263            >::encode(
21264                (
21265                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21266                    <fidl::encoding::Endpoint<
21267                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21268                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21269                        &mut self.volume_control,
21270                    ),
21271                ),
21272                encoder,
21273                offset,
21274                _depth,
21275            )
21276        }
21277    }
21278    unsafe impl<
21279        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
21280        T1: fidl::encoding::Encode<
21281                fidl::encoding::Endpoint<
21282                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21283                >,
21284                fidl::encoding::DefaultFuchsiaResourceDialect,
21285            >,
21286    >
21287        fidl::encoding::Encode<
21288            AudioCoreBindUsageVolumeControl2Request,
21289            fidl::encoding::DefaultFuchsiaResourceDialect,
21290        > for (T0, T1)
21291    {
21292        #[inline]
21293        unsafe fn encode(
21294            self,
21295            encoder: &mut fidl::encoding::Encoder<
21296                '_,
21297                fidl::encoding::DefaultFuchsiaResourceDialect,
21298            >,
21299            offset: usize,
21300            depth: fidl::encoding::Depth,
21301        ) -> fidl::Result<()> {
21302            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
21303            // Zero out padding regions. There's no need to apply masks
21304            // because the unmasked parts will be overwritten by fields.
21305            unsafe {
21306                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21307                (ptr as *mut u64).write_unaligned(0);
21308            }
21309            // Write the fields.
21310            self.0.encode(encoder, offset + 0, depth)?;
21311            self.1.encode(encoder, offset + 16, depth)?;
21312            Ok(())
21313        }
21314    }
21315
21316    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21317        for AudioCoreBindUsageVolumeControl2Request
21318    {
21319        #[inline(always)]
21320        fn new_empty() -> Self {
21321            Self {
21322                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
21323                volume_control: fidl::new_empty!(
21324                    fidl::encoding::Endpoint<
21325                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21326                    >,
21327                    fidl::encoding::DefaultFuchsiaResourceDialect
21328                ),
21329            }
21330        }
21331
21332        #[inline]
21333        unsafe fn decode(
21334            &mut self,
21335            decoder: &mut fidl::encoding::Decoder<
21336                '_,
21337                fidl::encoding::DefaultFuchsiaResourceDialect,
21338            >,
21339            offset: usize,
21340            _depth: fidl::encoding::Depth,
21341        ) -> fidl::Result<()> {
21342            decoder.debug_check_bounds::<Self>(offset);
21343            // Verify that padding bytes are zero.
21344            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21345            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21346            let mask = 0xffffffff00000000u64;
21347            let maskedval = padval & mask;
21348            if maskedval != 0 {
21349                return Err(fidl::Error::NonZeroPadding {
21350                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21351                });
21352            }
21353            fidl::decode!(
21354                Usage2,
21355                fidl::encoding::DefaultFuchsiaResourceDialect,
21356                &mut self.usage,
21357                decoder,
21358                offset + 0,
21359                _depth
21360            )?;
21361            fidl::decode!(
21362                fidl::encoding::Endpoint<
21363                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21364                >,
21365                fidl::encoding::DefaultFuchsiaResourceDialect,
21366                &mut self.volume_control,
21367                decoder,
21368                offset + 16,
21369                _depth
21370            )?;
21371            Ok(())
21372        }
21373    }
21374
21375    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
21376        type Borrowed<'a> = &'a mut Self;
21377        fn take_or_borrow<'a>(
21378            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21379        ) -> Self::Borrowed<'a> {
21380            value
21381        }
21382    }
21383
21384    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
21385        type Owned = Self;
21386
21387        #[inline(always)]
21388        fn inline_align(_context: fidl::encoding::Context) -> usize {
21389            8
21390        }
21391
21392        #[inline(always)]
21393        fn inline_size(_context: fidl::encoding::Context) -> usize {
21394            24
21395        }
21396    }
21397
21398    unsafe impl
21399        fidl::encoding::Encode<
21400            AudioCoreBindUsageVolumeControlRequest,
21401            fidl::encoding::DefaultFuchsiaResourceDialect,
21402        > for &mut AudioCoreBindUsageVolumeControlRequest
21403    {
21404        #[inline]
21405        unsafe fn encode(
21406            self,
21407            encoder: &mut fidl::encoding::Encoder<
21408                '_,
21409                fidl::encoding::DefaultFuchsiaResourceDialect,
21410            >,
21411            offset: usize,
21412            _depth: fidl::encoding::Depth,
21413        ) -> fidl::Result<()> {
21414            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21415            // Delegate to tuple encoding.
21416            fidl::encoding::Encode::<
21417                AudioCoreBindUsageVolumeControlRequest,
21418                fidl::encoding::DefaultFuchsiaResourceDialect,
21419            >::encode(
21420                (
21421                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21422                    <fidl::encoding::Endpoint<
21423                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21424                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21425                        &mut self.volume_control,
21426                    ),
21427                ),
21428                encoder,
21429                offset,
21430                _depth,
21431            )
21432        }
21433    }
21434    unsafe impl<
21435        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
21436        T1: fidl::encoding::Encode<
21437                fidl::encoding::Endpoint<
21438                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21439                >,
21440                fidl::encoding::DefaultFuchsiaResourceDialect,
21441            >,
21442    >
21443        fidl::encoding::Encode<
21444            AudioCoreBindUsageVolumeControlRequest,
21445            fidl::encoding::DefaultFuchsiaResourceDialect,
21446        > for (T0, T1)
21447    {
21448        #[inline]
21449        unsafe fn encode(
21450            self,
21451            encoder: &mut fidl::encoding::Encoder<
21452                '_,
21453                fidl::encoding::DefaultFuchsiaResourceDialect,
21454            >,
21455            offset: usize,
21456            depth: fidl::encoding::Depth,
21457        ) -> fidl::Result<()> {
21458            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
21459            // Zero out padding regions. There's no need to apply masks
21460            // because the unmasked parts will be overwritten by fields.
21461            unsafe {
21462                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
21463                (ptr as *mut u64).write_unaligned(0);
21464            }
21465            // Write the fields.
21466            self.0.encode(encoder, offset + 0, depth)?;
21467            self.1.encode(encoder, offset + 16, depth)?;
21468            Ok(())
21469        }
21470    }
21471
21472    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21473        for AudioCoreBindUsageVolumeControlRequest
21474    {
21475        #[inline(always)]
21476        fn new_empty() -> Self {
21477            Self {
21478                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
21479                volume_control: fidl::new_empty!(
21480                    fidl::encoding::Endpoint<
21481                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21482                    >,
21483                    fidl::encoding::DefaultFuchsiaResourceDialect
21484                ),
21485            }
21486        }
21487
21488        #[inline]
21489        unsafe fn decode(
21490            &mut self,
21491            decoder: &mut fidl::encoding::Decoder<
21492                '_,
21493                fidl::encoding::DefaultFuchsiaResourceDialect,
21494            >,
21495            offset: usize,
21496            _depth: fidl::encoding::Depth,
21497        ) -> fidl::Result<()> {
21498            decoder.debug_check_bounds::<Self>(offset);
21499            // Verify that padding bytes are zero.
21500            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
21501            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21502            let mask = 0xffffffff00000000u64;
21503            let maskedval = padval & mask;
21504            if maskedval != 0 {
21505                return Err(fidl::Error::NonZeroPadding {
21506                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
21507                });
21508            }
21509            fidl::decode!(
21510                Usage,
21511                fidl::encoding::DefaultFuchsiaResourceDialect,
21512                &mut self.usage,
21513                decoder,
21514                offset + 0,
21515                _depth
21516            )?;
21517            fidl::decode!(
21518                fidl::encoding::Endpoint<
21519                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
21520                >,
21521                fidl::encoding::DefaultFuchsiaResourceDialect,
21522                &mut self.volume_control,
21523                decoder,
21524                offset + 16,
21525                _depth
21526            )?;
21527            Ok(())
21528        }
21529    }
21530
21531    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
21532        type Borrowed<'a> = &'a mut Self;
21533        fn take_or_borrow<'a>(
21534            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21535        ) -> Self::Borrowed<'a> {
21536            value
21537        }
21538    }
21539
21540    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
21541        type Owned = Self;
21542
21543        #[inline(always)]
21544        fn inline_align(_context: fidl::encoding::Context) -> usize {
21545            4
21546        }
21547
21548        #[inline(always)]
21549        fn inline_size(_context: fidl::encoding::Context) -> usize {
21550            8
21551        }
21552    }
21553
21554    unsafe impl
21555        fidl::encoding::Encode<
21556            AudioCoreCreateAudioCapturerRequest,
21557            fidl::encoding::DefaultFuchsiaResourceDialect,
21558        > for &mut AudioCoreCreateAudioCapturerRequest
21559    {
21560        #[inline]
21561        unsafe fn encode(
21562            self,
21563            encoder: &mut fidl::encoding::Encoder<
21564                '_,
21565                fidl::encoding::DefaultFuchsiaResourceDialect,
21566            >,
21567            offset: usize,
21568            _depth: fidl::encoding::Depth,
21569        ) -> fidl::Result<()> {
21570            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21571            // Delegate to tuple encoding.
21572            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21573                (
21574                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
21575                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
21576                ),
21577                encoder, offset, _depth
21578            )
21579        }
21580    }
21581    unsafe impl<
21582        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
21583        T1: fidl::encoding::Encode<
21584                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21585                fidl::encoding::DefaultFuchsiaResourceDialect,
21586            >,
21587    >
21588        fidl::encoding::Encode<
21589            AudioCoreCreateAudioCapturerRequest,
21590            fidl::encoding::DefaultFuchsiaResourceDialect,
21591        > for (T0, T1)
21592    {
21593        #[inline]
21594        unsafe fn encode(
21595            self,
21596            encoder: &mut fidl::encoding::Encoder<
21597                '_,
21598                fidl::encoding::DefaultFuchsiaResourceDialect,
21599            >,
21600            offset: usize,
21601            depth: fidl::encoding::Depth,
21602        ) -> fidl::Result<()> {
21603            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
21604            // Zero out padding regions. There's no need to apply masks
21605            // because the unmasked parts will be overwritten by fields.
21606            unsafe {
21607                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
21608                (ptr as *mut u32).write_unaligned(0);
21609            }
21610            // Write the fields.
21611            self.0.encode(encoder, offset + 0, depth)?;
21612            self.1.encode(encoder, offset + 4, depth)?;
21613            Ok(())
21614        }
21615    }
21616
21617    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21618        for AudioCoreCreateAudioCapturerRequest
21619    {
21620        #[inline(always)]
21621        fn new_empty() -> Self {
21622            Self {
21623                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
21624                audio_in_request: fidl::new_empty!(
21625                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21626                    fidl::encoding::DefaultFuchsiaResourceDialect
21627                ),
21628            }
21629        }
21630
21631        #[inline]
21632        unsafe fn decode(
21633            &mut self,
21634            decoder: &mut fidl::encoding::Decoder<
21635                '_,
21636                fidl::encoding::DefaultFuchsiaResourceDialect,
21637            >,
21638            offset: usize,
21639            _depth: fidl::encoding::Depth,
21640        ) -> fidl::Result<()> {
21641            decoder.debug_check_bounds::<Self>(offset);
21642            // Verify that padding bytes are zero.
21643            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
21644            let padval = unsafe { (ptr as *const u32).read_unaligned() };
21645            let mask = 0xffffff00u32;
21646            let maskedval = padval & mask;
21647            if maskedval != 0 {
21648                return Err(fidl::Error::NonZeroPadding {
21649                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
21650                });
21651            }
21652            fidl::decode!(
21653                bool,
21654                fidl::encoding::DefaultFuchsiaResourceDialect,
21655                &mut self.loopback,
21656                decoder,
21657                offset + 0,
21658                _depth
21659            )?;
21660            fidl::decode!(
21661                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21662                fidl::encoding::DefaultFuchsiaResourceDialect,
21663                &mut self.audio_in_request,
21664                decoder,
21665                offset + 4,
21666                _depth
21667            )?;
21668            Ok(())
21669        }
21670    }
21671
21672    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21673        type Borrowed<'a> = &'a mut Self;
21674        fn take_or_borrow<'a>(
21675            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21676        ) -> Self::Borrowed<'a> {
21677            value
21678        }
21679    }
21680
21681    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
21682        type Owned = Self;
21683
21684        #[inline(always)]
21685        fn inline_align(_context: fidl::encoding::Context) -> usize {
21686            8
21687        }
21688
21689        #[inline(always)]
21690        fn inline_size(_context: fidl::encoding::Context) -> usize {
21691            40
21692        }
21693    }
21694
21695    unsafe impl
21696        fidl::encoding::Encode<
21697            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21698            fidl::encoding::DefaultFuchsiaResourceDialect,
21699        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
21700    {
21701        #[inline]
21702        unsafe fn encode(
21703            self,
21704            encoder: &mut fidl::encoding::Encoder<
21705                '_,
21706                fidl::encoding::DefaultFuchsiaResourceDialect,
21707            >,
21708            offset: usize,
21709            _depth: fidl::encoding::Depth,
21710        ) -> fidl::Result<()> {
21711            encoder
21712                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21713            // Delegate to tuple encoding.
21714            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21715                (
21716                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
21717                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
21718                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
21719                ),
21720                encoder, offset, _depth
21721            )
21722        }
21723    }
21724    unsafe impl<
21725        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
21726        T1: fidl::encoding::Encode<
21727                AudioCapturerConfiguration,
21728                fidl::encoding::DefaultFuchsiaResourceDialect,
21729            >,
21730        T2: fidl::encoding::Encode<
21731                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21732                fidl::encoding::DefaultFuchsiaResourceDialect,
21733            >,
21734    >
21735        fidl::encoding::Encode<
21736            AudioCoreCreateAudioCapturerWithConfigurationRequest,
21737            fidl::encoding::DefaultFuchsiaResourceDialect,
21738        > for (T0, T1, T2)
21739    {
21740        #[inline]
21741        unsafe fn encode(
21742            self,
21743            encoder: &mut fidl::encoding::Encoder<
21744                '_,
21745                fidl::encoding::DefaultFuchsiaResourceDialect,
21746            >,
21747            offset: usize,
21748            depth: fidl::encoding::Depth,
21749        ) -> fidl::Result<()> {
21750            encoder
21751                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
21752            // Zero out padding regions. There's no need to apply masks
21753            // because the unmasked parts will be overwritten by fields.
21754            unsafe {
21755                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
21756                (ptr as *mut u64).write_unaligned(0);
21757            }
21758            unsafe {
21759                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21760                (ptr as *mut u64).write_unaligned(0);
21761            }
21762            // Write the fields.
21763            self.0.encode(encoder, offset + 0, depth)?;
21764            self.1.encode(encoder, offset + 16, depth)?;
21765            self.2.encode(encoder, offset + 32, depth)?;
21766            Ok(())
21767        }
21768    }
21769
21770    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21771        for AudioCoreCreateAudioCapturerWithConfigurationRequest
21772    {
21773        #[inline(always)]
21774        fn new_empty() -> Self {
21775            Self {
21776                stream_type: fidl::new_empty!(
21777                    AudioStreamType,
21778                    fidl::encoding::DefaultFuchsiaResourceDialect
21779                ),
21780                configuration: fidl::new_empty!(
21781                    AudioCapturerConfiguration,
21782                    fidl::encoding::DefaultFuchsiaResourceDialect
21783                ),
21784                audio_capturer_request: fidl::new_empty!(
21785                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21786                    fidl::encoding::DefaultFuchsiaResourceDialect
21787                ),
21788            }
21789        }
21790
21791        #[inline]
21792        unsafe fn decode(
21793            &mut self,
21794            decoder: &mut fidl::encoding::Decoder<
21795                '_,
21796                fidl::encoding::DefaultFuchsiaResourceDialect,
21797            >,
21798            offset: usize,
21799            _depth: fidl::encoding::Depth,
21800        ) -> fidl::Result<()> {
21801            decoder.debug_check_bounds::<Self>(offset);
21802            // Verify that padding bytes are zero.
21803            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21804            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21805            let mask = 0xffffffff00000000u64;
21806            let maskedval = padval & mask;
21807            if maskedval != 0 {
21808                return Err(fidl::Error::NonZeroPadding {
21809                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21810                });
21811            }
21812            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21813            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21814            let mask = 0xffffffff00000000u64;
21815            let maskedval = padval & mask;
21816            if maskedval != 0 {
21817                return Err(fidl::Error::NonZeroPadding {
21818                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21819                });
21820            }
21821            fidl::decode!(
21822                AudioStreamType,
21823                fidl::encoding::DefaultFuchsiaResourceDialect,
21824                &mut self.stream_type,
21825                decoder,
21826                offset + 0,
21827                _depth
21828            )?;
21829            fidl::decode!(
21830                AudioCapturerConfiguration,
21831                fidl::encoding::DefaultFuchsiaResourceDialect,
21832                &mut self.configuration,
21833                decoder,
21834                offset + 16,
21835                _depth
21836            )?;
21837            fidl::decode!(
21838                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
21839                fidl::encoding::DefaultFuchsiaResourceDialect,
21840                &mut self.audio_capturer_request,
21841                decoder,
21842                offset + 32,
21843                _depth
21844            )?;
21845            Ok(())
21846        }
21847    }
21848
21849    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
21850        type Borrowed<'a> = &'a mut Self;
21851        fn take_or_borrow<'a>(
21852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21853        ) -> Self::Borrowed<'a> {
21854            value
21855        }
21856    }
21857
21858    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
21859        type Owned = Self;
21860
21861        #[inline(always)]
21862        fn inline_align(_context: fidl::encoding::Context) -> usize {
21863            4
21864        }
21865
21866        #[inline(always)]
21867        fn inline_size(_context: fidl::encoding::Context) -> usize {
21868            4
21869        }
21870    }
21871
21872    unsafe impl
21873        fidl::encoding::Encode<
21874            AudioCoreCreateAudioRendererRequest,
21875            fidl::encoding::DefaultFuchsiaResourceDialect,
21876        > for &mut AudioCoreCreateAudioRendererRequest
21877    {
21878        #[inline]
21879        unsafe fn encode(
21880            self,
21881            encoder: &mut fidl::encoding::Encoder<
21882                '_,
21883                fidl::encoding::DefaultFuchsiaResourceDialect,
21884            >,
21885            offset: usize,
21886            _depth: fidl::encoding::Depth,
21887        ) -> fidl::Result<()> {
21888            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21889            // Delegate to tuple encoding.
21890            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
21891                (
21892                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
21893                ),
21894                encoder, offset, _depth
21895            )
21896        }
21897    }
21898    unsafe impl<
21899        T0: fidl::encoding::Encode<
21900                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21901                fidl::encoding::DefaultFuchsiaResourceDialect,
21902            >,
21903    >
21904        fidl::encoding::Encode<
21905            AudioCoreCreateAudioRendererRequest,
21906            fidl::encoding::DefaultFuchsiaResourceDialect,
21907        > for (T0,)
21908    {
21909        #[inline]
21910        unsafe fn encode(
21911            self,
21912            encoder: &mut fidl::encoding::Encoder<
21913                '_,
21914                fidl::encoding::DefaultFuchsiaResourceDialect,
21915            >,
21916            offset: usize,
21917            depth: fidl::encoding::Depth,
21918        ) -> fidl::Result<()> {
21919            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
21920            // Zero out padding regions. There's no need to apply masks
21921            // because the unmasked parts will be overwritten by fields.
21922            // Write the fields.
21923            self.0.encode(encoder, offset + 0, depth)?;
21924            Ok(())
21925        }
21926    }
21927
21928    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
21929        for AudioCoreCreateAudioRendererRequest
21930    {
21931        #[inline(always)]
21932        fn new_empty() -> Self {
21933            Self {
21934                audio_out_request: fidl::new_empty!(
21935                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21936                    fidl::encoding::DefaultFuchsiaResourceDialect
21937                ),
21938            }
21939        }
21940
21941        #[inline]
21942        unsafe fn decode(
21943            &mut self,
21944            decoder: &mut fidl::encoding::Decoder<
21945                '_,
21946                fidl::encoding::DefaultFuchsiaResourceDialect,
21947            >,
21948            offset: usize,
21949            _depth: fidl::encoding::Depth,
21950        ) -> fidl::Result<()> {
21951            decoder.debug_check_bounds::<Self>(offset);
21952            // Verify that padding bytes are zero.
21953            fidl::decode!(
21954                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
21955                fidl::encoding::DefaultFuchsiaResourceDialect,
21956                &mut self.audio_out_request,
21957                decoder,
21958                offset + 0,
21959                _depth
21960            )?;
21961            Ok(())
21962        }
21963    }
21964
21965    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
21966        type Borrowed<'a> = &'a mut Self;
21967        fn take_or_borrow<'a>(
21968            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21969        ) -> Self::Borrowed<'a> {
21970            value
21971        }
21972    }
21973
21974    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
21975        type Owned = Self;
21976
21977        #[inline(always)]
21978        fn inline_align(_context: fidl::encoding::Context) -> usize {
21979            4
21980        }
21981
21982        #[inline(always)]
21983        fn inline_size(_context: fidl::encoding::Context) -> usize {
21984            8
21985        }
21986    }
21987
21988    unsafe impl
21989        fidl::encoding::Encode<
21990            AudioCreateAudioCapturerRequest,
21991            fidl::encoding::DefaultFuchsiaResourceDialect,
21992        > for &mut AudioCreateAudioCapturerRequest
21993    {
21994        #[inline]
21995        unsafe fn encode(
21996            self,
21997            encoder: &mut fidl::encoding::Encoder<
21998                '_,
21999                fidl::encoding::DefaultFuchsiaResourceDialect,
22000            >,
22001            offset: usize,
22002            _depth: fidl::encoding::Depth,
22003        ) -> fidl::Result<()> {
22004            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22005            // Delegate to tuple encoding.
22006            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22007                (
22008                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
22009                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
22010                ),
22011                encoder, offset, _depth
22012            )
22013        }
22014    }
22015    unsafe impl<
22016        T0: fidl::encoding::Encode<
22017                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22018                fidl::encoding::DefaultFuchsiaResourceDialect,
22019            >,
22020        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22021    >
22022        fidl::encoding::Encode<
22023            AudioCreateAudioCapturerRequest,
22024            fidl::encoding::DefaultFuchsiaResourceDialect,
22025        > for (T0, T1)
22026    {
22027        #[inline]
22028        unsafe fn encode(
22029            self,
22030            encoder: &mut fidl::encoding::Encoder<
22031                '_,
22032                fidl::encoding::DefaultFuchsiaResourceDialect,
22033            >,
22034            offset: usize,
22035            depth: fidl::encoding::Depth,
22036        ) -> fidl::Result<()> {
22037            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
22038            // Zero out padding regions. There's no need to apply masks
22039            // because the unmasked parts will be overwritten by fields.
22040            unsafe {
22041                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
22042                (ptr as *mut u32).write_unaligned(0);
22043            }
22044            // Write the fields.
22045            self.0.encode(encoder, offset + 0, depth)?;
22046            self.1.encode(encoder, offset + 4, depth)?;
22047            Ok(())
22048        }
22049    }
22050
22051    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22052        for AudioCreateAudioCapturerRequest
22053    {
22054        #[inline(always)]
22055        fn new_empty() -> Self {
22056            Self {
22057                audio_capturer_request: fidl::new_empty!(
22058                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22059                    fidl::encoding::DefaultFuchsiaResourceDialect
22060                ),
22061                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22062            }
22063        }
22064
22065        #[inline]
22066        unsafe fn decode(
22067            &mut self,
22068            decoder: &mut fidl::encoding::Decoder<
22069                '_,
22070                fidl::encoding::DefaultFuchsiaResourceDialect,
22071            >,
22072            offset: usize,
22073            _depth: fidl::encoding::Depth,
22074        ) -> fidl::Result<()> {
22075            decoder.debug_check_bounds::<Self>(offset);
22076            // Verify that padding bytes are zero.
22077            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
22078            let padval = unsafe { (ptr as *const u32).read_unaligned() };
22079            let mask = 0xffffff00u32;
22080            let maskedval = padval & mask;
22081            if maskedval != 0 {
22082                return Err(fidl::Error::NonZeroPadding {
22083                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
22084                });
22085            }
22086            fidl::decode!(
22087                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
22088                fidl::encoding::DefaultFuchsiaResourceDialect,
22089                &mut self.audio_capturer_request,
22090                decoder,
22091                offset + 0,
22092                _depth
22093            )?;
22094            fidl::decode!(
22095                bool,
22096                fidl::encoding::DefaultFuchsiaResourceDialect,
22097                &mut self.loopback,
22098                decoder,
22099                offset + 4,
22100                _depth
22101            )?;
22102            Ok(())
22103        }
22104    }
22105
22106    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
22107        type Borrowed<'a> = &'a mut Self;
22108        fn take_or_borrow<'a>(
22109            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22110        ) -> Self::Borrowed<'a> {
22111            value
22112        }
22113    }
22114
22115    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
22116        type Owned = Self;
22117
22118        #[inline(always)]
22119        fn inline_align(_context: fidl::encoding::Context) -> usize {
22120            4
22121        }
22122
22123        #[inline(always)]
22124        fn inline_size(_context: fidl::encoding::Context) -> usize {
22125            4
22126        }
22127    }
22128
22129    unsafe impl
22130        fidl::encoding::Encode<
22131            AudioCreateAudioRendererRequest,
22132            fidl::encoding::DefaultFuchsiaResourceDialect,
22133        > for &mut AudioCreateAudioRendererRequest
22134    {
22135        #[inline]
22136        unsafe fn encode(
22137            self,
22138            encoder: &mut fidl::encoding::Encoder<
22139                '_,
22140                fidl::encoding::DefaultFuchsiaResourceDialect,
22141            >,
22142            offset: usize,
22143            _depth: fidl::encoding::Depth,
22144        ) -> fidl::Result<()> {
22145            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22146            // Delegate to tuple encoding.
22147            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
22148                (
22149                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
22150                ),
22151                encoder, offset, _depth
22152            )
22153        }
22154    }
22155    unsafe impl<
22156        T0: fidl::encoding::Encode<
22157                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22158                fidl::encoding::DefaultFuchsiaResourceDialect,
22159            >,
22160    >
22161        fidl::encoding::Encode<
22162            AudioCreateAudioRendererRequest,
22163            fidl::encoding::DefaultFuchsiaResourceDialect,
22164        > for (T0,)
22165    {
22166        #[inline]
22167        unsafe fn encode(
22168            self,
22169            encoder: &mut fidl::encoding::Encoder<
22170                '_,
22171                fidl::encoding::DefaultFuchsiaResourceDialect,
22172            >,
22173            offset: usize,
22174            depth: fidl::encoding::Depth,
22175        ) -> fidl::Result<()> {
22176            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
22177            // Zero out padding regions. There's no need to apply masks
22178            // because the unmasked parts will be overwritten by fields.
22179            // Write the fields.
22180            self.0.encode(encoder, offset + 0, depth)?;
22181            Ok(())
22182        }
22183    }
22184
22185    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22186        for AudioCreateAudioRendererRequest
22187    {
22188        #[inline(always)]
22189        fn new_empty() -> Self {
22190            Self {
22191                audio_renderer_request: fidl::new_empty!(
22192                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22193                    fidl::encoding::DefaultFuchsiaResourceDialect
22194                ),
22195            }
22196        }
22197
22198        #[inline]
22199        unsafe fn decode(
22200            &mut self,
22201            decoder: &mut fidl::encoding::Decoder<
22202                '_,
22203                fidl::encoding::DefaultFuchsiaResourceDialect,
22204            >,
22205            offset: usize,
22206            _depth: fidl::encoding::Depth,
22207        ) -> fidl::Result<()> {
22208            decoder.debug_check_bounds::<Self>(offset);
22209            // Verify that padding bytes are zero.
22210            fidl::decode!(
22211                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
22212                fidl::encoding::DefaultFuchsiaResourceDialect,
22213                &mut self.audio_renderer_request,
22214                decoder,
22215                offset + 0,
22216                _depth
22217            )?;
22218            Ok(())
22219        }
22220    }
22221
22222    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22223        type Borrowed<'a> = &'a mut Self;
22224        fn take_or_borrow<'a>(
22225            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22226        ) -> Self::Borrowed<'a> {
22227            value
22228        }
22229    }
22230
22231    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
22232        type Owned = Self;
22233
22234        #[inline(always)]
22235        fn inline_align(_context: fidl::encoding::Context) -> usize {
22236            8
22237        }
22238
22239        #[inline(always)]
22240        fn inline_size(_context: fidl::encoding::Context) -> usize {
22241            24
22242        }
22243    }
22244
22245    unsafe impl
22246        fidl::encoding::Encode<
22247            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22248            fidl::encoding::DefaultFuchsiaResourceDialect,
22249        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
22250    {
22251        #[inline]
22252        unsafe fn encode(
22253            self,
22254            encoder: &mut fidl::encoding::Encoder<
22255                '_,
22256                fidl::encoding::DefaultFuchsiaResourceDialect,
22257            >,
22258            offset: usize,
22259            _depth: fidl::encoding::Depth,
22260        ) -> fidl::Result<()> {
22261            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22262            // Delegate to tuple encoding.
22263            fidl::encoding::Encode::<
22264                AudioDeviceEnumeratorAddDeviceByChannelRequest,
22265                fidl::encoding::DefaultFuchsiaResourceDialect,
22266            >::encode(
22267                (
22268                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
22269                        &self.device_name,
22270                    ),
22271                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
22272                    <fidl::encoding::Endpoint<
22273                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22274                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22275                        &mut self.channel
22276                    ),
22277                ),
22278                encoder,
22279                offset,
22280                _depth,
22281            )
22282        }
22283    }
22284    unsafe impl<
22285        T0: fidl::encoding::Encode<
22286                fidl::encoding::BoundedString<256>,
22287                fidl::encoding::DefaultFuchsiaResourceDialect,
22288            >,
22289        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
22290        T2: fidl::encoding::Encode<
22291                fidl::encoding::Endpoint<
22292                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22293                >,
22294                fidl::encoding::DefaultFuchsiaResourceDialect,
22295            >,
22296    >
22297        fidl::encoding::Encode<
22298            AudioDeviceEnumeratorAddDeviceByChannelRequest,
22299            fidl::encoding::DefaultFuchsiaResourceDialect,
22300        > for (T0, T1, T2)
22301    {
22302        #[inline]
22303        unsafe fn encode(
22304            self,
22305            encoder: &mut fidl::encoding::Encoder<
22306                '_,
22307                fidl::encoding::DefaultFuchsiaResourceDialect,
22308            >,
22309            offset: usize,
22310            depth: fidl::encoding::Depth,
22311        ) -> fidl::Result<()> {
22312            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
22313            // Zero out padding regions. There's no need to apply masks
22314            // because the unmasked parts will be overwritten by fields.
22315            unsafe {
22316                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22317                (ptr as *mut u64).write_unaligned(0);
22318            }
22319            // Write the fields.
22320            self.0.encode(encoder, offset + 0, depth)?;
22321            self.1.encode(encoder, offset + 16, depth)?;
22322            self.2.encode(encoder, offset + 20, depth)?;
22323            Ok(())
22324        }
22325    }
22326
22327    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22328        for AudioDeviceEnumeratorAddDeviceByChannelRequest
22329    {
22330        #[inline(always)]
22331        fn new_empty() -> Self {
22332            Self {
22333                device_name: fidl::new_empty!(
22334                    fidl::encoding::BoundedString<256>,
22335                    fidl::encoding::DefaultFuchsiaResourceDialect
22336                ),
22337                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
22338                channel: fidl::new_empty!(
22339                    fidl::encoding::Endpoint<
22340                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22341                    >,
22342                    fidl::encoding::DefaultFuchsiaResourceDialect
22343                ),
22344            }
22345        }
22346
22347        #[inline]
22348        unsafe fn decode(
22349            &mut self,
22350            decoder: &mut fidl::encoding::Decoder<
22351                '_,
22352                fidl::encoding::DefaultFuchsiaResourceDialect,
22353            >,
22354            offset: usize,
22355            _depth: fidl::encoding::Depth,
22356        ) -> fidl::Result<()> {
22357            decoder.debug_check_bounds::<Self>(offset);
22358            // Verify that padding bytes are zero.
22359            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22360            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22361            let mask = 0xffffff00u64;
22362            let maskedval = padval & mask;
22363            if maskedval != 0 {
22364                return Err(fidl::Error::NonZeroPadding {
22365                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22366                });
22367            }
22368            fidl::decode!(
22369                fidl::encoding::BoundedString<256>,
22370                fidl::encoding::DefaultFuchsiaResourceDialect,
22371                &mut self.device_name,
22372                decoder,
22373                offset + 0,
22374                _depth
22375            )?;
22376            fidl::decode!(
22377                bool,
22378                fidl::encoding::DefaultFuchsiaResourceDialect,
22379                &mut self.is_input,
22380                decoder,
22381                offset + 16,
22382                _depth
22383            )?;
22384            fidl::decode!(
22385                fidl::encoding::Endpoint<
22386                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
22387                >,
22388                fidl::encoding::DefaultFuchsiaResourceDialect,
22389                &mut self.channel,
22390                decoder,
22391                offset + 20,
22392                _depth
22393            )?;
22394            Ok(())
22395        }
22396    }
22397
22398    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
22399        type Borrowed<'a> = &'a mut Self;
22400        fn take_or_borrow<'a>(
22401            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22402        ) -> Self::Borrowed<'a> {
22403            value
22404        }
22405    }
22406
22407    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
22408        type Owned = Self;
22409
22410        #[inline(always)]
22411        fn inline_align(_context: fidl::encoding::Context) -> usize {
22412            4
22413        }
22414
22415        #[inline(always)]
22416        fn inline_size(_context: fidl::encoding::Context) -> usize {
22417            4
22418        }
22419    }
22420
22421    unsafe impl
22422        fidl::encoding::Encode<
22423            AudioRendererBindGainControlRequest,
22424            fidl::encoding::DefaultFuchsiaResourceDialect,
22425        > for &mut AudioRendererBindGainControlRequest
22426    {
22427        #[inline]
22428        unsafe fn encode(
22429            self,
22430            encoder: &mut fidl::encoding::Encoder<
22431                '_,
22432                fidl::encoding::DefaultFuchsiaResourceDialect,
22433            >,
22434            offset: usize,
22435            _depth: fidl::encoding::Depth,
22436        ) -> fidl::Result<()> {
22437            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22438            // Delegate to tuple encoding.
22439            fidl::encoding::Encode::<
22440                AudioRendererBindGainControlRequest,
22441                fidl::encoding::DefaultFuchsiaResourceDialect,
22442            >::encode(
22443                (<fidl::encoding::Endpoint<
22444                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22445                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22446                    &mut self.gain_control_request,
22447                ),),
22448                encoder,
22449                offset,
22450                _depth,
22451            )
22452        }
22453    }
22454    unsafe impl<
22455        T0: fidl::encoding::Encode<
22456                fidl::encoding::Endpoint<
22457                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22458                >,
22459                fidl::encoding::DefaultFuchsiaResourceDialect,
22460            >,
22461    >
22462        fidl::encoding::Encode<
22463            AudioRendererBindGainControlRequest,
22464            fidl::encoding::DefaultFuchsiaResourceDialect,
22465        > for (T0,)
22466    {
22467        #[inline]
22468        unsafe fn encode(
22469            self,
22470            encoder: &mut fidl::encoding::Encoder<
22471                '_,
22472                fidl::encoding::DefaultFuchsiaResourceDialect,
22473            >,
22474            offset: usize,
22475            depth: fidl::encoding::Depth,
22476        ) -> fidl::Result<()> {
22477            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
22478            // Zero out padding regions. There's no need to apply masks
22479            // because the unmasked parts will be overwritten by fields.
22480            // Write the fields.
22481            self.0.encode(encoder, offset + 0, depth)?;
22482            Ok(())
22483        }
22484    }
22485
22486    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22487        for AudioRendererBindGainControlRequest
22488    {
22489        #[inline(always)]
22490        fn new_empty() -> Self {
22491            Self {
22492                gain_control_request: fidl::new_empty!(
22493                    fidl::encoding::Endpoint<
22494                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22495                    >,
22496                    fidl::encoding::DefaultFuchsiaResourceDialect
22497                ),
22498            }
22499        }
22500
22501        #[inline]
22502        unsafe fn decode(
22503            &mut self,
22504            decoder: &mut fidl::encoding::Decoder<
22505                '_,
22506                fidl::encoding::DefaultFuchsiaResourceDialect,
22507            >,
22508            offset: usize,
22509            _depth: fidl::encoding::Depth,
22510        ) -> fidl::Result<()> {
22511            decoder.debug_check_bounds::<Self>(offset);
22512            // Verify that padding bytes are zero.
22513            fidl::decode!(
22514                fidl::encoding::Endpoint<
22515                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22516                >,
22517                fidl::encoding::DefaultFuchsiaResourceDialect,
22518                &mut self.gain_control_request,
22519                decoder,
22520                offset + 0,
22521                _depth
22522            )?;
22523            Ok(())
22524        }
22525    }
22526
22527    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
22528        type Borrowed<'a> = &'a mut Self;
22529        fn take_or_borrow<'a>(
22530            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22531        ) -> Self::Borrowed<'a> {
22532            value
22533        }
22534    }
22535
22536    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
22537        type Owned = Self;
22538
22539        #[inline(always)]
22540        fn inline_align(_context: fidl::encoding::Context) -> usize {
22541            4
22542        }
22543
22544        #[inline(always)]
22545        fn inline_size(_context: fidl::encoding::Context) -> usize {
22546            4
22547        }
22548    }
22549
22550    unsafe impl
22551        fidl::encoding::Encode<
22552            AudioRendererGetReferenceClockResponse,
22553            fidl::encoding::DefaultFuchsiaResourceDialect,
22554        > for &mut AudioRendererGetReferenceClockResponse
22555    {
22556        #[inline]
22557        unsafe fn encode(
22558            self,
22559            encoder: &mut fidl::encoding::Encoder<
22560                '_,
22561                fidl::encoding::DefaultFuchsiaResourceDialect,
22562            >,
22563            offset: usize,
22564            _depth: fidl::encoding::Depth,
22565        ) -> fidl::Result<()> {
22566            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22567            // Delegate to tuple encoding.
22568            fidl::encoding::Encode::<
22569                AudioRendererGetReferenceClockResponse,
22570                fidl::encoding::DefaultFuchsiaResourceDialect,
22571            >::encode(
22572                (<fidl::encoding::HandleType<
22573                    fidl::Clock,
22574                    { fidl::ObjectType::CLOCK.into_raw() },
22575                    2147483648,
22576                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22577                    &mut self.reference_clock,
22578                ),),
22579                encoder,
22580                offset,
22581                _depth,
22582            )
22583        }
22584    }
22585    unsafe impl<
22586        T0: fidl::encoding::Encode<
22587                fidl::encoding::HandleType<
22588                    fidl::Clock,
22589                    { fidl::ObjectType::CLOCK.into_raw() },
22590                    2147483648,
22591                >,
22592                fidl::encoding::DefaultFuchsiaResourceDialect,
22593            >,
22594    >
22595        fidl::encoding::Encode<
22596            AudioRendererGetReferenceClockResponse,
22597            fidl::encoding::DefaultFuchsiaResourceDialect,
22598        > for (T0,)
22599    {
22600        #[inline]
22601        unsafe fn encode(
22602            self,
22603            encoder: &mut fidl::encoding::Encoder<
22604                '_,
22605                fidl::encoding::DefaultFuchsiaResourceDialect,
22606            >,
22607            offset: usize,
22608            depth: fidl::encoding::Depth,
22609        ) -> fidl::Result<()> {
22610            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
22611            // Zero out padding regions. There's no need to apply masks
22612            // because the unmasked parts will be overwritten by fields.
22613            // Write the fields.
22614            self.0.encode(encoder, offset + 0, depth)?;
22615            Ok(())
22616        }
22617    }
22618
22619    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22620        for AudioRendererGetReferenceClockResponse
22621    {
22622        #[inline(always)]
22623        fn new_empty() -> Self {
22624            Self {
22625                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22626            }
22627        }
22628
22629        #[inline]
22630        unsafe fn decode(
22631            &mut self,
22632            decoder: &mut fidl::encoding::Decoder<
22633                '_,
22634                fidl::encoding::DefaultFuchsiaResourceDialect,
22635            >,
22636            offset: usize,
22637            _depth: fidl::encoding::Depth,
22638        ) -> fidl::Result<()> {
22639            decoder.debug_check_bounds::<Self>(offset);
22640            // Verify that padding bytes are zero.
22641            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22642            Ok(())
22643        }
22644    }
22645
22646    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
22647        type Borrowed<'a> = &'a mut Self;
22648        fn take_or_borrow<'a>(
22649            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22650        ) -> Self::Borrowed<'a> {
22651            value
22652        }
22653    }
22654
22655    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
22656        type Owned = Self;
22657
22658        #[inline(always)]
22659        fn inline_align(_context: fidl::encoding::Context) -> usize {
22660            4
22661        }
22662
22663        #[inline(always)]
22664        fn inline_size(_context: fidl::encoding::Context) -> usize {
22665            4
22666        }
22667    }
22668
22669    unsafe impl
22670        fidl::encoding::Encode<
22671            AudioRendererSetReferenceClockRequest,
22672            fidl::encoding::DefaultFuchsiaResourceDialect,
22673        > for &mut AudioRendererSetReferenceClockRequest
22674    {
22675        #[inline]
22676        unsafe fn encode(
22677            self,
22678            encoder: &mut fidl::encoding::Encoder<
22679                '_,
22680                fidl::encoding::DefaultFuchsiaResourceDialect,
22681            >,
22682            offset: usize,
22683            _depth: fidl::encoding::Depth,
22684        ) -> fidl::Result<()> {
22685            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22686            // Delegate to tuple encoding.
22687            fidl::encoding::Encode::<
22688                AudioRendererSetReferenceClockRequest,
22689                fidl::encoding::DefaultFuchsiaResourceDialect,
22690            >::encode(
22691                (<fidl::encoding::Optional<
22692                    fidl::encoding::HandleType<
22693                        fidl::Clock,
22694                        { fidl::ObjectType::CLOCK.into_raw() },
22695                        2147483648,
22696                    >,
22697                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22698                    &mut self.reference_clock,
22699                ),),
22700                encoder,
22701                offset,
22702                _depth,
22703            )
22704        }
22705    }
22706    unsafe impl<
22707        T0: fidl::encoding::Encode<
22708                fidl::encoding::Optional<
22709                    fidl::encoding::HandleType<
22710                        fidl::Clock,
22711                        { fidl::ObjectType::CLOCK.into_raw() },
22712                        2147483648,
22713                    >,
22714                >,
22715                fidl::encoding::DefaultFuchsiaResourceDialect,
22716            >,
22717    >
22718        fidl::encoding::Encode<
22719            AudioRendererSetReferenceClockRequest,
22720            fidl::encoding::DefaultFuchsiaResourceDialect,
22721        > for (T0,)
22722    {
22723        #[inline]
22724        unsafe fn encode(
22725            self,
22726            encoder: &mut fidl::encoding::Encoder<
22727                '_,
22728                fidl::encoding::DefaultFuchsiaResourceDialect,
22729            >,
22730            offset: usize,
22731            depth: fidl::encoding::Depth,
22732        ) -> fidl::Result<()> {
22733            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
22734            // Zero out padding regions. There's no need to apply masks
22735            // because the unmasked parts will be overwritten by fields.
22736            // Write the fields.
22737            self.0.encode(encoder, offset + 0, depth)?;
22738            Ok(())
22739        }
22740    }
22741
22742    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22743        for AudioRendererSetReferenceClockRequest
22744    {
22745        #[inline(always)]
22746        fn new_empty() -> Self {
22747            Self {
22748                reference_clock: fidl::new_empty!(
22749                    fidl::encoding::Optional<
22750                        fidl::encoding::HandleType<
22751                            fidl::Clock,
22752                            { fidl::ObjectType::CLOCK.into_raw() },
22753                            2147483648,
22754                        >,
22755                    >,
22756                    fidl::encoding::DefaultFuchsiaResourceDialect
22757                ),
22758            }
22759        }
22760
22761        #[inline]
22762        unsafe fn decode(
22763            &mut self,
22764            decoder: &mut fidl::encoding::Decoder<
22765                '_,
22766                fidl::encoding::DefaultFuchsiaResourceDialect,
22767            >,
22768            offset: usize,
22769            _depth: fidl::encoding::Depth,
22770        ) -> fidl::Result<()> {
22771            decoder.debug_check_bounds::<Self>(offset);
22772            // Verify that padding bytes are zero.
22773            fidl::decode!(
22774                fidl::encoding::Optional<
22775                    fidl::encoding::HandleType<
22776                        fidl::Clock,
22777                        { fidl::ObjectType::CLOCK.into_raw() },
22778                        2147483648,
22779                    >,
22780                >,
22781                fidl::encoding::DefaultFuchsiaResourceDialect,
22782                &mut self.reference_clock,
22783                decoder,
22784                offset + 0,
22785                _depth
22786            )?;
22787            Ok(())
22788        }
22789    }
22790
22791    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22792        type Borrowed<'a> = &'a mut Self;
22793        fn take_or_borrow<'a>(
22794            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22795        ) -> Self::Borrowed<'a> {
22796            value
22797        }
22798    }
22799
22800    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
22801        type Owned = Self;
22802
22803        #[inline(always)]
22804        fn inline_align(_context: fidl::encoding::Context) -> usize {
22805            8
22806        }
22807
22808        #[inline(always)]
22809        fn inline_size(_context: fidl::encoding::Context) -> usize {
22810            40
22811        }
22812    }
22813
22814    unsafe impl
22815        fidl::encoding::Encode<
22816            ProfileProviderRegisterHandlerWithCapacityRequest,
22817            fidl::encoding::DefaultFuchsiaResourceDialect,
22818        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
22819    {
22820        #[inline]
22821        unsafe fn encode(
22822            self,
22823            encoder: &mut fidl::encoding::Encoder<
22824                '_,
22825                fidl::encoding::DefaultFuchsiaResourceDialect,
22826            >,
22827            offset: usize,
22828            _depth: fidl::encoding::Depth,
22829        ) -> fidl::Result<()> {
22830            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22831            // Delegate to tuple encoding.
22832            fidl::encoding::Encode::<
22833                ProfileProviderRegisterHandlerWithCapacityRequest,
22834                fidl::encoding::DefaultFuchsiaResourceDialect,
22835            >::encode(
22836                (
22837                    <fidl::encoding::HandleType<
22838                        fidl::Thread,
22839                        { fidl::ObjectType::THREAD.into_raw() },
22840                        2147483648,
22841                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22842                        &mut self.thread_handle,
22843                    ),
22844                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
22845                        &self.name,
22846                    ),
22847                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
22848                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
22849                ),
22850                encoder,
22851                offset,
22852                _depth,
22853            )
22854        }
22855    }
22856    unsafe impl<
22857        T0: fidl::encoding::Encode<
22858                fidl::encoding::HandleType<
22859                    fidl::Thread,
22860                    { fidl::ObjectType::THREAD.into_raw() },
22861                    2147483648,
22862                >,
22863                fidl::encoding::DefaultFuchsiaResourceDialect,
22864            >,
22865        T1: fidl::encoding::Encode<
22866                fidl::encoding::BoundedString<64>,
22867                fidl::encoding::DefaultFuchsiaResourceDialect,
22868            >,
22869        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
22870        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
22871    >
22872        fidl::encoding::Encode<
22873            ProfileProviderRegisterHandlerWithCapacityRequest,
22874            fidl::encoding::DefaultFuchsiaResourceDialect,
22875        > for (T0, T1, T2, T3)
22876    {
22877        #[inline]
22878        unsafe fn encode(
22879            self,
22880            encoder: &mut fidl::encoding::Encoder<
22881                '_,
22882                fidl::encoding::DefaultFuchsiaResourceDialect,
22883            >,
22884            offset: usize,
22885            depth: fidl::encoding::Depth,
22886        ) -> fidl::Result<()> {
22887            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
22888            // Zero out padding regions. There's no need to apply masks
22889            // because the unmasked parts will be overwritten by fields.
22890            unsafe {
22891                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
22892                (ptr as *mut u64).write_unaligned(0);
22893            }
22894            unsafe {
22895                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
22896                (ptr as *mut u64).write_unaligned(0);
22897            }
22898            // Write the fields.
22899            self.0.encode(encoder, offset + 0, depth)?;
22900            self.1.encode(encoder, offset + 8, depth)?;
22901            self.2.encode(encoder, offset + 24, depth)?;
22902            self.3.encode(encoder, offset + 32, depth)?;
22903            Ok(())
22904        }
22905    }
22906
22907    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22908        for ProfileProviderRegisterHandlerWithCapacityRequest
22909    {
22910        #[inline(always)]
22911        fn new_empty() -> Self {
22912            Self {
22913                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22914                name: fidl::new_empty!(
22915                    fidl::encoding::BoundedString<64>,
22916                    fidl::encoding::DefaultFuchsiaResourceDialect
22917                ),
22918                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
22919                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
22920            }
22921        }
22922
22923        #[inline]
22924        unsafe fn decode(
22925            &mut self,
22926            decoder: &mut fidl::encoding::Decoder<
22927                '_,
22928                fidl::encoding::DefaultFuchsiaResourceDialect,
22929            >,
22930            offset: usize,
22931            _depth: fidl::encoding::Depth,
22932        ) -> fidl::Result<()> {
22933            decoder.debug_check_bounds::<Self>(offset);
22934            // Verify that padding bytes are zero.
22935            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
22936            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22937            let mask = 0xffffffff00000000u64;
22938            let maskedval = padval & mask;
22939            if maskedval != 0 {
22940                return Err(fidl::Error::NonZeroPadding {
22941                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
22942                });
22943            }
22944            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
22945            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22946            let mask = 0xffffffff00000000u64;
22947            let maskedval = padval & mask;
22948            if maskedval != 0 {
22949                return Err(fidl::Error::NonZeroPadding {
22950                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
22951                });
22952            }
22953            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
22954            fidl::decode!(
22955                fidl::encoding::BoundedString<64>,
22956                fidl::encoding::DefaultFuchsiaResourceDialect,
22957                &mut self.name,
22958                decoder,
22959                offset + 8,
22960                _depth
22961            )?;
22962            fidl::decode!(
22963                i64,
22964                fidl::encoding::DefaultFuchsiaResourceDialect,
22965                &mut self.period,
22966                decoder,
22967                offset + 24,
22968                _depth
22969            )?;
22970            fidl::decode!(
22971                f32,
22972                fidl::encoding::DefaultFuchsiaResourceDialect,
22973                &mut self.capacity,
22974                decoder,
22975                offset + 32,
22976                _depth
22977            )?;
22978            Ok(())
22979        }
22980    }
22981
22982    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22983        type Borrowed<'a> = &'a mut Self;
22984        fn take_or_borrow<'a>(
22985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22986        ) -> Self::Borrowed<'a> {
22987            value
22988        }
22989    }
22990
22991    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
22992        type Owned = Self;
22993
22994        #[inline(always)]
22995        fn inline_align(_context: fidl::encoding::Context) -> usize {
22996            8
22997        }
22998
22999        #[inline(always)]
23000        fn inline_size(_context: fidl::encoding::Context) -> usize {
23001            24
23002        }
23003    }
23004
23005    unsafe impl
23006        fidl::encoding::Encode<
23007            ProfileProviderRegisterMemoryRangeRequest,
23008            fidl::encoding::DefaultFuchsiaResourceDialect,
23009        > for &mut ProfileProviderRegisterMemoryRangeRequest
23010    {
23011        #[inline]
23012        unsafe fn encode(
23013            self,
23014            encoder: &mut fidl::encoding::Encoder<
23015                '_,
23016                fidl::encoding::DefaultFuchsiaResourceDialect,
23017            >,
23018            offset: usize,
23019            _depth: fidl::encoding::Depth,
23020        ) -> fidl::Result<()> {
23021            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23022            // Delegate to tuple encoding.
23023            fidl::encoding::Encode::<
23024                ProfileProviderRegisterMemoryRangeRequest,
23025                fidl::encoding::DefaultFuchsiaResourceDialect,
23026            >::encode(
23027                (
23028                    <fidl::encoding::HandleType<
23029                        fidl::Vmar,
23030                        { fidl::ObjectType::VMAR.into_raw() },
23031                        2147483648,
23032                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23033                        &mut self.vmar_handle
23034                    ),
23035                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23036                        &self.name,
23037                    ),
23038                ),
23039                encoder,
23040                offset,
23041                _depth,
23042            )
23043        }
23044    }
23045    unsafe impl<
23046        T0: fidl::encoding::Encode<
23047                fidl::encoding::HandleType<
23048                    fidl::Vmar,
23049                    { fidl::ObjectType::VMAR.into_raw() },
23050                    2147483648,
23051                >,
23052                fidl::encoding::DefaultFuchsiaResourceDialect,
23053            >,
23054        T1: fidl::encoding::Encode<
23055                fidl::encoding::BoundedString<64>,
23056                fidl::encoding::DefaultFuchsiaResourceDialect,
23057            >,
23058    >
23059        fidl::encoding::Encode<
23060            ProfileProviderRegisterMemoryRangeRequest,
23061            fidl::encoding::DefaultFuchsiaResourceDialect,
23062        > for (T0, T1)
23063    {
23064        #[inline]
23065        unsafe fn encode(
23066            self,
23067            encoder: &mut fidl::encoding::Encoder<
23068                '_,
23069                fidl::encoding::DefaultFuchsiaResourceDialect,
23070            >,
23071            offset: usize,
23072            depth: fidl::encoding::Depth,
23073        ) -> fidl::Result<()> {
23074            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
23075            // Zero out padding regions. There's no need to apply masks
23076            // because the unmasked parts will be overwritten by fields.
23077            unsafe {
23078                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23079                (ptr as *mut u64).write_unaligned(0);
23080            }
23081            // Write the fields.
23082            self.0.encode(encoder, offset + 0, depth)?;
23083            self.1.encode(encoder, offset + 8, depth)?;
23084            Ok(())
23085        }
23086    }
23087
23088    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23089        for ProfileProviderRegisterMemoryRangeRequest
23090    {
23091        #[inline(always)]
23092        fn new_empty() -> Self {
23093            Self {
23094                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23095                name: fidl::new_empty!(
23096                    fidl::encoding::BoundedString<64>,
23097                    fidl::encoding::DefaultFuchsiaResourceDialect
23098                ),
23099            }
23100        }
23101
23102        #[inline]
23103        unsafe fn decode(
23104            &mut self,
23105            decoder: &mut fidl::encoding::Decoder<
23106                '_,
23107                fidl::encoding::DefaultFuchsiaResourceDialect,
23108            >,
23109            offset: usize,
23110            _depth: fidl::encoding::Depth,
23111        ) -> fidl::Result<()> {
23112            decoder.debug_check_bounds::<Self>(offset);
23113            // Verify that padding bytes are zero.
23114            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23115            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23116            let mask = 0xffffffff00000000u64;
23117            let maskedval = padval & mask;
23118            if maskedval != 0 {
23119                return Err(fidl::Error::NonZeroPadding {
23120                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23121                });
23122            }
23123            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23124            fidl::decode!(
23125                fidl::encoding::BoundedString<64>,
23126                fidl::encoding::DefaultFuchsiaResourceDialect,
23127                &mut self.name,
23128                decoder,
23129                offset + 8,
23130                _depth
23131            )?;
23132            Ok(())
23133        }
23134    }
23135
23136    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
23137        type Borrowed<'a> = &'a mut Self;
23138        fn take_or_borrow<'a>(
23139            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23140        ) -> Self::Borrowed<'a> {
23141            value
23142        }
23143    }
23144
23145    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
23146        type Owned = Self;
23147
23148        #[inline(always)]
23149        fn inline_align(_context: fidl::encoding::Context) -> usize {
23150            8
23151        }
23152
23153        #[inline(always)]
23154        fn inline_size(_context: fidl::encoding::Context) -> usize {
23155            24
23156        }
23157    }
23158
23159    unsafe impl
23160        fidl::encoding::Encode<
23161            ProfileProviderUnregisterHandlerRequest,
23162            fidl::encoding::DefaultFuchsiaResourceDialect,
23163        > for &mut ProfileProviderUnregisterHandlerRequest
23164    {
23165        #[inline]
23166        unsafe fn encode(
23167            self,
23168            encoder: &mut fidl::encoding::Encoder<
23169                '_,
23170                fidl::encoding::DefaultFuchsiaResourceDialect,
23171            >,
23172            offset: usize,
23173            _depth: fidl::encoding::Depth,
23174        ) -> fidl::Result<()> {
23175            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23176            // Delegate to tuple encoding.
23177            fidl::encoding::Encode::<
23178                ProfileProviderUnregisterHandlerRequest,
23179                fidl::encoding::DefaultFuchsiaResourceDialect,
23180            >::encode(
23181                (
23182                    <fidl::encoding::HandleType<
23183                        fidl::Thread,
23184                        { fidl::ObjectType::THREAD.into_raw() },
23185                        2147483648,
23186                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23187                        &mut self.thread_handle,
23188                    ),
23189                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
23190                        &self.name,
23191                    ),
23192                ),
23193                encoder,
23194                offset,
23195                _depth,
23196            )
23197        }
23198    }
23199    unsafe impl<
23200        T0: fidl::encoding::Encode<
23201                fidl::encoding::HandleType<
23202                    fidl::Thread,
23203                    { fidl::ObjectType::THREAD.into_raw() },
23204                    2147483648,
23205                >,
23206                fidl::encoding::DefaultFuchsiaResourceDialect,
23207            >,
23208        T1: fidl::encoding::Encode<
23209                fidl::encoding::BoundedString<64>,
23210                fidl::encoding::DefaultFuchsiaResourceDialect,
23211            >,
23212    >
23213        fidl::encoding::Encode<
23214            ProfileProviderUnregisterHandlerRequest,
23215            fidl::encoding::DefaultFuchsiaResourceDialect,
23216        > for (T0, T1)
23217    {
23218        #[inline]
23219        unsafe fn encode(
23220            self,
23221            encoder: &mut fidl::encoding::Encoder<
23222                '_,
23223                fidl::encoding::DefaultFuchsiaResourceDialect,
23224            >,
23225            offset: usize,
23226            depth: fidl::encoding::Depth,
23227        ) -> fidl::Result<()> {
23228            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
23229            // Zero out padding regions. There's no need to apply masks
23230            // because the unmasked parts will be overwritten by fields.
23231            unsafe {
23232                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23233                (ptr as *mut u64).write_unaligned(0);
23234            }
23235            // Write the fields.
23236            self.0.encode(encoder, offset + 0, depth)?;
23237            self.1.encode(encoder, offset + 8, depth)?;
23238            Ok(())
23239        }
23240    }
23241
23242    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23243        for ProfileProviderUnregisterHandlerRequest
23244    {
23245        #[inline(always)]
23246        fn new_empty() -> Self {
23247            Self {
23248                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23249                name: fidl::new_empty!(
23250                    fidl::encoding::BoundedString<64>,
23251                    fidl::encoding::DefaultFuchsiaResourceDialect
23252                ),
23253            }
23254        }
23255
23256        #[inline]
23257        unsafe fn decode(
23258            &mut self,
23259            decoder: &mut fidl::encoding::Decoder<
23260                '_,
23261                fidl::encoding::DefaultFuchsiaResourceDialect,
23262            >,
23263            offset: usize,
23264            _depth: fidl::encoding::Depth,
23265        ) -> fidl::Result<()> {
23266            decoder.debug_check_bounds::<Self>(offset);
23267            // Verify that padding bytes are zero.
23268            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23269            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23270            let mask = 0xffffffff00000000u64;
23271            let maskedval = padval & mask;
23272            if maskedval != 0 {
23273                return Err(fidl::Error::NonZeroPadding {
23274                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23275                });
23276            }
23277            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
23278            fidl::decode!(
23279                fidl::encoding::BoundedString<64>,
23280                fidl::encoding::DefaultFuchsiaResourceDialect,
23281                &mut self.name,
23282                decoder,
23283                offset + 8,
23284                _depth
23285            )?;
23286            Ok(())
23287        }
23288    }
23289
23290    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23291        type Borrowed<'a> = &'a mut Self;
23292        fn take_or_borrow<'a>(
23293            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23294        ) -> Self::Borrowed<'a> {
23295            value
23296        }
23297    }
23298
23299    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
23300        type Owned = Self;
23301
23302        #[inline(always)]
23303        fn inline_align(_context: fidl::encoding::Context) -> usize {
23304            4
23305        }
23306
23307        #[inline(always)]
23308        fn inline_size(_context: fidl::encoding::Context) -> usize {
23309            4
23310        }
23311    }
23312
23313    unsafe impl
23314        fidl::encoding::Encode<
23315            ProfileProviderUnregisterMemoryRangeRequest,
23316            fidl::encoding::DefaultFuchsiaResourceDialect,
23317        > for &mut ProfileProviderUnregisterMemoryRangeRequest
23318    {
23319        #[inline]
23320        unsafe fn encode(
23321            self,
23322            encoder: &mut fidl::encoding::Encoder<
23323                '_,
23324                fidl::encoding::DefaultFuchsiaResourceDialect,
23325            >,
23326            offset: usize,
23327            _depth: fidl::encoding::Depth,
23328        ) -> fidl::Result<()> {
23329            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23330            // Delegate to tuple encoding.
23331            fidl::encoding::Encode::<
23332                ProfileProviderUnregisterMemoryRangeRequest,
23333                fidl::encoding::DefaultFuchsiaResourceDialect,
23334            >::encode(
23335                (<fidl::encoding::HandleType<
23336                    fidl::Vmar,
23337                    { fidl::ObjectType::VMAR.into_raw() },
23338                    2147483648,
23339                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23340                    &mut self.vmar_handle
23341                ),),
23342                encoder,
23343                offset,
23344                _depth,
23345            )
23346        }
23347    }
23348    unsafe impl<
23349        T0: fidl::encoding::Encode<
23350                fidl::encoding::HandleType<
23351                    fidl::Vmar,
23352                    { fidl::ObjectType::VMAR.into_raw() },
23353                    2147483648,
23354                >,
23355                fidl::encoding::DefaultFuchsiaResourceDialect,
23356            >,
23357    >
23358        fidl::encoding::Encode<
23359            ProfileProviderUnregisterMemoryRangeRequest,
23360            fidl::encoding::DefaultFuchsiaResourceDialect,
23361        > for (T0,)
23362    {
23363        #[inline]
23364        unsafe fn encode(
23365            self,
23366            encoder: &mut fidl::encoding::Encoder<
23367                '_,
23368                fidl::encoding::DefaultFuchsiaResourceDialect,
23369            >,
23370            offset: usize,
23371            depth: fidl::encoding::Depth,
23372        ) -> fidl::Result<()> {
23373            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
23374            // Zero out padding regions. There's no need to apply masks
23375            // because the unmasked parts will be overwritten by fields.
23376            // Write the fields.
23377            self.0.encode(encoder, offset + 0, depth)?;
23378            Ok(())
23379        }
23380    }
23381
23382    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23383        for ProfileProviderUnregisterMemoryRangeRequest
23384    {
23385        #[inline(always)]
23386        fn new_empty() -> Self {
23387            Self {
23388                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23389            }
23390        }
23391
23392        #[inline]
23393        unsafe fn decode(
23394            &mut self,
23395            decoder: &mut fidl::encoding::Decoder<
23396                '_,
23397                fidl::encoding::DefaultFuchsiaResourceDialect,
23398            >,
23399            offset: usize,
23400            _depth: fidl::encoding::Depth,
23401        ) -> fidl::Result<()> {
23402            decoder.debug_check_bounds::<Self>(offset);
23403            // Verify that padding bytes are zero.
23404            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
23405            Ok(())
23406        }
23407    }
23408
23409    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23410        type Borrowed<'a> = &'a mut Self;
23411        fn take_or_borrow<'a>(
23412            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23413        ) -> Self::Borrowed<'a> {
23414            value
23415        }
23416    }
23417
23418    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
23419        type Owned = Self;
23420
23421        #[inline(always)]
23422        fn inline_align(_context: fidl::encoding::Context) -> usize {
23423            8
23424        }
23425
23426        #[inline(always)]
23427        fn inline_size(_context: fidl::encoding::Context) -> usize {
23428            16
23429        }
23430    }
23431
23432    unsafe impl
23433        fidl::encoding::Encode<
23434            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23435            fidl::encoding::DefaultFuchsiaResourceDialect,
23436        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
23437    {
23438        #[inline]
23439        unsafe fn encode(
23440            self,
23441            encoder: &mut fidl::encoding::Encoder<
23442                '_,
23443                fidl::encoding::DefaultFuchsiaResourceDialect,
23444            >,
23445            offset: usize,
23446            _depth: fidl::encoding::Depth,
23447        ) -> fidl::Result<()> {
23448            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23449                offset,
23450            );
23451            // Delegate to tuple encoding.
23452            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23453                (
23454                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
23455                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23456                ),
23457                encoder, offset, _depth
23458            )
23459        }
23460    }
23461    unsafe impl<
23462        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
23463        T1: fidl::encoding::Encode<
23464                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23465                fidl::encoding::DefaultFuchsiaResourceDialect,
23466            >,
23467    >
23468        fidl::encoding::Encode<
23469            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
23470            fidl::encoding::DefaultFuchsiaResourceDialect,
23471        > for (T0, T1)
23472    {
23473        #[inline]
23474        unsafe fn encode(
23475            self,
23476            encoder: &mut fidl::encoding::Encoder<
23477                '_,
23478                fidl::encoding::DefaultFuchsiaResourceDialect,
23479            >,
23480            offset: usize,
23481            depth: fidl::encoding::Depth,
23482        ) -> fidl::Result<()> {
23483            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
23484                offset,
23485            );
23486            // Zero out padding regions. There's no need to apply masks
23487            // because the unmasked parts will be overwritten by fields.
23488            unsafe {
23489                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23490                (ptr as *mut u64).write_unaligned(0);
23491            }
23492            // Write the fields.
23493            self.0.encode(encoder, offset + 0, depth)?;
23494            self.1.encode(encoder, offset + 8, depth)?;
23495            Ok(())
23496        }
23497    }
23498
23499    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23500        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
23501    {
23502        #[inline(always)]
23503        fn new_empty() -> Self {
23504            Self {
23505                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
23506                audio_consumer_request: fidl::new_empty!(
23507                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23508                    fidl::encoding::DefaultFuchsiaResourceDialect
23509                ),
23510            }
23511        }
23512
23513        #[inline]
23514        unsafe fn decode(
23515            &mut self,
23516            decoder: &mut fidl::encoding::Decoder<
23517                '_,
23518                fidl::encoding::DefaultFuchsiaResourceDialect,
23519            >,
23520            offset: usize,
23521            _depth: fidl::encoding::Depth,
23522        ) -> fidl::Result<()> {
23523            decoder.debug_check_bounds::<Self>(offset);
23524            // Verify that padding bytes are zero.
23525            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
23526            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23527            let mask = 0xffffffff00000000u64;
23528            let maskedval = padval & mask;
23529            if maskedval != 0 {
23530                return Err(fidl::Error::NonZeroPadding {
23531                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
23532                });
23533            }
23534            fidl::decode!(
23535                u64,
23536                fidl::encoding::DefaultFuchsiaResourceDialect,
23537                &mut self.session_id,
23538                decoder,
23539                offset + 0,
23540                _depth
23541            )?;
23542            fidl::decode!(
23543                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23544                fidl::encoding::DefaultFuchsiaResourceDialect,
23545                &mut self.audio_consumer_request,
23546                decoder,
23547                offset + 8,
23548                _depth
23549            )?;
23550            Ok(())
23551        }
23552    }
23553
23554    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
23555        type Borrowed<'a> = &'a mut Self;
23556        fn take_or_borrow<'a>(
23557            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23558        ) -> Self::Borrowed<'a> {
23559            value
23560        }
23561    }
23562
23563    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
23564        type Owned = Self;
23565
23566        #[inline(always)]
23567        fn inline_align(_context: fidl::encoding::Context) -> usize {
23568            4
23569        }
23570
23571        #[inline(always)]
23572        fn inline_size(_context: fidl::encoding::Context) -> usize {
23573            8
23574        }
23575    }
23576
23577    unsafe impl
23578        fidl::encoding::Encode<
23579            StreamBufferSetAddPayloadBufferRequest,
23580            fidl::encoding::DefaultFuchsiaResourceDialect,
23581        > for &mut StreamBufferSetAddPayloadBufferRequest
23582    {
23583        #[inline]
23584        unsafe fn encode(
23585            self,
23586            encoder: &mut fidl::encoding::Encoder<
23587                '_,
23588                fidl::encoding::DefaultFuchsiaResourceDialect,
23589            >,
23590            offset: usize,
23591            _depth: fidl::encoding::Depth,
23592        ) -> fidl::Result<()> {
23593            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23594            // Delegate to tuple encoding.
23595            fidl::encoding::Encode::<
23596                StreamBufferSetAddPayloadBufferRequest,
23597                fidl::encoding::DefaultFuchsiaResourceDialect,
23598            >::encode(
23599                (
23600                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
23601                    <fidl::encoding::HandleType<
23602                        fidl::Vmo,
23603                        { fidl::ObjectType::VMO.into_raw() },
23604                        2147483648,
23605                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23606                        &mut self.payload_buffer,
23607                    ),
23608                ),
23609                encoder,
23610                offset,
23611                _depth,
23612            )
23613        }
23614    }
23615    unsafe impl<
23616        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
23617        T1: fidl::encoding::Encode<
23618                fidl::encoding::HandleType<
23619                    fidl::Vmo,
23620                    { fidl::ObjectType::VMO.into_raw() },
23621                    2147483648,
23622                >,
23623                fidl::encoding::DefaultFuchsiaResourceDialect,
23624            >,
23625    >
23626        fidl::encoding::Encode<
23627            StreamBufferSetAddPayloadBufferRequest,
23628            fidl::encoding::DefaultFuchsiaResourceDialect,
23629        > for (T0, T1)
23630    {
23631        #[inline]
23632        unsafe fn encode(
23633            self,
23634            encoder: &mut fidl::encoding::Encoder<
23635                '_,
23636                fidl::encoding::DefaultFuchsiaResourceDialect,
23637            >,
23638            offset: usize,
23639            depth: fidl::encoding::Depth,
23640        ) -> fidl::Result<()> {
23641            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
23642            // Zero out padding regions. There's no need to apply masks
23643            // because the unmasked parts will be overwritten by fields.
23644            // Write the fields.
23645            self.0.encode(encoder, offset + 0, depth)?;
23646            self.1.encode(encoder, offset + 4, depth)?;
23647            Ok(())
23648        }
23649    }
23650
23651    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23652        for StreamBufferSetAddPayloadBufferRequest
23653    {
23654        #[inline(always)]
23655        fn new_empty() -> Self {
23656            Self {
23657                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
23658                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
23659            }
23660        }
23661
23662        #[inline]
23663        unsafe fn decode(
23664            &mut self,
23665            decoder: &mut fidl::encoding::Decoder<
23666                '_,
23667                fidl::encoding::DefaultFuchsiaResourceDialect,
23668            >,
23669            offset: usize,
23670            _depth: fidl::encoding::Depth,
23671        ) -> fidl::Result<()> {
23672            decoder.debug_check_bounds::<Self>(offset);
23673            // Verify that padding bytes are zero.
23674            fidl::decode!(
23675                u32,
23676                fidl::encoding::DefaultFuchsiaResourceDialect,
23677                &mut self.id,
23678                decoder,
23679                offset + 0,
23680                _depth
23681            )?;
23682            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
23683            Ok(())
23684        }
23685    }
23686
23687    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23688        type Borrowed<'a> = &'a mut Self;
23689        fn take_or_borrow<'a>(
23690            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23691        ) -> Self::Borrowed<'a> {
23692            value
23693        }
23694    }
23695
23696    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
23697        type Owned = Self;
23698
23699        #[inline(always)]
23700        fn inline_align(_context: fidl::encoding::Context) -> usize {
23701            8
23702        }
23703
23704        #[inline(always)]
23705        fn inline_size(_context: fidl::encoding::Context) -> usize {
23706            16
23707        }
23708    }
23709
23710    unsafe impl
23711        fidl::encoding::Encode<
23712            StreamProcessorSetInputBufferPartialSettingsRequest,
23713            fidl::encoding::DefaultFuchsiaResourceDialect,
23714        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
23715    {
23716        #[inline]
23717        unsafe fn encode(
23718            self,
23719            encoder: &mut fidl::encoding::Encoder<
23720                '_,
23721                fidl::encoding::DefaultFuchsiaResourceDialect,
23722            >,
23723            offset: usize,
23724            _depth: fidl::encoding::Depth,
23725        ) -> fidl::Result<()> {
23726            encoder
23727                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23728            // Delegate to tuple encoding.
23729            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23730                (
23731                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
23732                ),
23733                encoder, offset, _depth
23734            )
23735        }
23736    }
23737    unsafe impl<
23738        T0: fidl::encoding::Encode<
23739                StreamBufferPartialSettings,
23740                fidl::encoding::DefaultFuchsiaResourceDialect,
23741            >,
23742    >
23743        fidl::encoding::Encode<
23744            StreamProcessorSetInputBufferPartialSettingsRequest,
23745            fidl::encoding::DefaultFuchsiaResourceDialect,
23746        > for (T0,)
23747    {
23748        #[inline]
23749        unsafe fn encode(
23750            self,
23751            encoder: &mut fidl::encoding::Encoder<
23752                '_,
23753                fidl::encoding::DefaultFuchsiaResourceDialect,
23754            >,
23755            offset: usize,
23756            depth: fidl::encoding::Depth,
23757        ) -> fidl::Result<()> {
23758            encoder
23759                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
23760            // Zero out padding regions. There's no need to apply masks
23761            // because the unmasked parts will be overwritten by fields.
23762            // Write the fields.
23763            self.0.encode(encoder, offset + 0, depth)?;
23764            Ok(())
23765        }
23766    }
23767
23768    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23769        for StreamProcessorSetInputBufferPartialSettingsRequest
23770    {
23771        #[inline(always)]
23772        fn new_empty() -> Self {
23773            Self {
23774                input_settings: fidl::new_empty!(
23775                    StreamBufferPartialSettings,
23776                    fidl::encoding::DefaultFuchsiaResourceDialect
23777                ),
23778            }
23779        }
23780
23781        #[inline]
23782        unsafe fn decode(
23783            &mut self,
23784            decoder: &mut fidl::encoding::Decoder<
23785                '_,
23786                fidl::encoding::DefaultFuchsiaResourceDialect,
23787            >,
23788            offset: usize,
23789            _depth: fidl::encoding::Depth,
23790        ) -> fidl::Result<()> {
23791            decoder.debug_check_bounds::<Self>(offset);
23792            // Verify that padding bytes are zero.
23793            fidl::decode!(
23794                StreamBufferPartialSettings,
23795                fidl::encoding::DefaultFuchsiaResourceDialect,
23796                &mut self.input_settings,
23797                decoder,
23798                offset + 0,
23799                _depth
23800            )?;
23801            Ok(())
23802        }
23803    }
23804
23805    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23806        type Borrowed<'a> = &'a mut Self;
23807        fn take_or_borrow<'a>(
23808            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23809        ) -> Self::Borrowed<'a> {
23810            value
23811        }
23812    }
23813
23814    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
23815        type Owned = Self;
23816
23817        #[inline(always)]
23818        fn inline_align(_context: fidl::encoding::Context) -> usize {
23819            8
23820        }
23821
23822        #[inline(always)]
23823        fn inline_size(_context: fidl::encoding::Context) -> usize {
23824            16
23825        }
23826    }
23827
23828    unsafe impl
23829        fidl::encoding::Encode<
23830            StreamProcessorSetOutputBufferPartialSettingsRequest,
23831            fidl::encoding::DefaultFuchsiaResourceDialect,
23832        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
23833    {
23834        #[inline]
23835        unsafe fn encode(
23836            self,
23837            encoder: &mut fidl::encoding::Encoder<
23838                '_,
23839                fidl::encoding::DefaultFuchsiaResourceDialect,
23840            >,
23841            offset: usize,
23842            _depth: fidl::encoding::Depth,
23843        ) -> fidl::Result<()> {
23844            encoder
23845                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23846            // Delegate to tuple encoding.
23847            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23848                (
23849                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
23850                ),
23851                encoder, offset, _depth
23852            )
23853        }
23854    }
23855    unsafe impl<
23856        T0: fidl::encoding::Encode<
23857                StreamBufferPartialSettings,
23858                fidl::encoding::DefaultFuchsiaResourceDialect,
23859            >,
23860    >
23861        fidl::encoding::Encode<
23862            StreamProcessorSetOutputBufferPartialSettingsRequest,
23863            fidl::encoding::DefaultFuchsiaResourceDialect,
23864        > for (T0,)
23865    {
23866        #[inline]
23867        unsafe fn encode(
23868            self,
23869            encoder: &mut fidl::encoding::Encoder<
23870                '_,
23871                fidl::encoding::DefaultFuchsiaResourceDialect,
23872            >,
23873            offset: usize,
23874            depth: fidl::encoding::Depth,
23875        ) -> fidl::Result<()> {
23876            encoder
23877                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
23878            // Zero out padding regions. There's no need to apply masks
23879            // because the unmasked parts will be overwritten by fields.
23880            // Write the fields.
23881            self.0.encode(encoder, offset + 0, depth)?;
23882            Ok(())
23883        }
23884    }
23885
23886    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23887        for StreamProcessorSetOutputBufferPartialSettingsRequest
23888    {
23889        #[inline(always)]
23890        fn new_empty() -> Self {
23891            Self {
23892                output_settings: fidl::new_empty!(
23893                    StreamBufferPartialSettings,
23894                    fidl::encoding::DefaultFuchsiaResourceDialect
23895                ),
23896            }
23897        }
23898
23899        #[inline]
23900        unsafe fn decode(
23901            &mut self,
23902            decoder: &mut fidl::encoding::Decoder<
23903                '_,
23904                fidl::encoding::DefaultFuchsiaResourceDialect,
23905            >,
23906            offset: usize,
23907            _depth: fidl::encoding::Depth,
23908        ) -> fidl::Result<()> {
23909            decoder.debug_check_bounds::<Self>(offset);
23910            // Verify that padding bytes are zero.
23911            fidl::decode!(
23912                StreamBufferPartialSettings,
23913                fidl::encoding::DefaultFuchsiaResourceDialect,
23914                &mut self.output_settings,
23915                decoder,
23916                offset + 0,
23917                _depth
23918            )?;
23919            Ok(())
23920        }
23921    }
23922
23923    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23924        type Borrowed<'a> = &'a mut Self;
23925        fn take_or_borrow<'a>(
23926            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23927        ) -> Self::Borrowed<'a> {
23928            value
23929        }
23930    }
23931
23932    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
23933        type Owned = Self;
23934
23935        #[inline(always)]
23936        fn inline_align(_context: fidl::encoding::Context) -> usize {
23937            4
23938        }
23939
23940        #[inline(always)]
23941        fn inline_size(_context: fidl::encoding::Context) -> usize {
23942            8
23943        }
23944    }
23945
23946    unsafe impl
23947        fidl::encoding::Encode<
23948            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23949            fidl::encoding::DefaultFuchsiaResourceDialect,
23950        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
23951    {
23952        #[inline]
23953        unsafe fn encode(
23954            self,
23955            encoder: &mut fidl::encoding::Encoder<
23956                '_,
23957                fidl::encoding::DefaultFuchsiaResourceDialect,
23958            >,
23959            offset: usize,
23960            _depth: fidl::encoding::Depth,
23961        ) -> fidl::Result<()> {
23962            encoder
23963                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23964            // Delegate to tuple encoding.
23965            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23966                (
23967                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23968                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
23969                ),
23970                encoder, offset, _depth
23971            )
23972        }
23973    }
23974    unsafe impl<
23975        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
23976        T1: fidl::encoding::Encode<
23977                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
23978                fidl::encoding::DefaultFuchsiaResourceDialect,
23979            >,
23980    >
23981        fidl::encoding::Encode<
23982            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
23983            fidl::encoding::DefaultFuchsiaResourceDialect,
23984        > for (T0, T1)
23985    {
23986        #[inline]
23987        unsafe fn encode(
23988            self,
23989            encoder: &mut fidl::encoding::Encoder<
23990                '_,
23991                fidl::encoding::DefaultFuchsiaResourceDialect,
23992            >,
23993            offset: usize,
23994            depth: fidl::encoding::Depth,
23995        ) -> fidl::Result<()> {
23996            encoder
23997                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
23998            // Zero out padding regions. There's no need to apply masks
23999            // because the unmasked parts will be overwritten by fields.
24000            // Write the fields.
24001            self.0.encode(encoder, offset + 0, depth)?;
24002            self.1.encode(encoder, offset + 4, depth)?;
24003            Ok(())
24004        }
24005    }
24006
24007    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24008        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
24009    {
24010        #[inline(always)]
24011        fn new_empty() -> Self {
24012            Self {
24013                usage: fidl::new_empty!(
24014                    AudioRenderUsage2,
24015                    fidl::encoding::DefaultFuchsiaResourceDialect
24016                ),
24017                audio_consumer_request: fidl::new_empty!(
24018                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24019                    fidl::encoding::DefaultFuchsiaResourceDialect
24020                ),
24021            }
24022        }
24023
24024        #[inline]
24025        unsafe fn decode(
24026            &mut self,
24027            decoder: &mut fidl::encoding::Decoder<
24028                '_,
24029                fidl::encoding::DefaultFuchsiaResourceDialect,
24030            >,
24031            offset: usize,
24032            _depth: fidl::encoding::Depth,
24033        ) -> fidl::Result<()> {
24034            decoder.debug_check_bounds::<Self>(offset);
24035            // Verify that padding bytes are zero.
24036            fidl::decode!(
24037                AudioRenderUsage2,
24038                fidl::encoding::DefaultFuchsiaResourceDialect,
24039                &mut self.usage,
24040                decoder,
24041                offset + 0,
24042                _depth
24043            )?;
24044            fidl::decode!(
24045                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24046                fidl::encoding::DefaultFuchsiaResourceDialect,
24047                &mut self.audio_consumer_request,
24048                decoder,
24049                offset + 4,
24050                _depth
24051            )?;
24052            Ok(())
24053        }
24054    }
24055
24056    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24057        type Borrowed<'a> = &'a mut Self;
24058        fn take_or_borrow<'a>(
24059            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24060        ) -> Self::Borrowed<'a> {
24061            value
24062        }
24063    }
24064
24065    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
24066        type Owned = Self;
24067
24068        #[inline(always)]
24069        fn inline_align(_context: fidl::encoding::Context) -> usize {
24070            4
24071        }
24072
24073        #[inline(always)]
24074        fn inline_size(_context: fidl::encoding::Context) -> usize {
24075            8
24076        }
24077    }
24078
24079    unsafe impl
24080        fidl::encoding::Encode<
24081            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24082            fidl::encoding::DefaultFuchsiaResourceDialect,
24083        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
24084    {
24085        #[inline]
24086        unsafe fn encode(
24087            self,
24088            encoder: &mut fidl::encoding::Encoder<
24089                '_,
24090                fidl::encoding::DefaultFuchsiaResourceDialect,
24091            >,
24092            offset: usize,
24093            _depth: fidl::encoding::Depth,
24094        ) -> fidl::Result<()> {
24095            encoder
24096                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24097            // Delegate to tuple encoding.
24098            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24099                (
24100                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24101                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
24102                ),
24103                encoder, offset, _depth
24104            )
24105        }
24106    }
24107    unsafe impl<
24108        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24109        T1: fidl::encoding::Encode<
24110                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24111                fidl::encoding::DefaultFuchsiaResourceDialect,
24112            >,
24113    >
24114        fidl::encoding::Encode<
24115            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
24116            fidl::encoding::DefaultFuchsiaResourceDialect,
24117        > for (T0, T1)
24118    {
24119        #[inline]
24120        unsafe fn encode(
24121            self,
24122            encoder: &mut fidl::encoding::Encoder<
24123                '_,
24124                fidl::encoding::DefaultFuchsiaResourceDialect,
24125            >,
24126            offset: usize,
24127            depth: fidl::encoding::Depth,
24128        ) -> fidl::Result<()> {
24129            encoder
24130                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
24131            // Zero out padding regions. There's no need to apply masks
24132            // because the unmasked parts will be overwritten by fields.
24133            // Write the fields.
24134            self.0.encode(encoder, offset + 0, depth)?;
24135            self.1.encode(encoder, offset + 4, depth)?;
24136            Ok(())
24137        }
24138    }
24139
24140    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24141        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
24142    {
24143        #[inline(always)]
24144        fn new_empty() -> Self {
24145            Self {
24146                usage: fidl::new_empty!(
24147                    AudioRenderUsage,
24148                    fidl::encoding::DefaultFuchsiaResourceDialect
24149                ),
24150                audio_consumer_request: fidl::new_empty!(
24151                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24152                    fidl::encoding::DefaultFuchsiaResourceDialect
24153                ),
24154            }
24155        }
24156
24157        #[inline]
24158        unsafe fn decode(
24159            &mut self,
24160            decoder: &mut fidl::encoding::Decoder<
24161                '_,
24162                fidl::encoding::DefaultFuchsiaResourceDialect,
24163            >,
24164            offset: usize,
24165            _depth: fidl::encoding::Depth,
24166        ) -> fidl::Result<()> {
24167            decoder.debug_check_bounds::<Self>(offset);
24168            // Verify that padding bytes are zero.
24169            fidl::decode!(
24170                AudioRenderUsage,
24171                fidl::encoding::DefaultFuchsiaResourceDialect,
24172                &mut self.usage,
24173                decoder,
24174                offset + 0,
24175                _depth
24176            )?;
24177            fidl::decode!(
24178                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
24179                fidl::encoding::DefaultFuchsiaResourceDialect,
24180                &mut self.audio_consumer_request,
24181                decoder,
24182                offset + 4,
24183                _depth
24184            )?;
24185            Ok(())
24186        }
24187    }
24188
24189    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
24190        type Borrowed<'a> = &'a mut Self;
24191        fn take_or_borrow<'a>(
24192            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24193        ) -> Self::Borrowed<'a> {
24194            value
24195        }
24196    }
24197
24198    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
24199        type Owned = Self;
24200
24201        #[inline(always)]
24202        fn inline_align(_context: fidl::encoding::Context) -> usize {
24203            8
24204        }
24205
24206        #[inline(always)]
24207        fn inline_size(_context: fidl::encoding::Context) -> usize {
24208            40
24209        }
24210    }
24211
24212    unsafe impl
24213        fidl::encoding::Encode<
24214            UsageGainReporterRegisterListener2Request,
24215            fidl::encoding::DefaultFuchsiaResourceDialect,
24216        > for &mut UsageGainReporterRegisterListener2Request
24217    {
24218        #[inline]
24219        unsafe fn encode(
24220            self,
24221            encoder: &mut fidl::encoding::Encoder<
24222                '_,
24223                fidl::encoding::DefaultFuchsiaResourceDialect,
24224            >,
24225            offset: usize,
24226            _depth: fidl::encoding::Depth,
24227        ) -> fidl::Result<()> {
24228            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24229            // Delegate to tuple encoding.
24230            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24231                (
24232                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24233                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24234                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24235                ),
24236                encoder, offset, _depth
24237            )
24238        }
24239    }
24240    unsafe impl<
24241        T0: fidl::encoding::Encode<
24242                fidl::encoding::BoundedString<36>,
24243                fidl::encoding::DefaultFuchsiaResourceDialect,
24244            >,
24245        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24246        T2: fidl::encoding::Encode<
24247                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24248                fidl::encoding::DefaultFuchsiaResourceDialect,
24249            >,
24250    >
24251        fidl::encoding::Encode<
24252            UsageGainReporterRegisterListener2Request,
24253            fidl::encoding::DefaultFuchsiaResourceDialect,
24254        > for (T0, T1, T2)
24255    {
24256        #[inline]
24257        unsafe fn encode(
24258            self,
24259            encoder: &mut fidl::encoding::Encoder<
24260                '_,
24261                fidl::encoding::DefaultFuchsiaResourceDialect,
24262            >,
24263            offset: usize,
24264            depth: fidl::encoding::Depth,
24265        ) -> fidl::Result<()> {
24266            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
24267            // Zero out padding regions. There's no need to apply masks
24268            // because the unmasked parts will be overwritten by fields.
24269            unsafe {
24270                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24271                (ptr as *mut u64).write_unaligned(0);
24272            }
24273            // Write the fields.
24274            self.0.encode(encoder, offset + 0, depth)?;
24275            self.1.encode(encoder, offset + 16, depth)?;
24276            self.2.encode(encoder, offset + 32, depth)?;
24277            Ok(())
24278        }
24279    }
24280
24281    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24282        for UsageGainReporterRegisterListener2Request
24283    {
24284        #[inline(always)]
24285        fn new_empty() -> Self {
24286            Self {
24287                device_unique_id: fidl::new_empty!(
24288                    fidl::encoding::BoundedString<36>,
24289                    fidl::encoding::DefaultFuchsiaResourceDialect
24290                ),
24291                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24292                usage_gain_listener: fidl::new_empty!(
24293                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24294                    fidl::encoding::DefaultFuchsiaResourceDialect
24295                ),
24296            }
24297        }
24298
24299        #[inline]
24300        unsafe fn decode(
24301            &mut self,
24302            decoder: &mut fidl::encoding::Decoder<
24303                '_,
24304                fidl::encoding::DefaultFuchsiaResourceDialect,
24305            >,
24306            offset: usize,
24307            _depth: fidl::encoding::Depth,
24308        ) -> fidl::Result<()> {
24309            decoder.debug_check_bounds::<Self>(offset);
24310            // Verify that padding bytes are zero.
24311            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24312            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24313            let mask = 0xffffffff00000000u64;
24314            let maskedval = padval & mask;
24315            if maskedval != 0 {
24316                return Err(fidl::Error::NonZeroPadding {
24317                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24318                });
24319            }
24320            fidl::decode!(
24321                fidl::encoding::BoundedString<36>,
24322                fidl::encoding::DefaultFuchsiaResourceDialect,
24323                &mut self.device_unique_id,
24324                decoder,
24325                offset + 0,
24326                _depth
24327            )?;
24328            fidl::decode!(
24329                Usage2,
24330                fidl::encoding::DefaultFuchsiaResourceDialect,
24331                &mut self.usage,
24332                decoder,
24333                offset + 16,
24334                _depth
24335            )?;
24336            fidl::decode!(
24337                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24338                fidl::encoding::DefaultFuchsiaResourceDialect,
24339                &mut self.usage_gain_listener,
24340                decoder,
24341                offset + 32,
24342                _depth
24343            )?;
24344            Ok(())
24345        }
24346    }
24347
24348    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
24349        type Borrowed<'a> = &'a mut Self;
24350        fn take_or_borrow<'a>(
24351            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24352        ) -> Self::Borrowed<'a> {
24353            value
24354        }
24355    }
24356
24357    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
24358        type Owned = Self;
24359
24360        #[inline(always)]
24361        fn inline_align(_context: fidl::encoding::Context) -> usize {
24362            8
24363        }
24364
24365        #[inline(always)]
24366        fn inline_size(_context: fidl::encoding::Context) -> usize {
24367            40
24368        }
24369    }
24370
24371    unsafe impl
24372        fidl::encoding::Encode<
24373            UsageGainReporterRegisterListenerRequest,
24374            fidl::encoding::DefaultFuchsiaResourceDialect,
24375        > for &mut UsageGainReporterRegisterListenerRequest
24376    {
24377        #[inline]
24378        unsafe fn encode(
24379            self,
24380            encoder: &mut fidl::encoding::Encoder<
24381                '_,
24382                fidl::encoding::DefaultFuchsiaResourceDialect,
24383            >,
24384            offset: usize,
24385            _depth: fidl::encoding::Depth,
24386        ) -> fidl::Result<()> {
24387            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24388            // Delegate to tuple encoding.
24389            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24390                (
24391                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
24392                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24393                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
24394                ),
24395                encoder, offset, _depth
24396            )
24397        }
24398    }
24399    unsafe impl<
24400        T0: fidl::encoding::Encode<
24401                fidl::encoding::BoundedString<36>,
24402                fidl::encoding::DefaultFuchsiaResourceDialect,
24403            >,
24404        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24405        T2: fidl::encoding::Encode<
24406                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24407                fidl::encoding::DefaultFuchsiaResourceDialect,
24408            >,
24409    >
24410        fidl::encoding::Encode<
24411            UsageGainReporterRegisterListenerRequest,
24412            fidl::encoding::DefaultFuchsiaResourceDialect,
24413        > for (T0, T1, T2)
24414    {
24415        #[inline]
24416        unsafe fn encode(
24417            self,
24418            encoder: &mut fidl::encoding::Encoder<
24419                '_,
24420                fidl::encoding::DefaultFuchsiaResourceDialect,
24421            >,
24422            offset: usize,
24423            depth: fidl::encoding::Depth,
24424        ) -> fidl::Result<()> {
24425            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
24426            // Zero out padding regions. There's no need to apply masks
24427            // because the unmasked parts will be overwritten by fields.
24428            unsafe {
24429                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
24430                (ptr as *mut u64).write_unaligned(0);
24431            }
24432            // Write the fields.
24433            self.0.encode(encoder, offset + 0, depth)?;
24434            self.1.encode(encoder, offset + 16, depth)?;
24435            self.2.encode(encoder, offset + 32, depth)?;
24436            Ok(())
24437        }
24438    }
24439
24440    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24441        for UsageGainReporterRegisterListenerRequest
24442    {
24443        #[inline(always)]
24444        fn new_empty() -> Self {
24445            Self {
24446                device_unique_id: fidl::new_empty!(
24447                    fidl::encoding::BoundedString<36>,
24448                    fidl::encoding::DefaultFuchsiaResourceDialect
24449                ),
24450                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24451                usage_gain_listener: fidl::new_empty!(
24452                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24453                    fidl::encoding::DefaultFuchsiaResourceDialect
24454                ),
24455            }
24456        }
24457
24458        #[inline]
24459        unsafe fn decode(
24460            &mut self,
24461            decoder: &mut fidl::encoding::Decoder<
24462                '_,
24463                fidl::encoding::DefaultFuchsiaResourceDialect,
24464            >,
24465            offset: usize,
24466            _depth: fidl::encoding::Depth,
24467        ) -> fidl::Result<()> {
24468            decoder.debug_check_bounds::<Self>(offset);
24469            // Verify that padding bytes are zero.
24470            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24471            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24472            let mask = 0xffffffff00000000u64;
24473            let maskedval = padval & mask;
24474            if maskedval != 0 {
24475                return Err(fidl::Error::NonZeroPadding {
24476                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24477                });
24478            }
24479            fidl::decode!(
24480                fidl::encoding::BoundedString<36>,
24481                fidl::encoding::DefaultFuchsiaResourceDialect,
24482                &mut self.device_unique_id,
24483                decoder,
24484                offset + 0,
24485                _depth
24486            )?;
24487            fidl::decode!(
24488                Usage,
24489                fidl::encoding::DefaultFuchsiaResourceDialect,
24490                &mut self.usage,
24491                decoder,
24492                offset + 16,
24493                _depth
24494            )?;
24495            fidl::decode!(
24496                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
24497                fidl::encoding::DefaultFuchsiaResourceDialect,
24498                &mut self.usage_gain_listener,
24499                decoder,
24500                offset + 32,
24501                _depth
24502            )?;
24503            Ok(())
24504        }
24505    }
24506
24507    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
24508        type Borrowed<'a> = &'a mut Self;
24509        fn take_or_borrow<'a>(
24510            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24511        ) -> Self::Borrowed<'a> {
24512            value
24513        }
24514    }
24515
24516    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
24517        type Owned = Self;
24518
24519        #[inline(always)]
24520        fn inline_align(_context: fidl::encoding::Context) -> usize {
24521            8
24522        }
24523
24524        #[inline(always)]
24525        fn inline_size(_context: fidl::encoding::Context) -> usize {
24526            24
24527        }
24528    }
24529
24530    unsafe impl
24531        fidl::encoding::Encode<
24532            UsageReporterWatch2Request,
24533            fidl::encoding::DefaultFuchsiaResourceDialect,
24534        > for &mut UsageReporterWatch2Request
24535    {
24536        #[inline]
24537        unsafe fn encode(
24538            self,
24539            encoder: &mut fidl::encoding::Encoder<
24540                '_,
24541                fidl::encoding::DefaultFuchsiaResourceDialect,
24542            >,
24543            offset: usize,
24544            _depth: fidl::encoding::Depth,
24545        ) -> fidl::Result<()> {
24546            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24547            // Delegate to tuple encoding.
24548            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24549                (
24550                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24551                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24552                ),
24553                encoder, offset, _depth
24554            )
24555        }
24556    }
24557    unsafe impl<
24558        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
24559        T1: fidl::encoding::Encode<
24560                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24561                fidl::encoding::DefaultFuchsiaResourceDialect,
24562            >,
24563    >
24564        fidl::encoding::Encode<
24565            UsageReporterWatch2Request,
24566            fidl::encoding::DefaultFuchsiaResourceDialect,
24567        > for (T0, T1)
24568    {
24569        #[inline]
24570        unsafe fn encode(
24571            self,
24572            encoder: &mut fidl::encoding::Encoder<
24573                '_,
24574                fidl::encoding::DefaultFuchsiaResourceDialect,
24575            >,
24576            offset: usize,
24577            depth: fidl::encoding::Depth,
24578        ) -> fidl::Result<()> {
24579            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
24580            // Zero out padding regions. There's no need to apply masks
24581            // because the unmasked parts will be overwritten by fields.
24582            unsafe {
24583                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24584                (ptr as *mut u64).write_unaligned(0);
24585            }
24586            // Write the fields.
24587            self.0.encode(encoder, offset + 0, depth)?;
24588            self.1.encode(encoder, offset + 16, depth)?;
24589            Ok(())
24590        }
24591    }
24592
24593    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24594        for UsageReporterWatch2Request
24595    {
24596        #[inline(always)]
24597        fn new_empty() -> Self {
24598            Self {
24599                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
24600                usage_watcher: fidl::new_empty!(
24601                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24602                    fidl::encoding::DefaultFuchsiaResourceDialect
24603                ),
24604            }
24605        }
24606
24607        #[inline]
24608        unsafe fn decode(
24609            &mut self,
24610            decoder: &mut fidl::encoding::Decoder<
24611                '_,
24612                fidl::encoding::DefaultFuchsiaResourceDialect,
24613            >,
24614            offset: usize,
24615            _depth: fidl::encoding::Depth,
24616        ) -> fidl::Result<()> {
24617            decoder.debug_check_bounds::<Self>(offset);
24618            // Verify that padding bytes are zero.
24619            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24620            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24621            let mask = 0xffffffff00000000u64;
24622            let maskedval = padval & mask;
24623            if maskedval != 0 {
24624                return Err(fidl::Error::NonZeroPadding {
24625                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24626                });
24627            }
24628            fidl::decode!(
24629                Usage2,
24630                fidl::encoding::DefaultFuchsiaResourceDialect,
24631                &mut self.usage,
24632                decoder,
24633                offset + 0,
24634                _depth
24635            )?;
24636            fidl::decode!(
24637                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
24638                fidl::encoding::DefaultFuchsiaResourceDialect,
24639                &mut self.usage_watcher,
24640                decoder,
24641                offset + 16,
24642                _depth
24643            )?;
24644            Ok(())
24645        }
24646    }
24647
24648    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
24649        type Borrowed<'a> = &'a mut Self;
24650        fn take_or_borrow<'a>(
24651            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24652        ) -> Self::Borrowed<'a> {
24653            value
24654        }
24655    }
24656
24657    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
24658        type Owned = Self;
24659
24660        #[inline(always)]
24661        fn inline_align(_context: fidl::encoding::Context) -> usize {
24662            8
24663        }
24664
24665        #[inline(always)]
24666        fn inline_size(_context: fidl::encoding::Context) -> usize {
24667            24
24668        }
24669    }
24670
24671    unsafe impl
24672        fidl::encoding::Encode<
24673            UsageReporterWatchRequest,
24674            fidl::encoding::DefaultFuchsiaResourceDialect,
24675        > for &mut UsageReporterWatchRequest
24676    {
24677        #[inline]
24678        unsafe fn encode(
24679            self,
24680            encoder: &mut fidl::encoding::Encoder<
24681                '_,
24682                fidl::encoding::DefaultFuchsiaResourceDialect,
24683            >,
24684            offset: usize,
24685            _depth: fidl::encoding::Depth,
24686        ) -> fidl::Result<()> {
24687            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24688            // Delegate to tuple encoding.
24689            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24690                (
24691                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
24692                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
24693                ),
24694                encoder, offset, _depth
24695            )
24696        }
24697    }
24698    unsafe impl<
24699        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
24700        T1: fidl::encoding::Encode<
24701                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24702                fidl::encoding::DefaultFuchsiaResourceDialect,
24703            >,
24704    >
24705        fidl::encoding::Encode<
24706            UsageReporterWatchRequest,
24707            fidl::encoding::DefaultFuchsiaResourceDialect,
24708        > for (T0, T1)
24709    {
24710        #[inline]
24711        unsafe fn encode(
24712            self,
24713            encoder: &mut fidl::encoding::Encoder<
24714                '_,
24715                fidl::encoding::DefaultFuchsiaResourceDialect,
24716            >,
24717            offset: usize,
24718            depth: fidl::encoding::Depth,
24719        ) -> fidl::Result<()> {
24720            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
24721            // Zero out padding regions. There's no need to apply masks
24722            // because the unmasked parts will be overwritten by fields.
24723            unsafe {
24724                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24725                (ptr as *mut u64).write_unaligned(0);
24726            }
24727            // Write the fields.
24728            self.0.encode(encoder, offset + 0, depth)?;
24729            self.1.encode(encoder, offset + 16, depth)?;
24730            Ok(())
24731        }
24732    }
24733
24734    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24735        for UsageReporterWatchRequest
24736    {
24737        #[inline(always)]
24738        fn new_empty() -> Self {
24739            Self {
24740                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
24741                usage_watcher: fidl::new_empty!(
24742                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24743                    fidl::encoding::DefaultFuchsiaResourceDialect
24744                ),
24745            }
24746        }
24747
24748        #[inline]
24749        unsafe fn decode(
24750            &mut self,
24751            decoder: &mut fidl::encoding::Decoder<
24752                '_,
24753                fidl::encoding::DefaultFuchsiaResourceDialect,
24754            >,
24755            offset: usize,
24756            _depth: fidl::encoding::Depth,
24757        ) -> fidl::Result<()> {
24758            decoder.debug_check_bounds::<Self>(offset);
24759            // Verify that padding bytes are zero.
24760            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24761            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24762            let mask = 0xffffffff00000000u64;
24763            let maskedval = padval & mask;
24764            if maskedval != 0 {
24765                return Err(fidl::Error::NonZeroPadding {
24766                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24767                });
24768            }
24769            fidl::decode!(
24770                Usage,
24771                fidl::encoding::DefaultFuchsiaResourceDialect,
24772                &mut self.usage,
24773                decoder,
24774                offset + 0,
24775                _depth
24776            )?;
24777            fidl::decode!(
24778                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
24779                fidl::encoding::DefaultFuchsiaResourceDialect,
24780                &mut self.usage_watcher,
24781                decoder,
24782                offset + 16,
24783                _depth
24784            )?;
24785            Ok(())
24786        }
24787    }
24788
24789    impl StreamBufferPartialSettings {
24790        #[inline(always)]
24791        fn max_ordinal_present(&self) -> u64 {
24792            if let Some(_) = self.sysmem2_token {
24793                return 7;
24794            }
24795            if let Some(_) = self.sysmem_token {
24796                return 6;
24797            }
24798            if let Some(_) = self.packet_count_for_client {
24799                return 5;
24800            }
24801            if let Some(_) = self.packet_count_for_server {
24802                return 4;
24803            }
24804            if let Some(_) = self.single_buffer_mode {
24805                return 3;
24806            }
24807            if let Some(_) = self.buffer_constraints_version_ordinal {
24808                return 2;
24809            }
24810            if let Some(_) = self.buffer_lifetime_ordinal {
24811                return 1;
24812            }
24813            0
24814        }
24815    }
24816
24817    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
24818        type Borrowed<'a> = &'a mut Self;
24819        fn take_or_borrow<'a>(
24820            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24821        ) -> Self::Borrowed<'a> {
24822            value
24823        }
24824    }
24825
24826    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
24827        type Owned = Self;
24828
24829        #[inline(always)]
24830        fn inline_align(_context: fidl::encoding::Context) -> usize {
24831            8
24832        }
24833
24834        #[inline(always)]
24835        fn inline_size(_context: fidl::encoding::Context) -> usize {
24836            16
24837        }
24838    }
24839
24840    unsafe impl
24841        fidl::encoding::Encode<
24842            StreamBufferPartialSettings,
24843            fidl::encoding::DefaultFuchsiaResourceDialect,
24844        > for &mut StreamBufferPartialSettings
24845    {
24846        unsafe fn encode(
24847            self,
24848            encoder: &mut fidl::encoding::Encoder<
24849                '_,
24850                fidl::encoding::DefaultFuchsiaResourceDialect,
24851            >,
24852            offset: usize,
24853            mut depth: fidl::encoding::Depth,
24854        ) -> fidl::Result<()> {
24855            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
24856            // Vector header
24857            let max_ordinal: u64 = self.max_ordinal_present();
24858            encoder.write_num(max_ordinal, offset);
24859            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24860            // Calling encoder.out_of_line_offset(0) is not allowed.
24861            if max_ordinal == 0 {
24862                return Ok(());
24863            }
24864            depth.increment()?;
24865            let envelope_size = 8;
24866            let bytes_len = max_ordinal as usize * envelope_size;
24867            #[allow(unused_variables)]
24868            let offset = encoder.out_of_line_offset(bytes_len);
24869            let mut _prev_end_offset: usize = 0;
24870            if 1 > 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 = (1 - 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                u64,
24887                fidl::encoding::DefaultFuchsiaResourceDialect,
24888            >(
24889                self.buffer_lifetime_ordinal
24890                    .as_ref()
24891                    .map(<u64 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 2 > 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 = (2 - 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                u64,
24915                fidl::encoding::DefaultFuchsiaResourceDialect,
24916            >(
24917                self.buffer_constraints_version_ordinal
24918                    .as_ref()
24919                    .map(<u64 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 3 > 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 = (3 - 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                bool,
24943                fidl::encoding::DefaultFuchsiaResourceDialect,
24944            >(
24945                self.single_buffer_mode
24946                    .as_ref()
24947                    .map(<bool 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 4 > 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 = (4 - 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                u32,
24971                fidl::encoding::DefaultFuchsiaResourceDialect,
24972            >(
24973                self.packet_count_for_server
24974                    .as_ref()
24975                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24976                encoder,
24977                offset + cur_offset,
24978                depth,
24979            )?;
24980
24981            _prev_end_offset = cur_offset + envelope_size;
24982            if 5 > max_ordinal {
24983                return Ok(());
24984            }
24985
24986            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24987            // are envelope_size bytes.
24988            let cur_offset: usize = (5 - 1) * envelope_size;
24989
24990            // Zero reserved fields.
24991            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24992
24993            // Safety:
24994            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24995            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24996            //   envelope_size bytes, there is always sufficient room.
24997            fidl::encoding::encode_in_envelope_optional::<
24998                u32,
24999                fidl::encoding::DefaultFuchsiaResourceDialect,
25000            >(
25001                self.packet_count_for_client
25002                    .as_ref()
25003                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
25004                encoder,
25005                offset + cur_offset,
25006                depth,
25007            )?;
25008
25009            _prev_end_offset = cur_offset + envelope_size;
25010            if 6 > max_ordinal {
25011                return Ok(());
25012            }
25013
25014            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25015            // are envelope_size bytes.
25016            let cur_offset: usize = (6 - 1) * envelope_size;
25017
25018            // Zero reserved fields.
25019            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25020
25021            // Safety:
25022            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25023            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25024            //   envelope_size bytes, there is always sufficient room.
25025            fidl::encoding::encode_in_envelope_optional::<
25026                fidl::encoding::Endpoint<
25027                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25028                >,
25029                fidl::encoding::DefaultFuchsiaResourceDialect,
25030            >(
25031                self.sysmem_token.as_mut().map(
25032                    <fidl::encoding::Endpoint<
25033                        fidl::endpoints::ClientEnd<
25034                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25035                        >,
25036                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25037                ),
25038                encoder,
25039                offset + cur_offset,
25040                depth,
25041            )?;
25042
25043            _prev_end_offset = cur_offset + envelope_size;
25044            if 7 > max_ordinal {
25045                return Ok(());
25046            }
25047
25048            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
25049            // are envelope_size bytes.
25050            let cur_offset: usize = (7 - 1) * envelope_size;
25051
25052            // Zero reserved fields.
25053            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
25054
25055            // Safety:
25056            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
25057            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
25058            //   envelope_size bytes, there is always sufficient room.
25059            fidl::encoding::encode_in_envelope_optional::<
25060                fidl::encoding::Endpoint<
25061                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25062                >,
25063                fidl::encoding::DefaultFuchsiaResourceDialect,
25064            >(
25065                self.sysmem2_token.as_mut().map(
25066                    <fidl::encoding::Endpoint<
25067                        fidl::endpoints::ClientEnd<
25068                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25069                        >,
25070                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
25071                ),
25072                encoder,
25073                offset + cur_offset,
25074                depth,
25075            )?;
25076
25077            _prev_end_offset = cur_offset + envelope_size;
25078
25079            Ok(())
25080        }
25081    }
25082
25083    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25084        for StreamBufferPartialSettings
25085    {
25086        #[inline(always)]
25087        fn new_empty() -> Self {
25088            Self::default()
25089        }
25090
25091        unsafe fn decode(
25092            &mut self,
25093            decoder: &mut fidl::encoding::Decoder<
25094                '_,
25095                fidl::encoding::DefaultFuchsiaResourceDialect,
25096            >,
25097            offset: usize,
25098            mut depth: fidl::encoding::Depth,
25099        ) -> fidl::Result<()> {
25100            decoder.debug_check_bounds::<Self>(offset);
25101            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
25102                None => return Err(fidl::Error::NotNullable),
25103                Some(len) => len,
25104            };
25105            // Calling decoder.out_of_line_offset(0) is not allowed.
25106            if len == 0 {
25107                return Ok(());
25108            };
25109            depth.increment()?;
25110            let envelope_size = 8;
25111            let bytes_len = len * envelope_size;
25112            let offset = decoder.out_of_line_offset(bytes_len)?;
25113            // Decode the envelope for each type.
25114            let mut _next_ordinal_to_read = 0;
25115            let mut next_offset = offset;
25116            let end_offset = offset + bytes_len;
25117            _next_ordinal_to_read += 1;
25118            if next_offset >= end_offset {
25119                return Ok(());
25120            }
25121
25122            // Decode unknown envelopes for gaps in ordinals.
25123            while _next_ordinal_to_read < 1 {
25124                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25125                _next_ordinal_to_read += 1;
25126                next_offset += envelope_size;
25127            }
25128
25129            let next_out_of_line = decoder.next_out_of_line();
25130            let handles_before = decoder.remaining_handles();
25131            if let Some((inlined, num_bytes, num_handles)) =
25132                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25133            {
25134                let member_inline_size =
25135                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25136                if inlined != (member_inline_size <= 4) {
25137                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25138                }
25139                let inner_offset;
25140                let mut inner_depth = depth.clone();
25141                if inlined {
25142                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25143                    inner_offset = next_offset;
25144                } else {
25145                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25146                    inner_depth.increment()?;
25147                }
25148                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
25149                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25150                });
25151                fidl::decode!(
25152                    u64,
25153                    fidl::encoding::DefaultFuchsiaResourceDialect,
25154                    val_ref,
25155                    decoder,
25156                    inner_offset,
25157                    inner_depth
25158                )?;
25159                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25160                {
25161                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25162                }
25163                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25164                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25165                }
25166            }
25167
25168            next_offset += envelope_size;
25169            _next_ordinal_to_read += 1;
25170            if next_offset >= end_offset {
25171                return Ok(());
25172            }
25173
25174            // Decode unknown envelopes for gaps in ordinals.
25175            while _next_ordinal_to_read < 2 {
25176                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25177                _next_ordinal_to_read += 1;
25178                next_offset += envelope_size;
25179            }
25180
25181            let next_out_of_line = decoder.next_out_of_line();
25182            let handles_before = decoder.remaining_handles();
25183            if let Some((inlined, num_bytes, num_handles)) =
25184                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25185            {
25186                let member_inline_size =
25187                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25188                if inlined != (member_inline_size <= 4) {
25189                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25190                }
25191                let inner_offset;
25192                let mut inner_depth = depth.clone();
25193                if inlined {
25194                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25195                    inner_offset = next_offset;
25196                } else {
25197                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25198                    inner_depth.increment()?;
25199                }
25200                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
25201                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
25202                });
25203                fidl::decode!(
25204                    u64,
25205                    fidl::encoding::DefaultFuchsiaResourceDialect,
25206                    val_ref,
25207                    decoder,
25208                    inner_offset,
25209                    inner_depth
25210                )?;
25211                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25212                {
25213                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25214                }
25215                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25216                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25217                }
25218            }
25219
25220            next_offset += envelope_size;
25221            _next_ordinal_to_read += 1;
25222            if next_offset >= end_offset {
25223                return Ok(());
25224            }
25225
25226            // Decode unknown envelopes for gaps in ordinals.
25227            while _next_ordinal_to_read < 3 {
25228                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25229                _next_ordinal_to_read += 1;
25230                next_offset += envelope_size;
25231            }
25232
25233            let next_out_of_line = decoder.next_out_of_line();
25234            let handles_before = decoder.remaining_handles();
25235            if let Some((inlined, num_bytes, num_handles)) =
25236                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25237            {
25238                let member_inline_size =
25239                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25240                if inlined != (member_inline_size <= 4) {
25241                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25242                }
25243                let inner_offset;
25244                let mut inner_depth = depth.clone();
25245                if inlined {
25246                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25247                    inner_offset = next_offset;
25248                } else {
25249                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25250                    inner_depth.increment()?;
25251                }
25252                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
25253                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
25254                });
25255                fidl::decode!(
25256                    bool,
25257                    fidl::encoding::DefaultFuchsiaResourceDialect,
25258                    val_ref,
25259                    decoder,
25260                    inner_offset,
25261                    inner_depth
25262                )?;
25263                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25264                {
25265                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25266                }
25267                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25268                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25269                }
25270            }
25271
25272            next_offset += envelope_size;
25273            _next_ordinal_to_read += 1;
25274            if next_offset >= end_offset {
25275                return Ok(());
25276            }
25277
25278            // Decode unknown envelopes for gaps in ordinals.
25279            while _next_ordinal_to_read < 4 {
25280                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25281                _next_ordinal_to_read += 1;
25282                next_offset += envelope_size;
25283            }
25284
25285            let next_out_of_line = decoder.next_out_of_line();
25286            let handles_before = decoder.remaining_handles();
25287            if let Some((inlined, num_bytes, num_handles)) =
25288                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25289            {
25290                let member_inline_size =
25291                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25292                if inlined != (member_inline_size <= 4) {
25293                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25294                }
25295                let inner_offset;
25296                let mut inner_depth = depth.clone();
25297                if inlined {
25298                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25299                    inner_offset = next_offset;
25300                } else {
25301                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25302                    inner_depth.increment()?;
25303                }
25304                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
25305                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25306                });
25307                fidl::decode!(
25308                    u32,
25309                    fidl::encoding::DefaultFuchsiaResourceDialect,
25310                    val_ref,
25311                    decoder,
25312                    inner_offset,
25313                    inner_depth
25314                )?;
25315                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25316                {
25317                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25318                }
25319                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25320                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25321                }
25322            }
25323
25324            next_offset += envelope_size;
25325            _next_ordinal_to_read += 1;
25326            if next_offset >= end_offset {
25327                return Ok(());
25328            }
25329
25330            // Decode unknown envelopes for gaps in ordinals.
25331            while _next_ordinal_to_read < 5 {
25332                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25333                _next_ordinal_to_read += 1;
25334                next_offset += envelope_size;
25335            }
25336
25337            let next_out_of_line = decoder.next_out_of_line();
25338            let handles_before = decoder.remaining_handles();
25339            if let Some((inlined, num_bytes, num_handles)) =
25340                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25341            {
25342                let member_inline_size =
25343                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
25344                if inlined != (member_inline_size <= 4) {
25345                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25346                }
25347                let inner_offset;
25348                let mut inner_depth = depth.clone();
25349                if inlined {
25350                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25351                    inner_offset = next_offset;
25352                } else {
25353                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25354                    inner_depth.increment()?;
25355                }
25356                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
25357                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
25358                });
25359                fidl::decode!(
25360                    u32,
25361                    fidl::encoding::DefaultFuchsiaResourceDialect,
25362                    val_ref,
25363                    decoder,
25364                    inner_offset,
25365                    inner_depth
25366                )?;
25367                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25368                {
25369                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25370                }
25371                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25372                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25373                }
25374            }
25375
25376            next_offset += envelope_size;
25377            _next_ordinal_to_read += 1;
25378            if next_offset >= end_offset {
25379                return Ok(());
25380            }
25381
25382            // Decode unknown envelopes for gaps in ordinals.
25383            while _next_ordinal_to_read < 6 {
25384                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25385                _next_ordinal_to_read += 1;
25386                next_offset += envelope_size;
25387            }
25388
25389            let next_out_of_line = decoder.next_out_of_line();
25390            let handles_before = decoder.remaining_handles();
25391            if let Some((inlined, num_bytes, num_handles)) =
25392                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25393            {
25394                let member_inline_size = <fidl::encoding::Endpoint<
25395                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
25396                > as fidl::encoding::TypeMarker>::inline_size(
25397                    decoder.context
25398                );
25399                if inlined != (member_inline_size <= 4) {
25400                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25401                }
25402                let inner_offset;
25403                let mut inner_depth = depth.clone();
25404                if inlined {
25405                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25406                    inner_offset = next_offset;
25407                } else {
25408                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25409                    inner_depth.increment()?;
25410                }
25411                let val_ref = self.sysmem_token.get_or_insert_with(|| {
25412                    fidl::new_empty!(
25413                        fidl::encoding::Endpoint<
25414                            fidl::endpoints::ClientEnd<
25415                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25416                            >,
25417                        >,
25418                        fidl::encoding::DefaultFuchsiaResourceDialect
25419                    )
25420                });
25421                fidl::decode!(
25422                    fidl::encoding::Endpoint<
25423                        fidl::endpoints::ClientEnd<
25424                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
25425                        >,
25426                    >,
25427                    fidl::encoding::DefaultFuchsiaResourceDialect,
25428                    val_ref,
25429                    decoder,
25430                    inner_offset,
25431                    inner_depth
25432                )?;
25433                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25434                {
25435                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25436                }
25437                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25438                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25439                }
25440            }
25441
25442            next_offset += envelope_size;
25443            _next_ordinal_to_read += 1;
25444            if next_offset >= end_offset {
25445                return Ok(());
25446            }
25447
25448            // Decode unknown envelopes for gaps in ordinals.
25449            while _next_ordinal_to_read < 7 {
25450                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25451                _next_ordinal_to_read += 1;
25452                next_offset += envelope_size;
25453            }
25454
25455            let next_out_of_line = decoder.next_out_of_line();
25456            let handles_before = decoder.remaining_handles();
25457            if let Some((inlined, num_bytes, num_handles)) =
25458                fidl::encoding::decode_envelope_header(decoder, next_offset)?
25459            {
25460                let member_inline_size = <fidl::encoding::Endpoint<
25461                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
25462                > as fidl::encoding::TypeMarker>::inline_size(
25463                    decoder.context
25464                );
25465                if inlined != (member_inline_size <= 4) {
25466                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
25467                }
25468                let inner_offset;
25469                let mut inner_depth = depth.clone();
25470                if inlined {
25471                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
25472                    inner_offset = next_offset;
25473                } else {
25474                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
25475                    inner_depth.increment()?;
25476                }
25477                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
25478                    fidl::new_empty!(
25479                        fidl::encoding::Endpoint<
25480                            fidl::endpoints::ClientEnd<
25481                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25482                            >,
25483                        >,
25484                        fidl::encoding::DefaultFuchsiaResourceDialect
25485                    )
25486                });
25487                fidl::decode!(
25488                    fidl::encoding::Endpoint<
25489                        fidl::endpoints::ClientEnd<
25490                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
25491                        >,
25492                    >,
25493                    fidl::encoding::DefaultFuchsiaResourceDialect,
25494                    val_ref,
25495                    decoder,
25496                    inner_offset,
25497                    inner_depth
25498                )?;
25499                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
25500                {
25501                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
25502                }
25503                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
25504                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
25505                }
25506            }
25507
25508            next_offset += envelope_size;
25509
25510            // Decode the remaining unknown envelopes.
25511            while next_offset < end_offset {
25512                _next_ordinal_to_read += 1;
25513                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
25514                next_offset += envelope_size;
25515            }
25516
25517            Ok(())
25518        }
25519    }
25520}