Skip to main content

fidl_fuchsia_audio_controller/
fidl_fuchsia_audio_controller.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_audio_controller_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct DeviceControlDeviceSetGainStateRequest {
16    /// Id of the device to set the gain state.
17    ///
18    /// Required.
19    pub device: Option<DeviceSelector>,
20    /// Desired gain state.
21    ///
22    /// Required.
23    pub gain_state: Option<fidl_fuchsia_hardware_audio::GainState>,
24    #[doc(hidden)]
25    pub __source_breaking: fidl::marker::SourceBreaking,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
29    for DeviceControlDeviceSetGainStateRequest
30{
31}
32
33#[derive(Debug, Default, PartialEq)]
34pub struct PlayerPlayRequest {
35    /// Socket for the client to send audio data in WAV format.
36    ///
37    /// The client should transmit an entire file, then close the socket.
38    ///
39    /// Required.
40    pub wav_source: Option<fidl::Socket>,
41    /// The destination to which to play the audio.
42    ///
43    /// Required.
44    pub destination: Option<PlayDestination>,
45    /// Play settings.
46    ///
47    /// Optional. If not specified, use unity gain unmuted, and no other gain
48    /// processing enabled.
49    pub gain_settings: Option<GainSettings>,
50    /// Channels to enable during playback.
51    ///
52    /// Optional. If not specified, the active-channels configuration is not changed.
53    pub active_channels_bitmask: Option<u64>,
54    #[doc(hidden)]
55    pub __source_breaking: fidl::marker::SourceBreaking,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PlayerPlayRequest {}
59
60#[derive(Debug, Default, PartialEq)]
61pub struct PlayerPlayResponse {
62    /// Total number of bytes sent to destination.
63    pub bytes_processed: Option<u64>,
64    #[doc(hidden)]
65    pub __source_breaking: fidl::marker::SourceBreaking,
66}
67
68impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PlayerPlayResponse {}
69
70#[derive(Debug, Default, PartialEq)]
71pub struct RecorderRecordRequest {
72    /// The source from which to record the audio.
73    ///
74    /// Required.
75    pub source: Option<RecordSource>,
76    /// The stream format in which to record the audio.
77    ///
78    /// Required.
79    pub stream_type: Option<fidl_fuchsia_media::AudioStreamType>,
80    /// Duration in nanoseconds to record audio data.
81    ///
82    /// If not specified, `Recorder` will record and write data to the
83    /// socket until it receives a stop signal on `canceler`.
84    ///
85    /// If present, the record request is still cancelable via `canceler`.
86    ///
87    /// Optional.
88    pub duration: Option<i64>,
89    /// Handle to signal when to stop sending data back to the client.
90    ///
91    /// Required.
92    pub canceler: Option<fidl::endpoints::ServerEnd<RecordCancelerMarker>>,
93    /// Record gain settings.
94    ///
95    /// Only used for the `capturer` and `loopback` sources.
96    ///
97    /// Optional.
98    pub gain_settings: Option<GainSettings>,
99    /// Buffer size.
100    ///
101    /// Optional. If not specified, defaults to a size that is enough to
102    /// hold one second of audio data.
103    pub buffer_size: Option<u64>,
104    /// Sink for audio data.
105    ///
106    /// The captured data here will be written here as a complete WAV file.
107    ///
108    /// Required.
109    pub wav_data: Option<fidl::Socket>,
110    #[doc(hidden)]
111    pub __source_breaking: fidl::marker::SourceBreaking,
112}
113
114impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RecorderRecordRequest {}
115
116#[derive(Debug, Default, PartialEq)]
117pub struct RecorderRecordResponse {
118    /// Total number of bytes read from the source.
119    pub bytes_processed: Option<u64>,
120    /// If applicable, number of packets read from an `AudioCapturer`.
121    pub packets_processed: Option<u64>,
122    /// If applicable, number of times the capturer woke up too late to
123    /// read valid data from the device.
124    ///
125    /// If this is non-zero, some data was lost and replaced with silence.
126    pub late_wakeups: Option<u64>,
127    #[doc(hidden)]
128    pub __source_breaking: fidl::marker::SourceBreaking,
129}
130
131impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RecorderRecordResponse {}
132
133#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
134pub struct DeviceControlMarker;
135
136impl fidl::endpoints::ProtocolMarker for DeviceControlMarker {
137    type Proxy = DeviceControlProxy;
138    type RequestStream = DeviceControlRequestStream;
139    #[cfg(target_os = "fuchsia")]
140    type SynchronousProxy = DeviceControlSynchronousProxy;
141
142    const DEBUG_NAME: &'static str = "fuchsia.audio.controller.DeviceControl";
143}
144impl fidl::endpoints::DiscoverableProtocolMarker for DeviceControlMarker {}
145pub type DeviceControlDeviceSetGainStateResult = Result<(), i32>;
146
147pub trait DeviceControlProxyInterface: Send + Sync {
148    type DeviceSetGainStateResponseFut: std::future::Future<Output = Result<DeviceControlDeviceSetGainStateResult, fidl::Error>>
149        + Send;
150    fn r#device_set_gain_state(
151        &self,
152        payload: DeviceControlDeviceSetGainStateRequest,
153    ) -> Self::DeviceSetGainStateResponseFut;
154}
155#[derive(Debug)]
156#[cfg(target_os = "fuchsia")]
157pub struct DeviceControlSynchronousProxy {
158    client: fidl::client::sync::Client,
159}
160
161#[cfg(target_os = "fuchsia")]
162impl fidl::endpoints::SynchronousProxy for DeviceControlSynchronousProxy {
163    type Proxy = DeviceControlProxy;
164    type Protocol = DeviceControlMarker;
165
166    fn from_channel(inner: fidl::Channel) -> Self {
167        Self::new(inner)
168    }
169
170    fn into_channel(self) -> fidl::Channel {
171        self.client.into_channel()
172    }
173
174    fn as_channel(&self) -> &fidl::Channel {
175        self.client.as_channel()
176    }
177}
178
179#[cfg(target_os = "fuchsia")]
180impl DeviceControlSynchronousProxy {
181    pub fn new(channel: fidl::Channel) -> Self {
182        Self { client: fidl::client::sync::Client::new(channel) }
183    }
184
185    pub fn into_channel(self) -> fidl::Channel {
186        self.client.into_channel()
187    }
188
189    /// Waits until an event arrives and returns it. It is safe for other
190    /// threads to make concurrent requests while waiting for an event.
191    pub fn wait_for_event(
192        &self,
193        deadline: zx::MonotonicInstant,
194    ) -> Result<DeviceControlEvent, fidl::Error> {
195        DeviceControlEvent::decode(self.client.wait_for_event::<DeviceControlMarker>(deadline)?)
196    }
197
198    /// Sets the gain of the stream in decibels.
199    pub fn r#device_set_gain_state(
200        &self,
201        mut payload: DeviceControlDeviceSetGainStateRequest,
202        ___deadline: zx::MonotonicInstant,
203    ) -> Result<DeviceControlDeviceSetGainStateResult, fidl::Error> {
204        let _response = self.client.send_query::<
205            DeviceControlDeviceSetGainStateRequest,
206            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
207            DeviceControlMarker,
208        >(
209            &mut payload,
210            0x7c5c028bb8c42d12,
211            fidl::encoding::DynamicFlags::FLEXIBLE,
212            ___deadline,
213        )?
214        .into_result::<DeviceControlMarker>("device_set_gain_state")?;
215        Ok(_response.map(|x| x))
216    }
217}
218
219#[cfg(target_os = "fuchsia")]
220impl From<DeviceControlSynchronousProxy> for zx::NullableHandle {
221    fn from(value: DeviceControlSynchronousProxy) -> Self {
222        value.into_channel().into()
223    }
224}
225
226#[cfg(target_os = "fuchsia")]
227impl From<fidl::Channel> for DeviceControlSynchronousProxy {
228    fn from(value: fidl::Channel) -> Self {
229        Self::new(value)
230    }
231}
232
233#[cfg(target_os = "fuchsia")]
234impl fidl::endpoints::FromClient for DeviceControlSynchronousProxy {
235    type Protocol = DeviceControlMarker;
236
237    fn from_client(value: fidl::endpoints::ClientEnd<DeviceControlMarker>) -> Self {
238        Self::new(value.into_channel())
239    }
240}
241
242#[derive(Debug, Clone)]
243pub struct DeviceControlProxy {
244    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
245}
246
247impl fidl::endpoints::Proxy for DeviceControlProxy {
248    type Protocol = DeviceControlMarker;
249
250    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
251        Self::new(inner)
252    }
253
254    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
255        self.client.into_channel().map_err(|client| Self { client })
256    }
257
258    fn as_channel(&self) -> &::fidl::AsyncChannel {
259        self.client.as_channel()
260    }
261}
262
263impl DeviceControlProxy {
264    /// Create a new Proxy for fuchsia.audio.controller/DeviceControl.
265    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
266        let protocol_name = <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
267        Self { client: fidl::client::Client::new(channel, protocol_name) }
268    }
269
270    /// Get a Stream of events from the remote end of the protocol.
271    ///
272    /// # Panics
273    ///
274    /// Panics if the event stream was already taken.
275    pub fn take_event_stream(&self) -> DeviceControlEventStream {
276        DeviceControlEventStream { event_receiver: self.client.take_event_receiver() }
277    }
278
279    /// Sets the gain of the stream in decibels.
280    pub fn r#device_set_gain_state(
281        &self,
282        mut payload: DeviceControlDeviceSetGainStateRequest,
283    ) -> fidl::client::QueryResponseFut<
284        DeviceControlDeviceSetGainStateResult,
285        fidl::encoding::DefaultFuchsiaResourceDialect,
286    > {
287        DeviceControlProxyInterface::r#device_set_gain_state(self, payload)
288    }
289}
290
291impl DeviceControlProxyInterface for DeviceControlProxy {
292    type DeviceSetGainStateResponseFut = fidl::client::QueryResponseFut<
293        DeviceControlDeviceSetGainStateResult,
294        fidl::encoding::DefaultFuchsiaResourceDialect,
295    >;
296    fn r#device_set_gain_state(
297        &self,
298        mut payload: DeviceControlDeviceSetGainStateRequest,
299    ) -> Self::DeviceSetGainStateResponseFut {
300        fn _decode(
301            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
302        ) -> Result<DeviceControlDeviceSetGainStateResult, fidl::Error> {
303            let _response = fidl::client::decode_transaction_body::<
304                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
305                fidl::encoding::DefaultFuchsiaResourceDialect,
306                0x7c5c028bb8c42d12,
307            >(_buf?)?
308            .into_result::<DeviceControlMarker>("device_set_gain_state")?;
309            Ok(_response.map(|x| x))
310        }
311        self.client.send_query_and_decode::<
312            DeviceControlDeviceSetGainStateRequest,
313            DeviceControlDeviceSetGainStateResult,
314        >(
315            &mut payload,
316            0x7c5c028bb8c42d12,
317            fidl::encoding::DynamicFlags::FLEXIBLE,
318            _decode,
319        )
320    }
321}
322
323pub struct DeviceControlEventStream {
324    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
325}
326
327impl std::marker::Unpin for DeviceControlEventStream {}
328
329impl futures::stream::FusedStream for DeviceControlEventStream {
330    fn is_terminated(&self) -> bool {
331        self.event_receiver.is_terminated()
332    }
333}
334
335impl futures::Stream for DeviceControlEventStream {
336    type Item = Result<DeviceControlEvent, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
343            &mut self.event_receiver,
344            cx
345        )?) {
346            Some(buf) => std::task::Poll::Ready(Some(DeviceControlEvent::decode(buf))),
347            None => std::task::Poll::Ready(None),
348        }
349    }
350}
351
352#[derive(Debug)]
353pub enum DeviceControlEvent {
354    #[non_exhaustive]
355    _UnknownEvent {
356        /// Ordinal of the event that was sent.
357        ordinal: u64,
358    },
359}
360
361impl DeviceControlEvent {
362    /// Decodes a message buffer as a [`DeviceControlEvent`].
363    fn decode(
364        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
365    ) -> Result<DeviceControlEvent, fidl::Error> {
366        let (bytes, _handles) = buf.split_mut();
367        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
368        debug_assert_eq!(tx_header.tx_id, 0);
369        match tx_header.ordinal {
370            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
371                Ok(DeviceControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
372            }
373            _ => Err(fidl::Error::UnknownOrdinal {
374                ordinal: tx_header.ordinal,
375                protocol_name: <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
376            }),
377        }
378    }
379}
380
381/// A Stream of incoming requests for fuchsia.audio.controller/DeviceControl.
382pub struct DeviceControlRequestStream {
383    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
384    is_terminated: bool,
385}
386
387impl std::marker::Unpin for DeviceControlRequestStream {}
388
389impl futures::stream::FusedStream for DeviceControlRequestStream {
390    fn is_terminated(&self) -> bool {
391        self.is_terminated
392    }
393}
394
395impl fidl::endpoints::RequestStream for DeviceControlRequestStream {
396    type Protocol = DeviceControlMarker;
397    type ControlHandle = DeviceControlControlHandle;
398
399    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
400        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
401    }
402
403    fn control_handle(&self) -> Self::ControlHandle {
404        DeviceControlControlHandle { inner: self.inner.clone() }
405    }
406
407    fn into_inner(
408        self,
409    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
410    {
411        (self.inner, self.is_terminated)
412    }
413
414    fn from_inner(
415        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
416        is_terminated: bool,
417    ) -> Self {
418        Self { inner, is_terminated }
419    }
420}
421
422impl futures::Stream for DeviceControlRequestStream {
423    type Item = Result<DeviceControlRequest, fidl::Error>;
424
425    fn poll_next(
426        mut self: std::pin::Pin<&mut Self>,
427        cx: &mut std::task::Context<'_>,
428    ) -> std::task::Poll<Option<Self::Item>> {
429        let this = &mut *self;
430        if this.inner.check_shutdown(cx) {
431            this.is_terminated = true;
432            return std::task::Poll::Ready(None);
433        }
434        if this.is_terminated {
435            panic!("polled DeviceControlRequestStream after completion");
436        }
437        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
438            |bytes, handles| {
439                match this.inner.channel().read_etc(cx, bytes, handles) {
440                    std::task::Poll::Ready(Ok(())) => {}
441                    std::task::Poll::Pending => return std::task::Poll::Pending,
442                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
443                        this.is_terminated = true;
444                        return std::task::Poll::Ready(None);
445                    }
446                    std::task::Poll::Ready(Err(e)) => {
447                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
448                            e.into(),
449                        ))));
450                    }
451                }
452
453                // A message has been received from the channel
454                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
455
456                std::task::Poll::Ready(Some(match header.ordinal {
457                    0x7c5c028bb8c42d12 => {
458                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
459                        let mut req = fidl::new_empty!(
460                            DeviceControlDeviceSetGainStateRequest,
461                            fidl::encoding::DefaultFuchsiaResourceDialect
462                        );
463                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceControlDeviceSetGainStateRequest>(&header, _body_bytes, handles, &mut req)?;
464                        let control_handle =
465                            DeviceControlControlHandle { inner: this.inner.clone() };
466                        Ok(DeviceControlRequest::DeviceSetGainState {
467                            payload: req,
468                            responder: DeviceControlDeviceSetGainStateResponder {
469                                control_handle: std::mem::ManuallyDrop::new(control_handle),
470                                tx_id: header.tx_id,
471                            },
472                        })
473                    }
474                    _ if header.tx_id == 0
475                        && header
476                            .dynamic_flags()
477                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
478                    {
479                        Ok(DeviceControlRequest::_UnknownMethod {
480                            ordinal: header.ordinal,
481                            control_handle: DeviceControlControlHandle {
482                                inner: this.inner.clone(),
483                            },
484                            method_type: fidl::MethodType::OneWay,
485                        })
486                    }
487                    _ if header
488                        .dynamic_flags()
489                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
490                    {
491                        this.inner.send_framework_err(
492                            fidl::encoding::FrameworkErr::UnknownMethod,
493                            header.tx_id,
494                            header.ordinal,
495                            header.dynamic_flags(),
496                            (bytes, handles),
497                        )?;
498                        Ok(DeviceControlRequest::_UnknownMethod {
499                            ordinal: header.ordinal,
500                            control_handle: DeviceControlControlHandle {
501                                inner: this.inner.clone(),
502                            },
503                            method_type: fidl::MethodType::TwoWay,
504                        })
505                    }
506                    _ => Err(fidl::Error::UnknownOrdinal {
507                        ordinal: header.ordinal,
508                        protocol_name:
509                            <DeviceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
510                    }),
511                }))
512            },
513        )
514    }
515}
516
517/// Enumerate, query, and control audio devices from clients.
518#[derive(Debug)]
519pub enum DeviceControlRequest {
520    /// Sets the gain of the stream in decibels.
521    DeviceSetGainState {
522        payload: DeviceControlDeviceSetGainStateRequest,
523        responder: DeviceControlDeviceSetGainStateResponder,
524    },
525    /// An interaction was received which does not match any known method.
526    #[non_exhaustive]
527    _UnknownMethod {
528        /// Ordinal of the method that was called.
529        ordinal: u64,
530        control_handle: DeviceControlControlHandle,
531        method_type: fidl::MethodType,
532    },
533}
534
535impl DeviceControlRequest {
536    #[allow(irrefutable_let_patterns)]
537    pub fn into_device_set_gain_state(
538        self,
539    ) -> Option<(DeviceControlDeviceSetGainStateRequest, DeviceControlDeviceSetGainStateResponder)>
540    {
541        if let DeviceControlRequest::DeviceSetGainState { payload, responder } = self {
542            Some((payload, responder))
543        } else {
544            None
545        }
546    }
547
548    /// Name of the method defined in FIDL
549    pub fn method_name(&self) -> &'static str {
550        match *self {
551            DeviceControlRequest::DeviceSetGainState { .. } => "device_set_gain_state",
552            DeviceControlRequest::_UnknownMethod {
553                method_type: fidl::MethodType::OneWay, ..
554            } => "unknown one-way method",
555            DeviceControlRequest::_UnknownMethod {
556                method_type: fidl::MethodType::TwoWay, ..
557            } => "unknown two-way method",
558        }
559    }
560}
561
562#[derive(Debug, Clone)]
563pub struct DeviceControlControlHandle {
564    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
565}
566
567impl DeviceControlControlHandle {
568    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
569        self.inner.shutdown_with_epitaph(status.into())
570    }
571}
572
573impl fidl::endpoints::ControlHandle for DeviceControlControlHandle {
574    fn shutdown(&self) {
575        self.inner.shutdown()
576    }
577
578    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
579        self.inner.shutdown_with_epitaph(status)
580    }
581
582    fn is_closed(&self) -> bool {
583        self.inner.channel().is_closed()
584    }
585    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
586        self.inner.channel().on_closed()
587    }
588
589    #[cfg(target_os = "fuchsia")]
590    fn signal_peer(
591        &self,
592        clear_mask: zx::Signals,
593        set_mask: zx::Signals,
594    ) -> Result<(), zx_status::Status> {
595        use fidl::Peered;
596        self.inner.channel().signal_peer(clear_mask, set_mask)
597    }
598}
599
600impl DeviceControlControlHandle {}
601
602#[must_use = "FIDL methods require a response to be sent"]
603#[derive(Debug)]
604pub struct DeviceControlDeviceSetGainStateResponder {
605    control_handle: std::mem::ManuallyDrop<DeviceControlControlHandle>,
606    tx_id: u32,
607}
608
609/// Set the the channel to be shutdown (see [`DeviceControlControlHandle::shutdown`])
610/// if the responder is dropped without sending a response, so that the client
611/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
612impl std::ops::Drop for DeviceControlDeviceSetGainStateResponder {
613    fn drop(&mut self) {
614        self.control_handle.shutdown();
615        // Safety: drops once, never accessed again
616        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
617    }
618}
619
620impl fidl::endpoints::Responder for DeviceControlDeviceSetGainStateResponder {
621    type ControlHandle = DeviceControlControlHandle;
622
623    fn control_handle(&self) -> &DeviceControlControlHandle {
624        &self.control_handle
625    }
626
627    fn drop_without_shutdown(mut self) {
628        // Safety: drops once, never accessed again due to mem::forget
629        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
630        // Prevent Drop from running (which would shut down the channel)
631        std::mem::forget(self);
632    }
633}
634
635impl DeviceControlDeviceSetGainStateResponder {
636    /// Sends a response to the FIDL transaction.
637    ///
638    /// Sets the channel to shutdown if an error occurs.
639    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
640        let _result = self.send_raw(result);
641        if _result.is_err() {
642            self.control_handle.shutdown();
643        }
644        self.drop_without_shutdown();
645        _result
646    }
647
648    /// Similar to "send" but does not shutdown the channel if an error occurs.
649    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
650        let _result = self.send_raw(result);
651        self.drop_without_shutdown();
652        _result
653    }
654
655    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
656        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
657            fidl::encoding::EmptyStruct,
658            i32,
659        >>(
660            fidl::encoding::FlexibleResult::new(result),
661            self.tx_id,
662            0x7c5c028bb8c42d12,
663            fidl::encoding::DynamicFlags::FLEXIBLE,
664        )
665    }
666}
667
668#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
669pub struct PlayerMarker;
670
671impl fidl::endpoints::ProtocolMarker for PlayerMarker {
672    type Proxy = PlayerProxy;
673    type RequestStream = PlayerRequestStream;
674    #[cfg(target_os = "fuchsia")]
675    type SynchronousProxy = PlayerSynchronousProxy;
676
677    const DEBUG_NAME: &'static str = "fuchsia.audio.controller.Player";
678}
679impl fidl::endpoints::DiscoverableProtocolMarker for PlayerMarker {}
680pub type PlayerPlayResult = Result<PlayerPlayResponse, Error>;
681
682pub trait PlayerProxyInterface: Send + Sync {
683    type PlayResponseFut: std::future::Future<Output = Result<PlayerPlayResult, fidl::Error>> + Send;
684    fn r#play(&self, payload: PlayerPlayRequest) -> Self::PlayResponseFut;
685}
686#[derive(Debug)]
687#[cfg(target_os = "fuchsia")]
688pub struct PlayerSynchronousProxy {
689    client: fidl::client::sync::Client,
690}
691
692#[cfg(target_os = "fuchsia")]
693impl fidl::endpoints::SynchronousProxy for PlayerSynchronousProxy {
694    type Proxy = PlayerProxy;
695    type Protocol = PlayerMarker;
696
697    fn from_channel(inner: fidl::Channel) -> Self {
698        Self::new(inner)
699    }
700
701    fn into_channel(self) -> fidl::Channel {
702        self.client.into_channel()
703    }
704
705    fn as_channel(&self) -> &fidl::Channel {
706        self.client.as_channel()
707    }
708}
709
710#[cfg(target_os = "fuchsia")]
711impl PlayerSynchronousProxy {
712    pub fn new(channel: fidl::Channel) -> Self {
713        Self { client: fidl::client::sync::Client::new(channel) }
714    }
715
716    pub fn into_channel(self) -> fidl::Channel {
717        self.client.into_channel()
718    }
719
720    /// Waits until an event arrives and returns it. It is safe for other
721    /// threads to make concurrent requests while waiting for an event.
722    pub fn wait_for_event(
723        &self,
724        deadline: zx::MonotonicInstant,
725    ) -> Result<PlayerEvent, fidl::Error> {
726        PlayerEvent::decode(self.client.wait_for_event::<PlayerMarker>(deadline)?)
727    }
728
729    /// Read audio data from a socket in WAV format and play it to a destination.
730    ///
731    /// Returns when all bytes have been read from the socket.
732    pub fn r#play(
733        &self,
734        mut payload: PlayerPlayRequest,
735        ___deadline: zx::MonotonicInstant,
736    ) -> Result<PlayerPlayResult, fidl::Error> {
737        let _response = self.client.send_query::<
738            PlayerPlayRequest,
739            fidl::encoding::FlexibleResultType<PlayerPlayResponse, Error>,
740            PlayerMarker,
741        >(
742            &mut payload,
743            0x1e63779971512042,
744            fidl::encoding::DynamicFlags::FLEXIBLE,
745            ___deadline,
746        )?
747        .into_result::<PlayerMarker>("play")?;
748        Ok(_response.map(|x| x))
749    }
750}
751
752#[cfg(target_os = "fuchsia")]
753impl From<PlayerSynchronousProxy> for zx::NullableHandle {
754    fn from(value: PlayerSynchronousProxy) -> Self {
755        value.into_channel().into()
756    }
757}
758
759#[cfg(target_os = "fuchsia")]
760impl From<fidl::Channel> for PlayerSynchronousProxy {
761    fn from(value: fidl::Channel) -> Self {
762        Self::new(value)
763    }
764}
765
766#[cfg(target_os = "fuchsia")]
767impl fidl::endpoints::FromClient for PlayerSynchronousProxy {
768    type Protocol = PlayerMarker;
769
770    fn from_client(value: fidl::endpoints::ClientEnd<PlayerMarker>) -> Self {
771        Self::new(value.into_channel())
772    }
773}
774
775#[derive(Debug, Clone)]
776pub struct PlayerProxy {
777    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
778}
779
780impl fidl::endpoints::Proxy for PlayerProxy {
781    type Protocol = PlayerMarker;
782
783    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
784        Self::new(inner)
785    }
786
787    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
788        self.client.into_channel().map_err(|client| Self { client })
789    }
790
791    fn as_channel(&self) -> &::fidl::AsyncChannel {
792        self.client.as_channel()
793    }
794}
795
796impl PlayerProxy {
797    /// Create a new Proxy for fuchsia.audio.controller/Player.
798    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
799        let protocol_name = <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
800        Self { client: fidl::client::Client::new(channel, protocol_name) }
801    }
802
803    /// Get a Stream of events from the remote end of the protocol.
804    ///
805    /// # Panics
806    ///
807    /// Panics if the event stream was already taken.
808    pub fn take_event_stream(&self) -> PlayerEventStream {
809        PlayerEventStream { event_receiver: self.client.take_event_receiver() }
810    }
811
812    /// Read audio data from a socket in WAV format and play it to a destination.
813    ///
814    /// Returns when all bytes have been read from the socket.
815    pub fn r#play(
816        &self,
817        mut payload: PlayerPlayRequest,
818    ) -> fidl::client::QueryResponseFut<
819        PlayerPlayResult,
820        fidl::encoding::DefaultFuchsiaResourceDialect,
821    > {
822        PlayerProxyInterface::r#play(self, payload)
823    }
824}
825
826impl PlayerProxyInterface for PlayerProxy {
827    type PlayResponseFut = fidl::client::QueryResponseFut<
828        PlayerPlayResult,
829        fidl::encoding::DefaultFuchsiaResourceDialect,
830    >;
831    fn r#play(&self, mut payload: PlayerPlayRequest) -> Self::PlayResponseFut {
832        fn _decode(
833            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
834        ) -> Result<PlayerPlayResult, fidl::Error> {
835            let _response = fidl::client::decode_transaction_body::<
836                fidl::encoding::FlexibleResultType<PlayerPlayResponse, Error>,
837                fidl::encoding::DefaultFuchsiaResourceDialect,
838                0x1e63779971512042,
839            >(_buf?)?
840            .into_result::<PlayerMarker>("play")?;
841            Ok(_response.map(|x| x))
842        }
843        self.client.send_query_and_decode::<PlayerPlayRequest, PlayerPlayResult>(
844            &mut payload,
845            0x1e63779971512042,
846            fidl::encoding::DynamicFlags::FLEXIBLE,
847            _decode,
848        )
849    }
850}
851
852pub struct PlayerEventStream {
853    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
854}
855
856impl std::marker::Unpin for PlayerEventStream {}
857
858impl futures::stream::FusedStream for PlayerEventStream {
859    fn is_terminated(&self) -> bool {
860        self.event_receiver.is_terminated()
861    }
862}
863
864impl futures::Stream for PlayerEventStream {
865    type Item = Result<PlayerEvent, fidl::Error>;
866
867    fn poll_next(
868        mut self: std::pin::Pin<&mut Self>,
869        cx: &mut std::task::Context<'_>,
870    ) -> std::task::Poll<Option<Self::Item>> {
871        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
872            &mut self.event_receiver,
873            cx
874        )?) {
875            Some(buf) => std::task::Poll::Ready(Some(PlayerEvent::decode(buf))),
876            None => std::task::Poll::Ready(None),
877        }
878    }
879}
880
881#[derive(Debug)]
882pub enum PlayerEvent {
883    #[non_exhaustive]
884    _UnknownEvent {
885        /// Ordinal of the event that was sent.
886        ordinal: u64,
887    },
888}
889
890impl PlayerEvent {
891    /// Decodes a message buffer as a [`PlayerEvent`].
892    fn decode(
893        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
894    ) -> Result<PlayerEvent, fidl::Error> {
895        let (bytes, _handles) = buf.split_mut();
896        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
897        debug_assert_eq!(tx_header.tx_id, 0);
898        match tx_header.ordinal {
899            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
900                Ok(PlayerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
901            }
902            _ => Err(fidl::Error::UnknownOrdinal {
903                ordinal: tx_header.ordinal,
904                protocol_name: <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
905            }),
906        }
907    }
908}
909
910/// A Stream of incoming requests for fuchsia.audio.controller/Player.
911pub struct PlayerRequestStream {
912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
913    is_terminated: bool,
914}
915
916impl std::marker::Unpin for PlayerRequestStream {}
917
918impl futures::stream::FusedStream for PlayerRequestStream {
919    fn is_terminated(&self) -> bool {
920        self.is_terminated
921    }
922}
923
924impl fidl::endpoints::RequestStream for PlayerRequestStream {
925    type Protocol = PlayerMarker;
926    type ControlHandle = PlayerControlHandle;
927
928    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
929        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
930    }
931
932    fn control_handle(&self) -> Self::ControlHandle {
933        PlayerControlHandle { inner: self.inner.clone() }
934    }
935
936    fn into_inner(
937        self,
938    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
939    {
940        (self.inner, self.is_terminated)
941    }
942
943    fn from_inner(
944        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
945        is_terminated: bool,
946    ) -> Self {
947        Self { inner, is_terminated }
948    }
949}
950
951impl futures::Stream for PlayerRequestStream {
952    type Item = Result<PlayerRequest, fidl::Error>;
953
954    fn poll_next(
955        mut self: std::pin::Pin<&mut Self>,
956        cx: &mut std::task::Context<'_>,
957    ) -> std::task::Poll<Option<Self::Item>> {
958        let this = &mut *self;
959        if this.inner.check_shutdown(cx) {
960            this.is_terminated = true;
961            return std::task::Poll::Ready(None);
962        }
963        if this.is_terminated {
964            panic!("polled PlayerRequestStream after completion");
965        }
966        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
967            |bytes, handles| {
968                match this.inner.channel().read_etc(cx, bytes, handles) {
969                    std::task::Poll::Ready(Ok(())) => {}
970                    std::task::Poll::Pending => return std::task::Poll::Pending,
971                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
972                        this.is_terminated = true;
973                        return std::task::Poll::Ready(None);
974                    }
975                    std::task::Poll::Ready(Err(e)) => {
976                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
977                            e.into(),
978                        ))));
979                    }
980                }
981
982                // A message has been received from the channel
983                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
984
985                std::task::Poll::Ready(Some(match header.ordinal {
986                    0x1e63779971512042 => {
987                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
988                        let mut req = fidl::new_empty!(
989                            PlayerPlayRequest,
990                            fidl::encoding::DefaultFuchsiaResourceDialect
991                        );
992                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlayerPlayRequest>(&header, _body_bytes, handles, &mut req)?;
993                        let control_handle = PlayerControlHandle { inner: this.inner.clone() };
994                        Ok(PlayerRequest::Play {
995                            payload: req,
996                            responder: PlayerPlayResponder {
997                                control_handle: std::mem::ManuallyDrop::new(control_handle),
998                                tx_id: header.tx_id,
999                            },
1000                        })
1001                    }
1002                    _ if header.tx_id == 0
1003                        && header
1004                            .dynamic_flags()
1005                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1006                    {
1007                        Ok(PlayerRequest::_UnknownMethod {
1008                            ordinal: header.ordinal,
1009                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
1010                            method_type: fidl::MethodType::OneWay,
1011                        })
1012                    }
1013                    _ if header
1014                        .dynamic_flags()
1015                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1016                    {
1017                        this.inner.send_framework_err(
1018                            fidl::encoding::FrameworkErr::UnknownMethod,
1019                            header.tx_id,
1020                            header.ordinal,
1021                            header.dynamic_flags(),
1022                            (bytes, handles),
1023                        )?;
1024                        Ok(PlayerRequest::_UnknownMethod {
1025                            ordinal: header.ordinal,
1026                            control_handle: PlayerControlHandle { inner: this.inner.clone() },
1027                            method_type: fidl::MethodType::TwoWay,
1028                        })
1029                    }
1030                    _ => Err(fidl::Error::UnknownOrdinal {
1031                        ordinal: header.ordinal,
1032                        protocol_name:
1033                            <PlayerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1034                    }),
1035                }))
1036            },
1037        )
1038    }
1039}
1040
1041#[derive(Debug)]
1042pub enum PlayerRequest {
1043    /// Read audio data from a socket in WAV format and play it to a destination.
1044    ///
1045    /// Returns when all bytes have been read from the socket.
1046    Play { payload: PlayerPlayRequest, responder: PlayerPlayResponder },
1047    /// An interaction was received which does not match any known method.
1048    #[non_exhaustive]
1049    _UnknownMethod {
1050        /// Ordinal of the method that was called.
1051        ordinal: u64,
1052        control_handle: PlayerControlHandle,
1053        method_type: fidl::MethodType,
1054    },
1055}
1056
1057impl PlayerRequest {
1058    #[allow(irrefutable_let_patterns)]
1059    pub fn into_play(self) -> Option<(PlayerPlayRequest, PlayerPlayResponder)> {
1060        if let PlayerRequest::Play { payload, responder } = self {
1061            Some((payload, responder))
1062        } else {
1063            None
1064        }
1065    }
1066
1067    /// Name of the method defined in FIDL
1068    pub fn method_name(&self) -> &'static str {
1069        match *self {
1070            PlayerRequest::Play { .. } => "play",
1071            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1072                "unknown one-way method"
1073            }
1074            PlayerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1075                "unknown two-way method"
1076            }
1077        }
1078    }
1079}
1080
1081#[derive(Debug, Clone)]
1082pub struct PlayerControlHandle {
1083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1084}
1085
1086impl PlayerControlHandle {
1087    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1088        self.inner.shutdown_with_epitaph(status.into())
1089    }
1090}
1091
1092impl fidl::endpoints::ControlHandle for PlayerControlHandle {
1093    fn shutdown(&self) {
1094        self.inner.shutdown()
1095    }
1096
1097    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1098        self.inner.shutdown_with_epitaph(status)
1099    }
1100
1101    fn is_closed(&self) -> bool {
1102        self.inner.channel().is_closed()
1103    }
1104    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1105        self.inner.channel().on_closed()
1106    }
1107
1108    #[cfg(target_os = "fuchsia")]
1109    fn signal_peer(
1110        &self,
1111        clear_mask: zx::Signals,
1112        set_mask: zx::Signals,
1113    ) -> Result<(), zx_status::Status> {
1114        use fidl::Peered;
1115        self.inner.channel().signal_peer(clear_mask, set_mask)
1116    }
1117}
1118
1119impl PlayerControlHandle {}
1120
1121#[must_use = "FIDL methods require a response to be sent"]
1122#[derive(Debug)]
1123pub struct PlayerPlayResponder {
1124    control_handle: std::mem::ManuallyDrop<PlayerControlHandle>,
1125    tx_id: u32,
1126}
1127
1128/// Set the the channel to be shutdown (see [`PlayerControlHandle::shutdown`])
1129/// if the responder is dropped without sending a response, so that the client
1130/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1131impl std::ops::Drop for PlayerPlayResponder {
1132    fn drop(&mut self) {
1133        self.control_handle.shutdown();
1134        // Safety: drops once, never accessed again
1135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1136    }
1137}
1138
1139impl fidl::endpoints::Responder for PlayerPlayResponder {
1140    type ControlHandle = PlayerControlHandle;
1141
1142    fn control_handle(&self) -> &PlayerControlHandle {
1143        &self.control_handle
1144    }
1145
1146    fn drop_without_shutdown(mut self) {
1147        // Safety: drops once, never accessed again due to mem::forget
1148        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1149        // Prevent Drop from running (which would shut down the channel)
1150        std::mem::forget(self);
1151    }
1152}
1153
1154impl PlayerPlayResponder {
1155    /// Sends a response to the FIDL transaction.
1156    ///
1157    /// Sets the channel to shutdown if an error occurs.
1158    pub fn send(self, mut result: Result<PlayerPlayResponse, Error>) -> Result<(), fidl::Error> {
1159        let _result = self.send_raw(result);
1160        if _result.is_err() {
1161            self.control_handle.shutdown();
1162        }
1163        self.drop_without_shutdown();
1164        _result
1165    }
1166
1167    /// Similar to "send" but does not shutdown the channel if an error occurs.
1168    pub fn send_no_shutdown_on_err(
1169        self,
1170        mut result: Result<PlayerPlayResponse, Error>,
1171    ) -> Result<(), fidl::Error> {
1172        let _result = self.send_raw(result);
1173        self.drop_without_shutdown();
1174        _result
1175    }
1176
1177    fn send_raw(&self, mut result: Result<PlayerPlayResponse, Error>) -> Result<(), fidl::Error> {
1178        self.control_handle
1179            .inner
1180            .send::<fidl::encoding::FlexibleResultType<PlayerPlayResponse, Error>>(
1181                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1182                self.tx_id,
1183                0x1e63779971512042,
1184                fidl::encoding::DynamicFlags::FLEXIBLE,
1185            )
1186    }
1187}
1188
1189#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1190pub struct RecordCancelerMarker;
1191
1192impl fidl::endpoints::ProtocolMarker for RecordCancelerMarker {
1193    type Proxy = RecordCancelerProxy;
1194    type RequestStream = RecordCancelerRequestStream;
1195    #[cfg(target_os = "fuchsia")]
1196    type SynchronousProxy = RecordCancelerSynchronousProxy;
1197
1198    const DEBUG_NAME: &'static str = "(anonymous) RecordCanceler";
1199}
1200pub type RecordCancelerCancelResult = Result<(), i32>;
1201
1202pub trait RecordCancelerProxyInterface: Send + Sync {
1203    type CancelResponseFut: std::future::Future<Output = Result<RecordCancelerCancelResult, fidl::Error>>
1204        + Send;
1205    fn r#cancel(&self) -> Self::CancelResponseFut;
1206}
1207#[derive(Debug)]
1208#[cfg(target_os = "fuchsia")]
1209pub struct RecordCancelerSynchronousProxy {
1210    client: fidl::client::sync::Client,
1211}
1212
1213#[cfg(target_os = "fuchsia")]
1214impl fidl::endpoints::SynchronousProxy for RecordCancelerSynchronousProxy {
1215    type Proxy = RecordCancelerProxy;
1216    type Protocol = RecordCancelerMarker;
1217
1218    fn from_channel(inner: fidl::Channel) -> Self {
1219        Self::new(inner)
1220    }
1221
1222    fn into_channel(self) -> fidl::Channel {
1223        self.client.into_channel()
1224    }
1225
1226    fn as_channel(&self) -> &fidl::Channel {
1227        self.client.as_channel()
1228    }
1229}
1230
1231#[cfg(target_os = "fuchsia")]
1232impl RecordCancelerSynchronousProxy {
1233    pub fn new(channel: fidl::Channel) -> Self {
1234        Self { client: fidl::client::sync::Client::new(channel) }
1235    }
1236
1237    pub fn into_channel(self) -> fidl::Channel {
1238        self.client.into_channel()
1239    }
1240
1241    /// Waits until an event arrives and returns it. It is safe for other
1242    /// threads to make concurrent requests while waiting for an event.
1243    pub fn wait_for_event(
1244        &self,
1245        deadline: zx::MonotonicInstant,
1246    ) -> Result<RecordCancelerEvent, fidl::Error> {
1247        RecordCancelerEvent::decode(self.client.wait_for_event::<RecordCancelerMarker>(deadline)?)
1248    }
1249
1250    /// Stop recording and writing data on the output socket.
1251    pub fn r#cancel(
1252        &self,
1253        ___deadline: zx::MonotonicInstant,
1254    ) -> Result<RecordCancelerCancelResult, fidl::Error> {
1255        let _response = self.client.send_query::<
1256            fidl::encoding::EmptyPayload,
1257            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1258            RecordCancelerMarker,
1259        >(
1260            (),
1261            0x5ea52b81e366daf6,
1262            fidl::encoding::DynamicFlags::empty(),
1263            ___deadline,
1264        )?;
1265        Ok(_response.map(|x| x))
1266    }
1267}
1268
1269#[cfg(target_os = "fuchsia")]
1270impl From<RecordCancelerSynchronousProxy> for zx::NullableHandle {
1271    fn from(value: RecordCancelerSynchronousProxy) -> Self {
1272        value.into_channel().into()
1273    }
1274}
1275
1276#[cfg(target_os = "fuchsia")]
1277impl From<fidl::Channel> for RecordCancelerSynchronousProxy {
1278    fn from(value: fidl::Channel) -> Self {
1279        Self::new(value)
1280    }
1281}
1282
1283#[cfg(target_os = "fuchsia")]
1284impl fidl::endpoints::FromClient for RecordCancelerSynchronousProxy {
1285    type Protocol = RecordCancelerMarker;
1286
1287    fn from_client(value: fidl::endpoints::ClientEnd<RecordCancelerMarker>) -> Self {
1288        Self::new(value.into_channel())
1289    }
1290}
1291
1292#[derive(Debug, Clone)]
1293pub struct RecordCancelerProxy {
1294    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1295}
1296
1297impl fidl::endpoints::Proxy for RecordCancelerProxy {
1298    type Protocol = RecordCancelerMarker;
1299
1300    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1301        Self::new(inner)
1302    }
1303
1304    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1305        self.client.into_channel().map_err(|client| Self { client })
1306    }
1307
1308    fn as_channel(&self) -> &::fidl::AsyncChannel {
1309        self.client.as_channel()
1310    }
1311}
1312
1313impl RecordCancelerProxy {
1314    /// Create a new Proxy for fuchsia.audio.controller/RecordCanceler.
1315    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1316        let protocol_name = <RecordCancelerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1317        Self { client: fidl::client::Client::new(channel, protocol_name) }
1318    }
1319
1320    /// Get a Stream of events from the remote end of the protocol.
1321    ///
1322    /// # Panics
1323    ///
1324    /// Panics if the event stream was already taken.
1325    pub fn take_event_stream(&self) -> RecordCancelerEventStream {
1326        RecordCancelerEventStream { event_receiver: self.client.take_event_receiver() }
1327    }
1328
1329    /// Stop recording and writing data on the output socket.
1330    pub fn r#cancel(
1331        &self,
1332    ) -> fidl::client::QueryResponseFut<
1333        RecordCancelerCancelResult,
1334        fidl::encoding::DefaultFuchsiaResourceDialect,
1335    > {
1336        RecordCancelerProxyInterface::r#cancel(self)
1337    }
1338}
1339
1340impl RecordCancelerProxyInterface for RecordCancelerProxy {
1341    type CancelResponseFut = fidl::client::QueryResponseFut<
1342        RecordCancelerCancelResult,
1343        fidl::encoding::DefaultFuchsiaResourceDialect,
1344    >;
1345    fn r#cancel(&self) -> Self::CancelResponseFut {
1346        fn _decode(
1347            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1348        ) -> Result<RecordCancelerCancelResult, fidl::Error> {
1349            let _response = fidl::client::decode_transaction_body::<
1350                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1351                fidl::encoding::DefaultFuchsiaResourceDialect,
1352                0x5ea52b81e366daf6,
1353            >(_buf?)?;
1354            Ok(_response.map(|x| x))
1355        }
1356        self.client
1357            .send_query_and_decode::<fidl::encoding::EmptyPayload, RecordCancelerCancelResult>(
1358                (),
1359                0x5ea52b81e366daf6,
1360                fidl::encoding::DynamicFlags::empty(),
1361                _decode,
1362            )
1363    }
1364}
1365
1366pub struct RecordCancelerEventStream {
1367    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1368}
1369
1370impl std::marker::Unpin for RecordCancelerEventStream {}
1371
1372impl futures::stream::FusedStream for RecordCancelerEventStream {
1373    fn is_terminated(&self) -> bool {
1374        self.event_receiver.is_terminated()
1375    }
1376}
1377
1378impl futures::Stream for RecordCancelerEventStream {
1379    type Item = Result<RecordCancelerEvent, fidl::Error>;
1380
1381    fn poll_next(
1382        mut self: std::pin::Pin<&mut Self>,
1383        cx: &mut std::task::Context<'_>,
1384    ) -> std::task::Poll<Option<Self::Item>> {
1385        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1386            &mut self.event_receiver,
1387            cx
1388        )?) {
1389            Some(buf) => std::task::Poll::Ready(Some(RecordCancelerEvent::decode(buf))),
1390            None => std::task::Poll::Ready(None),
1391        }
1392    }
1393}
1394
1395#[derive(Debug)]
1396pub enum RecordCancelerEvent {
1397    #[non_exhaustive]
1398    _UnknownEvent {
1399        /// Ordinal of the event that was sent.
1400        ordinal: u64,
1401    },
1402}
1403
1404impl RecordCancelerEvent {
1405    /// Decodes a message buffer as a [`RecordCancelerEvent`].
1406    fn decode(
1407        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1408    ) -> Result<RecordCancelerEvent, fidl::Error> {
1409        let (bytes, _handles) = buf.split_mut();
1410        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1411        debug_assert_eq!(tx_header.tx_id, 0);
1412        match tx_header.ordinal {
1413            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1414                Ok(RecordCancelerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1415            }
1416            _ => Err(fidl::Error::UnknownOrdinal {
1417                ordinal: tx_header.ordinal,
1418                protocol_name:
1419                    <RecordCancelerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1420            }),
1421        }
1422    }
1423}
1424
1425/// A Stream of incoming requests for fuchsia.audio.controller/RecordCanceler.
1426pub struct RecordCancelerRequestStream {
1427    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1428    is_terminated: bool,
1429}
1430
1431impl std::marker::Unpin for RecordCancelerRequestStream {}
1432
1433impl futures::stream::FusedStream for RecordCancelerRequestStream {
1434    fn is_terminated(&self) -> bool {
1435        self.is_terminated
1436    }
1437}
1438
1439impl fidl::endpoints::RequestStream for RecordCancelerRequestStream {
1440    type Protocol = RecordCancelerMarker;
1441    type ControlHandle = RecordCancelerControlHandle;
1442
1443    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1444        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1445    }
1446
1447    fn control_handle(&self) -> Self::ControlHandle {
1448        RecordCancelerControlHandle { inner: self.inner.clone() }
1449    }
1450
1451    fn into_inner(
1452        self,
1453    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1454    {
1455        (self.inner, self.is_terminated)
1456    }
1457
1458    fn from_inner(
1459        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1460        is_terminated: bool,
1461    ) -> Self {
1462        Self { inner, is_terminated }
1463    }
1464}
1465
1466impl futures::Stream for RecordCancelerRequestStream {
1467    type Item = Result<RecordCancelerRequest, fidl::Error>;
1468
1469    fn poll_next(
1470        mut self: std::pin::Pin<&mut Self>,
1471        cx: &mut std::task::Context<'_>,
1472    ) -> std::task::Poll<Option<Self::Item>> {
1473        let this = &mut *self;
1474        if this.inner.check_shutdown(cx) {
1475            this.is_terminated = true;
1476            return std::task::Poll::Ready(None);
1477        }
1478        if this.is_terminated {
1479            panic!("polled RecordCancelerRequestStream after completion");
1480        }
1481        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1482            |bytes, handles| {
1483                match this.inner.channel().read_etc(cx, bytes, handles) {
1484                    std::task::Poll::Ready(Ok(())) => {}
1485                    std::task::Poll::Pending => return std::task::Poll::Pending,
1486                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1487                        this.is_terminated = true;
1488                        return std::task::Poll::Ready(None);
1489                    }
1490                    std::task::Poll::Ready(Err(e)) => {
1491                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1492                            e.into(),
1493                        ))));
1494                    }
1495                }
1496
1497                // A message has been received from the channel
1498                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1499
1500                std::task::Poll::Ready(Some(match header.ordinal {
1501                    0x5ea52b81e366daf6 => {
1502                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1503                        let mut req = fidl::new_empty!(
1504                            fidl::encoding::EmptyPayload,
1505                            fidl::encoding::DefaultFuchsiaResourceDialect
1506                        );
1507                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1508                        let control_handle =
1509                            RecordCancelerControlHandle { inner: this.inner.clone() };
1510                        Ok(RecordCancelerRequest::Cancel {
1511                            responder: RecordCancelerCancelResponder {
1512                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1513                                tx_id: header.tx_id,
1514                            },
1515                        })
1516                    }
1517                    _ if header.tx_id == 0
1518                        && header
1519                            .dynamic_flags()
1520                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1521                    {
1522                        Ok(RecordCancelerRequest::_UnknownMethod {
1523                            ordinal: header.ordinal,
1524                            control_handle: RecordCancelerControlHandle {
1525                                inner: this.inner.clone(),
1526                            },
1527                            method_type: fidl::MethodType::OneWay,
1528                        })
1529                    }
1530                    _ if header
1531                        .dynamic_flags()
1532                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1533                    {
1534                        this.inner.send_framework_err(
1535                            fidl::encoding::FrameworkErr::UnknownMethod,
1536                            header.tx_id,
1537                            header.ordinal,
1538                            header.dynamic_flags(),
1539                            (bytes, handles),
1540                        )?;
1541                        Ok(RecordCancelerRequest::_UnknownMethod {
1542                            ordinal: header.ordinal,
1543                            control_handle: RecordCancelerControlHandle {
1544                                inner: this.inner.clone(),
1545                            },
1546                            method_type: fidl::MethodType::TwoWay,
1547                        })
1548                    }
1549                    _ => Err(fidl::Error::UnknownOrdinal {
1550                        ordinal: header.ordinal,
1551                        protocol_name:
1552                            <RecordCancelerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1553                    }),
1554                }))
1555            },
1556        )
1557    }
1558}
1559
1560/// Cancels a `Recorder.Record` request.
1561#[derive(Debug)]
1562pub enum RecordCancelerRequest {
1563    /// Stop recording and writing data on the output socket.
1564    Cancel { responder: RecordCancelerCancelResponder },
1565    /// An interaction was received which does not match any known method.
1566    #[non_exhaustive]
1567    _UnknownMethod {
1568        /// Ordinal of the method that was called.
1569        ordinal: u64,
1570        control_handle: RecordCancelerControlHandle,
1571        method_type: fidl::MethodType,
1572    },
1573}
1574
1575impl RecordCancelerRequest {
1576    #[allow(irrefutable_let_patterns)]
1577    pub fn into_cancel(self) -> Option<(RecordCancelerCancelResponder)> {
1578        if let RecordCancelerRequest::Cancel { responder } = self {
1579            Some((responder))
1580        } else {
1581            None
1582        }
1583    }
1584
1585    /// Name of the method defined in FIDL
1586    pub fn method_name(&self) -> &'static str {
1587        match *self {
1588            RecordCancelerRequest::Cancel { .. } => "cancel",
1589            RecordCancelerRequest::_UnknownMethod {
1590                method_type: fidl::MethodType::OneWay, ..
1591            } => "unknown one-way method",
1592            RecordCancelerRequest::_UnknownMethod {
1593                method_type: fidl::MethodType::TwoWay, ..
1594            } => "unknown two-way method",
1595        }
1596    }
1597}
1598
1599#[derive(Debug, Clone)]
1600pub struct RecordCancelerControlHandle {
1601    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1602}
1603
1604impl RecordCancelerControlHandle {
1605    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1606        self.inner.shutdown_with_epitaph(status.into())
1607    }
1608}
1609
1610impl fidl::endpoints::ControlHandle for RecordCancelerControlHandle {
1611    fn shutdown(&self) {
1612        self.inner.shutdown()
1613    }
1614
1615    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1616        self.inner.shutdown_with_epitaph(status)
1617    }
1618
1619    fn is_closed(&self) -> bool {
1620        self.inner.channel().is_closed()
1621    }
1622    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1623        self.inner.channel().on_closed()
1624    }
1625
1626    #[cfg(target_os = "fuchsia")]
1627    fn signal_peer(
1628        &self,
1629        clear_mask: zx::Signals,
1630        set_mask: zx::Signals,
1631    ) -> Result<(), zx_status::Status> {
1632        use fidl::Peered;
1633        self.inner.channel().signal_peer(clear_mask, set_mask)
1634    }
1635}
1636
1637impl RecordCancelerControlHandle {}
1638
1639#[must_use = "FIDL methods require a response to be sent"]
1640#[derive(Debug)]
1641pub struct RecordCancelerCancelResponder {
1642    control_handle: std::mem::ManuallyDrop<RecordCancelerControlHandle>,
1643    tx_id: u32,
1644}
1645
1646/// Set the the channel to be shutdown (see [`RecordCancelerControlHandle::shutdown`])
1647/// if the responder is dropped without sending a response, so that the client
1648/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1649impl std::ops::Drop for RecordCancelerCancelResponder {
1650    fn drop(&mut self) {
1651        self.control_handle.shutdown();
1652        // Safety: drops once, never accessed again
1653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1654    }
1655}
1656
1657impl fidl::endpoints::Responder for RecordCancelerCancelResponder {
1658    type ControlHandle = RecordCancelerControlHandle;
1659
1660    fn control_handle(&self) -> &RecordCancelerControlHandle {
1661        &self.control_handle
1662    }
1663
1664    fn drop_without_shutdown(mut self) {
1665        // Safety: drops once, never accessed again due to mem::forget
1666        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1667        // Prevent Drop from running (which would shut down the channel)
1668        std::mem::forget(self);
1669    }
1670}
1671
1672impl RecordCancelerCancelResponder {
1673    /// Sends a response to the FIDL transaction.
1674    ///
1675    /// Sets the channel to shutdown if an error occurs.
1676    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1677        let _result = self.send_raw(result);
1678        if _result.is_err() {
1679            self.control_handle.shutdown();
1680        }
1681        self.drop_without_shutdown();
1682        _result
1683    }
1684
1685    /// Similar to "send" but does not shutdown the channel if an error occurs.
1686    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1687        let _result = self.send_raw(result);
1688        self.drop_without_shutdown();
1689        _result
1690    }
1691
1692    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1693        self.control_handle
1694            .inner
1695            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1696                result,
1697                self.tx_id,
1698                0x5ea52b81e366daf6,
1699                fidl::encoding::DynamicFlags::empty(),
1700            )
1701    }
1702}
1703
1704#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1705pub struct RecorderMarker;
1706
1707impl fidl::endpoints::ProtocolMarker for RecorderMarker {
1708    type Proxy = RecorderProxy;
1709    type RequestStream = RecorderRequestStream;
1710    #[cfg(target_os = "fuchsia")]
1711    type SynchronousProxy = RecorderSynchronousProxy;
1712
1713    const DEBUG_NAME: &'static str = "fuchsia.audio.controller.Recorder";
1714}
1715impl fidl::endpoints::DiscoverableProtocolMarker for RecorderMarker {}
1716pub type RecorderRecordResult = Result<RecorderRecordResponse, Error>;
1717
1718pub trait RecorderProxyInterface: Send + Sync {
1719    type RecordResponseFut: std::future::Future<Output = Result<RecorderRecordResult, fidl::Error>>
1720        + Send;
1721    fn r#record(&self, payload: RecorderRecordRequest) -> Self::RecordResponseFut;
1722}
1723#[derive(Debug)]
1724#[cfg(target_os = "fuchsia")]
1725pub struct RecorderSynchronousProxy {
1726    client: fidl::client::sync::Client,
1727}
1728
1729#[cfg(target_os = "fuchsia")]
1730impl fidl::endpoints::SynchronousProxy for RecorderSynchronousProxy {
1731    type Proxy = RecorderProxy;
1732    type Protocol = RecorderMarker;
1733
1734    fn from_channel(inner: fidl::Channel) -> Self {
1735        Self::new(inner)
1736    }
1737
1738    fn into_channel(self) -> fidl::Channel {
1739        self.client.into_channel()
1740    }
1741
1742    fn as_channel(&self) -> &fidl::Channel {
1743        self.client.as_channel()
1744    }
1745}
1746
1747#[cfg(target_os = "fuchsia")]
1748impl RecorderSynchronousProxy {
1749    pub fn new(channel: fidl::Channel) -> Self {
1750        Self { client: fidl::client::sync::Client::new(channel) }
1751    }
1752
1753    pub fn into_channel(self) -> fidl::Channel {
1754        self.client.into_channel()
1755    }
1756
1757    /// Waits until an event arrives and returns it. It is safe for other
1758    /// threads to make concurrent requests while waiting for an event.
1759    pub fn wait_for_event(
1760        &self,
1761        deadline: zx::MonotonicInstant,
1762    ) -> Result<RecorderEvent, fidl::Error> {
1763        RecorderEvent::decode(self.client.wait_for_event::<RecorderMarker>(deadline)?)
1764    }
1765
1766    /// Record audio data and write it to a socket in WAV format.
1767    pub fn r#record(
1768        &self,
1769        mut payload: RecorderRecordRequest,
1770        ___deadline: zx::MonotonicInstant,
1771    ) -> Result<RecorderRecordResult, fidl::Error> {
1772        let _response = self.client.send_query::<
1773            RecorderRecordRequest,
1774            fidl::encoding::FlexibleResultType<RecorderRecordResponse, Error>,
1775            RecorderMarker,
1776        >(
1777            &mut payload,
1778            0x47cabcb60b2c8ca7,
1779            fidl::encoding::DynamicFlags::FLEXIBLE,
1780            ___deadline,
1781        )?
1782        .into_result::<RecorderMarker>("record")?;
1783        Ok(_response.map(|x| x))
1784    }
1785}
1786
1787#[cfg(target_os = "fuchsia")]
1788impl From<RecorderSynchronousProxy> for zx::NullableHandle {
1789    fn from(value: RecorderSynchronousProxy) -> Self {
1790        value.into_channel().into()
1791    }
1792}
1793
1794#[cfg(target_os = "fuchsia")]
1795impl From<fidl::Channel> for RecorderSynchronousProxy {
1796    fn from(value: fidl::Channel) -> Self {
1797        Self::new(value)
1798    }
1799}
1800
1801#[cfg(target_os = "fuchsia")]
1802impl fidl::endpoints::FromClient for RecorderSynchronousProxy {
1803    type Protocol = RecorderMarker;
1804
1805    fn from_client(value: fidl::endpoints::ClientEnd<RecorderMarker>) -> Self {
1806        Self::new(value.into_channel())
1807    }
1808}
1809
1810#[derive(Debug, Clone)]
1811pub struct RecorderProxy {
1812    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1813}
1814
1815impl fidl::endpoints::Proxy for RecorderProxy {
1816    type Protocol = RecorderMarker;
1817
1818    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1819        Self::new(inner)
1820    }
1821
1822    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1823        self.client.into_channel().map_err(|client| Self { client })
1824    }
1825
1826    fn as_channel(&self) -> &::fidl::AsyncChannel {
1827        self.client.as_channel()
1828    }
1829}
1830
1831impl RecorderProxy {
1832    /// Create a new Proxy for fuchsia.audio.controller/Recorder.
1833    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1834        let protocol_name = <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1835        Self { client: fidl::client::Client::new(channel, protocol_name) }
1836    }
1837
1838    /// Get a Stream of events from the remote end of the protocol.
1839    ///
1840    /// # Panics
1841    ///
1842    /// Panics if the event stream was already taken.
1843    pub fn take_event_stream(&self) -> RecorderEventStream {
1844        RecorderEventStream { event_receiver: self.client.take_event_receiver() }
1845    }
1846
1847    /// Record audio data and write it to a socket in WAV format.
1848    pub fn r#record(
1849        &self,
1850        mut payload: RecorderRecordRequest,
1851    ) -> fidl::client::QueryResponseFut<
1852        RecorderRecordResult,
1853        fidl::encoding::DefaultFuchsiaResourceDialect,
1854    > {
1855        RecorderProxyInterface::r#record(self, payload)
1856    }
1857}
1858
1859impl RecorderProxyInterface for RecorderProxy {
1860    type RecordResponseFut = fidl::client::QueryResponseFut<
1861        RecorderRecordResult,
1862        fidl::encoding::DefaultFuchsiaResourceDialect,
1863    >;
1864    fn r#record(&self, mut payload: RecorderRecordRequest) -> Self::RecordResponseFut {
1865        fn _decode(
1866            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1867        ) -> Result<RecorderRecordResult, fidl::Error> {
1868            let _response = fidl::client::decode_transaction_body::<
1869                fidl::encoding::FlexibleResultType<RecorderRecordResponse, Error>,
1870                fidl::encoding::DefaultFuchsiaResourceDialect,
1871                0x47cabcb60b2c8ca7,
1872            >(_buf?)?
1873            .into_result::<RecorderMarker>("record")?;
1874            Ok(_response.map(|x| x))
1875        }
1876        self.client.send_query_and_decode::<RecorderRecordRequest, RecorderRecordResult>(
1877            &mut payload,
1878            0x47cabcb60b2c8ca7,
1879            fidl::encoding::DynamicFlags::FLEXIBLE,
1880            _decode,
1881        )
1882    }
1883}
1884
1885pub struct RecorderEventStream {
1886    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1887}
1888
1889impl std::marker::Unpin for RecorderEventStream {}
1890
1891impl futures::stream::FusedStream for RecorderEventStream {
1892    fn is_terminated(&self) -> bool {
1893        self.event_receiver.is_terminated()
1894    }
1895}
1896
1897impl futures::Stream for RecorderEventStream {
1898    type Item = Result<RecorderEvent, fidl::Error>;
1899
1900    fn poll_next(
1901        mut self: std::pin::Pin<&mut Self>,
1902        cx: &mut std::task::Context<'_>,
1903    ) -> std::task::Poll<Option<Self::Item>> {
1904        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1905            &mut self.event_receiver,
1906            cx
1907        )?) {
1908            Some(buf) => std::task::Poll::Ready(Some(RecorderEvent::decode(buf))),
1909            None => std::task::Poll::Ready(None),
1910        }
1911    }
1912}
1913
1914#[derive(Debug)]
1915pub enum RecorderEvent {
1916    #[non_exhaustive]
1917    _UnknownEvent {
1918        /// Ordinal of the event that was sent.
1919        ordinal: u64,
1920    },
1921}
1922
1923impl RecorderEvent {
1924    /// Decodes a message buffer as a [`RecorderEvent`].
1925    fn decode(
1926        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1927    ) -> Result<RecorderEvent, fidl::Error> {
1928        let (bytes, _handles) = buf.split_mut();
1929        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1930        debug_assert_eq!(tx_header.tx_id, 0);
1931        match tx_header.ordinal {
1932            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1933                Ok(RecorderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1934            }
1935            _ => Err(fidl::Error::UnknownOrdinal {
1936                ordinal: tx_header.ordinal,
1937                protocol_name: <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1938            }),
1939        }
1940    }
1941}
1942
1943/// A Stream of incoming requests for fuchsia.audio.controller/Recorder.
1944pub struct RecorderRequestStream {
1945    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1946    is_terminated: bool,
1947}
1948
1949impl std::marker::Unpin for RecorderRequestStream {}
1950
1951impl futures::stream::FusedStream for RecorderRequestStream {
1952    fn is_terminated(&self) -> bool {
1953        self.is_terminated
1954    }
1955}
1956
1957impl fidl::endpoints::RequestStream for RecorderRequestStream {
1958    type Protocol = RecorderMarker;
1959    type ControlHandle = RecorderControlHandle;
1960
1961    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1962        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1963    }
1964
1965    fn control_handle(&self) -> Self::ControlHandle {
1966        RecorderControlHandle { inner: self.inner.clone() }
1967    }
1968
1969    fn into_inner(
1970        self,
1971    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1972    {
1973        (self.inner, self.is_terminated)
1974    }
1975
1976    fn from_inner(
1977        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1978        is_terminated: bool,
1979    ) -> Self {
1980        Self { inner, is_terminated }
1981    }
1982}
1983
1984impl futures::Stream for RecorderRequestStream {
1985    type Item = Result<RecorderRequest, fidl::Error>;
1986
1987    fn poll_next(
1988        mut self: std::pin::Pin<&mut Self>,
1989        cx: &mut std::task::Context<'_>,
1990    ) -> std::task::Poll<Option<Self::Item>> {
1991        let this = &mut *self;
1992        if this.inner.check_shutdown(cx) {
1993            this.is_terminated = true;
1994            return std::task::Poll::Ready(None);
1995        }
1996        if this.is_terminated {
1997            panic!("polled RecorderRequestStream after completion");
1998        }
1999        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2000            |bytes, handles| {
2001                match this.inner.channel().read_etc(cx, bytes, handles) {
2002                    std::task::Poll::Ready(Ok(())) => {}
2003                    std::task::Poll::Pending => return std::task::Poll::Pending,
2004                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2005                        this.is_terminated = true;
2006                        return std::task::Poll::Ready(None);
2007                    }
2008                    std::task::Poll::Ready(Err(e)) => {
2009                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2010                            e.into(),
2011                        ))));
2012                    }
2013                }
2014
2015                // A message has been received from the channel
2016                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2017
2018                std::task::Poll::Ready(Some(match header.ordinal {
2019                    0x47cabcb60b2c8ca7 => {
2020                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2021                        let mut req = fidl::new_empty!(
2022                            RecorderRecordRequest,
2023                            fidl::encoding::DefaultFuchsiaResourceDialect
2024                        );
2025                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderRecordRequest>(&header, _body_bytes, handles, &mut req)?;
2026                        let control_handle = RecorderControlHandle { inner: this.inner.clone() };
2027                        Ok(RecorderRequest::Record {
2028                            payload: req,
2029                            responder: RecorderRecordResponder {
2030                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2031                                tx_id: header.tx_id,
2032                            },
2033                        })
2034                    }
2035                    _ if header.tx_id == 0
2036                        && header
2037                            .dynamic_flags()
2038                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2039                    {
2040                        Ok(RecorderRequest::_UnknownMethod {
2041                            ordinal: header.ordinal,
2042                            control_handle: RecorderControlHandle { inner: this.inner.clone() },
2043                            method_type: fidl::MethodType::OneWay,
2044                        })
2045                    }
2046                    _ if header
2047                        .dynamic_flags()
2048                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2049                    {
2050                        this.inner.send_framework_err(
2051                            fidl::encoding::FrameworkErr::UnknownMethod,
2052                            header.tx_id,
2053                            header.ordinal,
2054                            header.dynamic_flags(),
2055                            (bytes, handles),
2056                        )?;
2057                        Ok(RecorderRequest::_UnknownMethod {
2058                            ordinal: header.ordinal,
2059                            control_handle: RecorderControlHandle { inner: this.inner.clone() },
2060                            method_type: fidl::MethodType::TwoWay,
2061                        })
2062                    }
2063                    _ => Err(fidl::Error::UnknownOrdinal {
2064                        ordinal: header.ordinal,
2065                        protocol_name:
2066                            <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2067                    }),
2068                }))
2069            },
2070        )
2071    }
2072}
2073
2074#[derive(Debug)]
2075pub enum RecorderRequest {
2076    /// Record audio data and write it to a socket in WAV format.
2077    Record { payload: RecorderRecordRequest, responder: RecorderRecordResponder },
2078    /// An interaction was received which does not match any known method.
2079    #[non_exhaustive]
2080    _UnknownMethod {
2081        /// Ordinal of the method that was called.
2082        ordinal: u64,
2083        control_handle: RecorderControlHandle,
2084        method_type: fidl::MethodType,
2085    },
2086}
2087
2088impl RecorderRequest {
2089    #[allow(irrefutable_let_patterns)]
2090    pub fn into_record(self) -> Option<(RecorderRecordRequest, RecorderRecordResponder)> {
2091        if let RecorderRequest::Record { payload, responder } = self {
2092            Some((payload, responder))
2093        } else {
2094            None
2095        }
2096    }
2097
2098    /// Name of the method defined in FIDL
2099    pub fn method_name(&self) -> &'static str {
2100        match *self {
2101            RecorderRequest::Record { .. } => "record",
2102            RecorderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2103                "unknown one-way method"
2104            }
2105            RecorderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2106                "unknown two-way method"
2107            }
2108        }
2109    }
2110}
2111
2112#[derive(Debug, Clone)]
2113pub struct RecorderControlHandle {
2114    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2115}
2116
2117impl RecorderControlHandle {
2118    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2119        self.inner.shutdown_with_epitaph(status.into())
2120    }
2121}
2122
2123impl fidl::endpoints::ControlHandle for RecorderControlHandle {
2124    fn shutdown(&self) {
2125        self.inner.shutdown()
2126    }
2127
2128    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2129        self.inner.shutdown_with_epitaph(status)
2130    }
2131
2132    fn is_closed(&self) -> bool {
2133        self.inner.channel().is_closed()
2134    }
2135    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2136        self.inner.channel().on_closed()
2137    }
2138
2139    #[cfg(target_os = "fuchsia")]
2140    fn signal_peer(
2141        &self,
2142        clear_mask: zx::Signals,
2143        set_mask: zx::Signals,
2144    ) -> Result<(), zx_status::Status> {
2145        use fidl::Peered;
2146        self.inner.channel().signal_peer(clear_mask, set_mask)
2147    }
2148}
2149
2150impl RecorderControlHandle {}
2151
2152#[must_use = "FIDL methods require a response to be sent"]
2153#[derive(Debug)]
2154pub struct RecorderRecordResponder {
2155    control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
2156    tx_id: u32,
2157}
2158
2159/// Set the the channel to be shutdown (see [`RecorderControlHandle::shutdown`])
2160/// if the responder is dropped without sending a response, so that the client
2161/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2162impl std::ops::Drop for RecorderRecordResponder {
2163    fn drop(&mut self) {
2164        self.control_handle.shutdown();
2165        // Safety: drops once, never accessed again
2166        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2167    }
2168}
2169
2170impl fidl::endpoints::Responder for RecorderRecordResponder {
2171    type ControlHandle = RecorderControlHandle;
2172
2173    fn control_handle(&self) -> &RecorderControlHandle {
2174        &self.control_handle
2175    }
2176
2177    fn drop_without_shutdown(mut self) {
2178        // Safety: drops once, never accessed again due to mem::forget
2179        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2180        // Prevent Drop from running (which would shut down the channel)
2181        std::mem::forget(self);
2182    }
2183}
2184
2185impl RecorderRecordResponder {
2186    /// Sends a response to the FIDL transaction.
2187    ///
2188    /// Sets the channel to shutdown if an error occurs.
2189    pub fn send(
2190        self,
2191        mut result: Result<RecorderRecordResponse, Error>,
2192    ) -> Result<(), fidl::Error> {
2193        let _result = self.send_raw(result);
2194        if _result.is_err() {
2195            self.control_handle.shutdown();
2196        }
2197        self.drop_without_shutdown();
2198        _result
2199    }
2200
2201    /// Similar to "send" but does not shutdown the channel if an error occurs.
2202    pub fn send_no_shutdown_on_err(
2203        self,
2204        mut result: Result<RecorderRecordResponse, Error>,
2205    ) -> Result<(), fidl::Error> {
2206        let _result = self.send_raw(result);
2207        self.drop_without_shutdown();
2208        _result
2209    }
2210
2211    fn send_raw(
2212        &self,
2213        mut result: Result<RecorderRecordResponse, Error>,
2214    ) -> Result<(), fidl::Error> {
2215        self.control_handle
2216            .inner
2217            .send::<fidl::encoding::FlexibleResultType<RecorderRecordResponse, Error>>(
2218                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2219                self.tx_id,
2220                0x47cabcb60b2c8ca7,
2221                fidl::encoding::DynamicFlags::FLEXIBLE,
2222            )
2223    }
2224}
2225
2226mod internal {
2227    use super::*;
2228
2229    impl DeviceControlDeviceSetGainStateRequest {
2230        #[inline(always)]
2231        fn max_ordinal_present(&self) -> u64 {
2232            if let Some(_) = self.gain_state {
2233                return 2;
2234            }
2235            if let Some(_) = self.device {
2236                return 1;
2237            }
2238            0
2239        }
2240    }
2241
2242    impl fidl::encoding::ResourceTypeMarker for DeviceControlDeviceSetGainStateRequest {
2243        type Borrowed<'a> = &'a mut Self;
2244        fn take_or_borrow<'a>(
2245            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2246        ) -> Self::Borrowed<'a> {
2247            value
2248        }
2249    }
2250
2251    unsafe impl fidl::encoding::TypeMarker for DeviceControlDeviceSetGainStateRequest {
2252        type Owned = Self;
2253
2254        #[inline(always)]
2255        fn inline_align(_context: fidl::encoding::Context) -> usize {
2256            8
2257        }
2258
2259        #[inline(always)]
2260        fn inline_size(_context: fidl::encoding::Context) -> usize {
2261            16
2262        }
2263    }
2264
2265    unsafe impl
2266        fidl::encoding::Encode<
2267            DeviceControlDeviceSetGainStateRequest,
2268            fidl::encoding::DefaultFuchsiaResourceDialect,
2269        > for &mut DeviceControlDeviceSetGainStateRequest
2270    {
2271        unsafe fn encode(
2272            self,
2273            encoder: &mut fidl::encoding::Encoder<
2274                '_,
2275                fidl::encoding::DefaultFuchsiaResourceDialect,
2276            >,
2277            offset: usize,
2278            mut depth: fidl::encoding::Depth,
2279        ) -> fidl::Result<()> {
2280            encoder.debug_check_bounds::<DeviceControlDeviceSetGainStateRequest>(offset);
2281            // Vector header
2282            let max_ordinal: u64 = self.max_ordinal_present();
2283            encoder.write_num(max_ordinal, offset);
2284            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2285            // Calling encoder.out_of_line_offset(0) is not allowed.
2286            if max_ordinal == 0 {
2287                return Ok(());
2288            }
2289            depth.increment()?;
2290            let envelope_size = 8;
2291            let bytes_len = max_ordinal as usize * envelope_size;
2292            #[allow(unused_variables)]
2293            let offset = encoder.out_of_line_offset(bytes_len);
2294            let mut _prev_end_offset: usize = 0;
2295            if 1 > max_ordinal {
2296                return Ok(());
2297            }
2298
2299            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2300            // are envelope_size bytes.
2301            let cur_offset: usize = (1 - 1) * envelope_size;
2302
2303            // Zero reserved fields.
2304            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2305
2306            // Safety:
2307            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2308            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2309            //   envelope_size bytes, there is always sufficient room.
2310            fidl::encoding::encode_in_envelope_optional::<
2311                DeviceSelector,
2312                fidl::encoding::DefaultFuchsiaResourceDialect,
2313            >(
2314                self.device
2315                    .as_ref()
2316                    .map(<DeviceSelector as fidl::encoding::ValueTypeMarker>::borrow),
2317                encoder,
2318                offset + cur_offset,
2319                depth,
2320            )?;
2321
2322            _prev_end_offset = cur_offset + envelope_size;
2323            if 2 > max_ordinal {
2324                return Ok(());
2325            }
2326
2327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2328            // are envelope_size bytes.
2329            let cur_offset: usize = (2 - 1) * envelope_size;
2330
2331            // Zero reserved fields.
2332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2333
2334            // Safety:
2335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2337            //   envelope_size bytes, there is always sufficient room.
2338            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_audio::GainState, fidl::encoding::DefaultFuchsiaResourceDialect>(
2339            self.gain_state.as_ref().map(<fidl_fuchsia_hardware_audio::GainState as fidl::encoding::ValueTypeMarker>::borrow),
2340            encoder, offset + cur_offset, depth
2341        )?;
2342
2343            _prev_end_offset = cur_offset + envelope_size;
2344
2345            Ok(())
2346        }
2347    }
2348
2349    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2350        for DeviceControlDeviceSetGainStateRequest
2351    {
2352        #[inline(always)]
2353        fn new_empty() -> Self {
2354            Self::default()
2355        }
2356
2357        unsafe fn decode(
2358            &mut self,
2359            decoder: &mut fidl::encoding::Decoder<
2360                '_,
2361                fidl::encoding::DefaultFuchsiaResourceDialect,
2362            >,
2363            offset: usize,
2364            mut depth: fidl::encoding::Depth,
2365        ) -> fidl::Result<()> {
2366            decoder.debug_check_bounds::<Self>(offset);
2367            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2368                None => return Err(fidl::Error::NotNullable),
2369                Some(len) => len,
2370            };
2371            // Calling decoder.out_of_line_offset(0) is not allowed.
2372            if len == 0 {
2373                return Ok(());
2374            };
2375            depth.increment()?;
2376            let envelope_size = 8;
2377            let bytes_len = len * envelope_size;
2378            let offset = decoder.out_of_line_offset(bytes_len)?;
2379            // Decode the envelope for each type.
2380            let mut _next_ordinal_to_read = 0;
2381            let mut next_offset = offset;
2382            let end_offset = offset + bytes_len;
2383            _next_ordinal_to_read += 1;
2384            if next_offset >= end_offset {
2385                return Ok(());
2386            }
2387
2388            // Decode unknown envelopes for gaps in ordinals.
2389            while _next_ordinal_to_read < 1 {
2390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2391                _next_ordinal_to_read += 1;
2392                next_offset += envelope_size;
2393            }
2394
2395            let next_out_of_line = decoder.next_out_of_line();
2396            let handles_before = decoder.remaining_handles();
2397            if let Some((inlined, num_bytes, num_handles)) =
2398                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2399            {
2400                let member_inline_size =
2401                    <DeviceSelector as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2402                if inlined != (member_inline_size <= 4) {
2403                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2404                }
2405                let inner_offset;
2406                let mut inner_depth = depth.clone();
2407                if inlined {
2408                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2409                    inner_offset = next_offset;
2410                } else {
2411                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2412                    inner_depth.increment()?;
2413                }
2414                let val_ref = self.device.get_or_insert_with(|| {
2415                    fidl::new_empty!(DeviceSelector, fidl::encoding::DefaultFuchsiaResourceDialect)
2416                });
2417                fidl::decode!(
2418                    DeviceSelector,
2419                    fidl::encoding::DefaultFuchsiaResourceDialect,
2420                    val_ref,
2421                    decoder,
2422                    inner_offset,
2423                    inner_depth
2424                )?;
2425                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2426                {
2427                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2428                }
2429                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2430                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2431                }
2432            }
2433
2434            next_offset += envelope_size;
2435            _next_ordinal_to_read += 1;
2436            if next_offset >= end_offset {
2437                return Ok(());
2438            }
2439
2440            // Decode unknown envelopes for gaps in ordinals.
2441            while _next_ordinal_to_read < 2 {
2442                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2443                _next_ordinal_to_read += 1;
2444                next_offset += envelope_size;
2445            }
2446
2447            let next_out_of_line = decoder.next_out_of_line();
2448            let handles_before = decoder.remaining_handles();
2449            if let Some((inlined, num_bytes, num_handles)) =
2450                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2451            {
2452                let member_inline_size = <fidl_fuchsia_hardware_audio::GainState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2453                if inlined != (member_inline_size <= 4) {
2454                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2455                }
2456                let inner_offset;
2457                let mut inner_depth = depth.clone();
2458                if inlined {
2459                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2460                    inner_offset = next_offset;
2461                } else {
2462                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2463                    inner_depth.increment()?;
2464                }
2465                let val_ref = self.gain_state.get_or_insert_with(|| {
2466                    fidl::new_empty!(
2467                        fidl_fuchsia_hardware_audio::GainState,
2468                        fidl::encoding::DefaultFuchsiaResourceDialect
2469                    )
2470                });
2471                fidl::decode!(
2472                    fidl_fuchsia_hardware_audio::GainState,
2473                    fidl::encoding::DefaultFuchsiaResourceDialect,
2474                    val_ref,
2475                    decoder,
2476                    inner_offset,
2477                    inner_depth
2478                )?;
2479                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2480                {
2481                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2482                }
2483                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2484                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2485                }
2486            }
2487
2488            next_offset += envelope_size;
2489
2490            // Decode the remaining unknown envelopes.
2491            while next_offset < end_offset {
2492                _next_ordinal_to_read += 1;
2493                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2494                next_offset += envelope_size;
2495            }
2496
2497            Ok(())
2498        }
2499    }
2500
2501    impl PlayerPlayRequest {
2502        #[inline(always)]
2503        fn max_ordinal_present(&self) -> u64 {
2504            if let Some(_) = self.active_channels_bitmask {
2505                return 4;
2506            }
2507            if let Some(_) = self.gain_settings {
2508                return 3;
2509            }
2510            if let Some(_) = self.destination {
2511                return 2;
2512            }
2513            if let Some(_) = self.wav_source {
2514                return 1;
2515            }
2516            0
2517        }
2518    }
2519
2520    impl fidl::encoding::ResourceTypeMarker for PlayerPlayRequest {
2521        type Borrowed<'a> = &'a mut Self;
2522        fn take_or_borrow<'a>(
2523            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2524        ) -> Self::Borrowed<'a> {
2525            value
2526        }
2527    }
2528
2529    unsafe impl fidl::encoding::TypeMarker for PlayerPlayRequest {
2530        type Owned = Self;
2531
2532        #[inline(always)]
2533        fn inline_align(_context: fidl::encoding::Context) -> usize {
2534            8
2535        }
2536
2537        #[inline(always)]
2538        fn inline_size(_context: fidl::encoding::Context) -> usize {
2539            16
2540        }
2541    }
2542
2543    unsafe impl
2544        fidl::encoding::Encode<PlayerPlayRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2545        for &mut PlayerPlayRequest
2546    {
2547        unsafe fn encode(
2548            self,
2549            encoder: &mut fidl::encoding::Encoder<
2550                '_,
2551                fidl::encoding::DefaultFuchsiaResourceDialect,
2552            >,
2553            offset: usize,
2554            mut depth: fidl::encoding::Depth,
2555        ) -> fidl::Result<()> {
2556            encoder.debug_check_bounds::<PlayerPlayRequest>(offset);
2557            // Vector header
2558            let max_ordinal: u64 = self.max_ordinal_present();
2559            encoder.write_num(max_ordinal, offset);
2560            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2561            // Calling encoder.out_of_line_offset(0) is not allowed.
2562            if max_ordinal == 0 {
2563                return Ok(());
2564            }
2565            depth.increment()?;
2566            let envelope_size = 8;
2567            let bytes_len = max_ordinal as usize * envelope_size;
2568            #[allow(unused_variables)]
2569            let offset = encoder.out_of_line_offset(bytes_len);
2570            let mut _prev_end_offset: usize = 0;
2571            if 1 > max_ordinal {
2572                return Ok(());
2573            }
2574
2575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2576            // are envelope_size bytes.
2577            let cur_offset: usize = (1 - 1) * envelope_size;
2578
2579            // Zero reserved fields.
2580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2581
2582            // Safety:
2583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2585            //   envelope_size bytes, there is always sufficient room.
2586            fidl::encoding::encode_in_envelope_optional::<
2587                fidl::encoding::HandleType<
2588                    fidl::Socket,
2589                    { fidl::ObjectType::SOCKET.into_raw() },
2590                    16389,
2591                >,
2592                fidl::encoding::DefaultFuchsiaResourceDialect,
2593            >(
2594                self.wav_source.as_mut().map(
2595                    <fidl::encoding::HandleType<
2596                        fidl::Socket,
2597                        { fidl::ObjectType::SOCKET.into_raw() },
2598                        16389,
2599                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2600                ),
2601                encoder,
2602                offset + cur_offset,
2603                depth,
2604            )?;
2605
2606            _prev_end_offset = cur_offset + envelope_size;
2607            if 2 > max_ordinal {
2608                return Ok(());
2609            }
2610
2611            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2612            // are envelope_size bytes.
2613            let cur_offset: usize = (2 - 1) * envelope_size;
2614
2615            // Zero reserved fields.
2616            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2617
2618            // Safety:
2619            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2620            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2621            //   envelope_size bytes, there is always sufficient room.
2622            fidl::encoding::encode_in_envelope_optional::<
2623                PlayDestination,
2624                fidl::encoding::DefaultFuchsiaResourceDialect,
2625            >(
2626                self.destination
2627                    .as_ref()
2628                    .map(<PlayDestination as fidl::encoding::ValueTypeMarker>::borrow),
2629                encoder,
2630                offset + cur_offset,
2631                depth,
2632            )?;
2633
2634            _prev_end_offset = cur_offset + envelope_size;
2635            if 3 > max_ordinal {
2636                return Ok(());
2637            }
2638
2639            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2640            // are envelope_size bytes.
2641            let cur_offset: usize = (3 - 1) * envelope_size;
2642
2643            // Zero reserved fields.
2644            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2645
2646            // Safety:
2647            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2648            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2649            //   envelope_size bytes, there is always sufficient room.
2650            fidl::encoding::encode_in_envelope_optional::<
2651                GainSettings,
2652                fidl::encoding::DefaultFuchsiaResourceDialect,
2653            >(
2654                self.gain_settings
2655                    .as_ref()
2656                    .map(<GainSettings as fidl::encoding::ValueTypeMarker>::borrow),
2657                encoder,
2658                offset + cur_offset,
2659                depth,
2660            )?;
2661
2662            _prev_end_offset = cur_offset + envelope_size;
2663            if 4 > max_ordinal {
2664                return Ok(());
2665            }
2666
2667            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2668            // are envelope_size bytes.
2669            let cur_offset: usize = (4 - 1) * envelope_size;
2670
2671            // Zero reserved fields.
2672            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2673
2674            // Safety:
2675            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2676            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2677            //   envelope_size bytes, there is always sufficient room.
2678            fidl::encoding::encode_in_envelope_optional::<
2679                u64,
2680                fidl::encoding::DefaultFuchsiaResourceDialect,
2681            >(
2682                self.active_channels_bitmask
2683                    .as_ref()
2684                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2685                encoder,
2686                offset + cur_offset,
2687                depth,
2688            )?;
2689
2690            _prev_end_offset = cur_offset + envelope_size;
2691
2692            Ok(())
2693        }
2694    }
2695
2696    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2697        for PlayerPlayRequest
2698    {
2699        #[inline(always)]
2700        fn new_empty() -> Self {
2701            Self::default()
2702        }
2703
2704        unsafe fn decode(
2705            &mut self,
2706            decoder: &mut fidl::encoding::Decoder<
2707                '_,
2708                fidl::encoding::DefaultFuchsiaResourceDialect,
2709            >,
2710            offset: usize,
2711            mut depth: fidl::encoding::Depth,
2712        ) -> fidl::Result<()> {
2713            decoder.debug_check_bounds::<Self>(offset);
2714            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2715                None => return Err(fidl::Error::NotNullable),
2716                Some(len) => len,
2717            };
2718            // Calling decoder.out_of_line_offset(0) is not allowed.
2719            if len == 0 {
2720                return Ok(());
2721            };
2722            depth.increment()?;
2723            let envelope_size = 8;
2724            let bytes_len = len * envelope_size;
2725            let offset = decoder.out_of_line_offset(bytes_len)?;
2726            // Decode the envelope for each type.
2727            let mut _next_ordinal_to_read = 0;
2728            let mut next_offset = offset;
2729            let end_offset = offset + bytes_len;
2730            _next_ordinal_to_read += 1;
2731            if next_offset >= end_offset {
2732                return Ok(());
2733            }
2734
2735            // Decode unknown envelopes for gaps in ordinals.
2736            while _next_ordinal_to_read < 1 {
2737                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2738                _next_ordinal_to_read += 1;
2739                next_offset += envelope_size;
2740            }
2741
2742            let next_out_of_line = decoder.next_out_of_line();
2743            let handles_before = decoder.remaining_handles();
2744            if let Some((inlined, num_bytes, num_handles)) =
2745                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2746            {
2747                let member_inline_size = <fidl::encoding::HandleType<
2748                    fidl::Socket,
2749                    { fidl::ObjectType::SOCKET.into_raw() },
2750                    16389,
2751                > as fidl::encoding::TypeMarker>::inline_size(
2752                    decoder.context
2753                );
2754                if inlined != (member_inline_size <= 4) {
2755                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2756                }
2757                let inner_offset;
2758                let mut inner_depth = depth.clone();
2759                if inlined {
2760                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2761                    inner_offset = next_offset;
2762                } else {
2763                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2764                    inner_depth.increment()?;
2765                }
2766                let val_ref =
2767                self.wav_source.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16389>, fidl::encoding::DefaultFuchsiaResourceDialect));
2768                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16389>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2769                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2770                {
2771                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2772                }
2773                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2774                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2775                }
2776            }
2777
2778            next_offset += envelope_size;
2779            _next_ordinal_to_read += 1;
2780            if next_offset >= end_offset {
2781                return Ok(());
2782            }
2783
2784            // Decode unknown envelopes for gaps in ordinals.
2785            while _next_ordinal_to_read < 2 {
2786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2787                _next_ordinal_to_read += 1;
2788                next_offset += envelope_size;
2789            }
2790
2791            let next_out_of_line = decoder.next_out_of_line();
2792            let handles_before = decoder.remaining_handles();
2793            if let Some((inlined, num_bytes, num_handles)) =
2794                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2795            {
2796                let member_inline_size =
2797                    <PlayDestination as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2798                if inlined != (member_inline_size <= 4) {
2799                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2800                }
2801                let inner_offset;
2802                let mut inner_depth = depth.clone();
2803                if inlined {
2804                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2805                    inner_offset = next_offset;
2806                } else {
2807                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2808                    inner_depth.increment()?;
2809                }
2810                let val_ref = self.destination.get_or_insert_with(|| {
2811                    fidl::new_empty!(PlayDestination, fidl::encoding::DefaultFuchsiaResourceDialect)
2812                });
2813                fidl::decode!(
2814                    PlayDestination,
2815                    fidl::encoding::DefaultFuchsiaResourceDialect,
2816                    val_ref,
2817                    decoder,
2818                    inner_offset,
2819                    inner_depth
2820                )?;
2821                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2822                {
2823                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2824                }
2825                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2826                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2827                }
2828            }
2829
2830            next_offset += envelope_size;
2831            _next_ordinal_to_read += 1;
2832            if next_offset >= end_offset {
2833                return Ok(());
2834            }
2835
2836            // Decode unknown envelopes for gaps in ordinals.
2837            while _next_ordinal_to_read < 3 {
2838                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2839                _next_ordinal_to_read += 1;
2840                next_offset += envelope_size;
2841            }
2842
2843            let next_out_of_line = decoder.next_out_of_line();
2844            let handles_before = decoder.remaining_handles();
2845            if let Some((inlined, num_bytes, num_handles)) =
2846                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2847            {
2848                let member_inline_size =
2849                    <GainSettings as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2850                if inlined != (member_inline_size <= 4) {
2851                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2852                }
2853                let inner_offset;
2854                let mut inner_depth = depth.clone();
2855                if inlined {
2856                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2857                    inner_offset = next_offset;
2858                } else {
2859                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2860                    inner_depth.increment()?;
2861                }
2862                let val_ref = self.gain_settings.get_or_insert_with(|| {
2863                    fidl::new_empty!(GainSettings, fidl::encoding::DefaultFuchsiaResourceDialect)
2864                });
2865                fidl::decode!(
2866                    GainSettings,
2867                    fidl::encoding::DefaultFuchsiaResourceDialect,
2868                    val_ref,
2869                    decoder,
2870                    inner_offset,
2871                    inner_depth
2872                )?;
2873                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2874                {
2875                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2876                }
2877                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2878                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2879                }
2880            }
2881
2882            next_offset += envelope_size;
2883            _next_ordinal_to_read += 1;
2884            if next_offset >= end_offset {
2885                return Ok(());
2886            }
2887
2888            // Decode unknown envelopes for gaps in ordinals.
2889            while _next_ordinal_to_read < 4 {
2890                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2891                _next_ordinal_to_read += 1;
2892                next_offset += envelope_size;
2893            }
2894
2895            let next_out_of_line = decoder.next_out_of_line();
2896            let handles_before = decoder.remaining_handles();
2897            if let Some((inlined, num_bytes, num_handles)) =
2898                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2899            {
2900                let member_inline_size =
2901                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2902                if inlined != (member_inline_size <= 4) {
2903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2904                }
2905                let inner_offset;
2906                let mut inner_depth = depth.clone();
2907                if inlined {
2908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2909                    inner_offset = next_offset;
2910                } else {
2911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2912                    inner_depth.increment()?;
2913                }
2914                let val_ref = self.active_channels_bitmask.get_or_insert_with(|| {
2915                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2916                });
2917                fidl::decode!(
2918                    u64,
2919                    fidl::encoding::DefaultFuchsiaResourceDialect,
2920                    val_ref,
2921                    decoder,
2922                    inner_offset,
2923                    inner_depth
2924                )?;
2925                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2926                {
2927                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2928                }
2929                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2930                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2931                }
2932            }
2933
2934            next_offset += envelope_size;
2935
2936            // Decode the remaining unknown envelopes.
2937            while next_offset < end_offset {
2938                _next_ordinal_to_read += 1;
2939                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2940                next_offset += envelope_size;
2941            }
2942
2943            Ok(())
2944        }
2945    }
2946
2947    impl PlayerPlayResponse {
2948        #[inline(always)]
2949        fn max_ordinal_present(&self) -> u64 {
2950            if let Some(_) = self.bytes_processed {
2951                return 1;
2952            }
2953            0
2954        }
2955    }
2956
2957    impl fidl::encoding::ResourceTypeMarker for PlayerPlayResponse {
2958        type Borrowed<'a> = &'a mut Self;
2959        fn take_or_borrow<'a>(
2960            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2961        ) -> Self::Borrowed<'a> {
2962            value
2963        }
2964    }
2965
2966    unsafe impl fidl::encoding::TypeMarker for PlayerPlayResponse {
2967        type Owned = Self;
2968
2969        #[inline(always)]
2970        fn inline_align(_context: fidl::encoding::Context) -> usize {
2971            8
2972        }
2973
2974        #[inline(always)]
2975        fn inline_size(_context: fidl::encoding::Context) -> usize {
2976            16
2977        }
2978    }
2979
2980    unsafe impl
2981        fidl::encoding::Encode<PlayerPlayResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
2982        for &mut PlayerPlayResponse
2983    {
2984        unsafe fn encode(
2985            self,
2986            encoder: &mut fidl::encoding::Encoder<
2987                '_,
2988                fidl::encoding::DefaultFuchsiaResourceDialect,
2989            >,
2990            offset: usize,
2991            mut depth: fidl::encoding::Depth,
2992        ) -> fidl::Result<()> {
2993            encoder.debug_check_bounds::<PlayerPlayResponse>(offset);
2994            // Vector header
2995            let max_ordinal: u64 = self.max_ordinal_present();
2996            encoder.write_num(max_ordinal, offset);
2997            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2998            // Calling encoder.out_of_line_offset(0) is not allowed.
2999            if max_ordinal == 0 {
3000                return Ok(());
3001            }
3002            depth.increment()?;
3003            let envelope_size = 8;
3004            let bytes_len = max_ordinal as usize * envelope_size;
3005            #[allow(unused_variables)]
3006            let offset = encoder.out_of_line_offset(bytes_len);
3007            let mut _prev_end_offset: usize = 0;
3008            if 1 > max_ordinal {
3009                return Ok(());
3010            }
3011
3012            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3013            // are envelope_size bytes.
3014            let cur_offset: usize = (1 - 1) * envelope_size;
3015
3016            // Zero reserved fields.
3017            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3018
3019            // Safety:
3020            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3021            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3022            //   envelope_size bytes, there is always sufficient room.
3023            fidl::encoding::encode_in_envelope_optional::<
3024                u64,
3025                fidl::encoding::DefaultFuchsiaResourceDialect,
3026            >(
3027                self.bytes_processed.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3028                encoder,
3029                offset + cur_offset,
3030                depth,
3031            )?;
3032
3033            _prev_end_offset = cur_offset + envelope_size;
3034
3035            Ok(())
3036        }
3037    }
3038
3039    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3040        for PlayerPlayResponse
3041    {
3042        #[inline(always)]
3043        fn new_empty() -> Self {
3044            Self::default()
3045        }
3046
3047        unsafe fn decode(
3048            &mut self,
3049            decoder: &mut fidl::encoding::Decoder<
3050                '_,
3051                fidl::encoding::DefaultFuchsiaResourceDialect,
3052            >,
3053            offset: usize,
3054            mut depth: fidl::encoding::Depth,
3055        ) -> fidl::Result<()> {
3056            decoder.debug_check_bounds::<Self>(offset);
3057            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3058                None => return Err(fidl::Error::NotNullable),
3059                Some(len) => len,
3060            };
3061            // Calling decoder.out_of_line_offset(0) is not allowed.
3062            if len == 0 {
3063                return Ok(());
3064            };
3065            depth.increment()?;
3066            let envelope_size = 8;
3067            let bytes_len = len * envelope_size;
3068            let offset = decoder.out_of_line_offset(bytes_len)?;
3069            // Decode the envelope for each type.
3070            let mut _next_ordinal_to_read = 0;
3071            let mut next_offset = offset;
3072            let end_offset = offset + bytes_len;
3073            _next_ordinal_to_read += 1;
3074            if next_offset >= end_offset {
3075                return Ok(());
3076            }
3077
3078            // Decode unknown envelopes for gaps in ordinals.
3079            while _next_ordinal_to_read < 1 {
3080                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3081                _next_ordinal_to_read += 1;
3082                next_offset += envelope_size;
3083            }
3084
3085            let next_out_of_line = decoder.next_out_of_line();
3086            let handles_before = decoder.remaining_handles();
3087            if let Some((inlined, num_bytes, num_handles)) =
3088                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3089            {
3090                let member_inline_size =
3091                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3092                if inlined != (member_inline_size <= 4) {
3093                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3094                }
3095                let inner_offset;
3096                let mut inner_depth = depth.clone();
3097                if inlined {
3098                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3099                    inner_offset = next_offset;
3100                } else {
3101                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3102                    inner_depth.increment()?;
3103                }
3104                let val_ref = self.bytes_processed.get_or_insert_with(|| {
3105                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
3106                });
3107                fidl::decode!(
3108                    u64,
3109                    fidl::encoding::DefaultFuchsiaResourceDialect,
3110                    val_ref,
3111                    decoder,
3112                    inner_offset,
3113                    inner_depth
3114                )?;
3115                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3116                {
3117                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3118                }
3119                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3120                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3121                }
3122            }
3123
3124            next_offset += envelope_size;
3125
3126            // Decode the remaining unknown envelopes.
3127            while next_offset < end_offset {
3128                _next_ordinal_to_read += 1;
3129                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3130                next_offset += envelope_size;
3131            }
3132
3133            Ok(())
3134        }
3135    }
3136
3137    impl RecorderRecordRequest {
3138        #[inline(always)]
3139        fn max_ordinal_present(&self) -> u64 {
3140            if let Some(_) = self.wav_data {
3141                return 7;
3142            }
3143            if let Some(_) = self.buffer_size {
3144                return 6;
3145            }
3146            if let Some(_) = self.gain_settings {
3147                return 5;
3148            }
3149            if let Some(_) = self.canceler {
3150                return 4;
3151            }
3152            if let Some(_) = self.duration {
3153                return 3;
3154            }
3155            if let Some(_) = self.stream_type {
3156                return 2;
3157            }
3158            if let Some(_) = self.source {
3159                return 1;
3160            }
3161            0
3162        }
3163    }
3164
3165    impl fidl::encoding::ResourceTypeMarker for RecorderRecordRequest {
3166        type Borrowed<'a> = &'a mut Self;
3167        fn take_or_borrow<'a>(
3168            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3169        ) -> Self::Borrowed<'a> {
3170            value
3171        }
3172    }
3173
3174    unsafe impl fidl::encoding::TypeMarker for RecorderRecordRequest {
3175        type Owned = Self;
3176
3177        #[inline(always)]
3178        fn inline_align(_context: fidl::encoding::Context) -> usize {
3179            8
3180        }
3181
3182        #[inline(always)]
3183        fn inline_size(_context: fidl::encoding::Context) -> usize {
3184            16
3185        }
3186    }
3187
3188    unsafe impl
3189        fidl::encoding::Encode<RecorderRecordRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3190        for &mut RecorderRecordRequest
3191    {
3192        unsafe fn encode(
3193            self,
3194            encoder: &mut fidl::encoding::Encoder<
3195                '_,
3196                fidl::encoding::DefaultFuchsiaResourceDialect,
3197            >,
3198            offset: usize,
3199            mut depth: fidl::encoding::Depth,
3200        ) -> fidl::Result<()> {
3201            encoder.debug_check_bounds::<RecorderRecordRequest>(offset);
3202            // Vector header
3203            let max_ordinal: u64 = self.max_ordinal_present();
3204            encoder.write_num(max_ordinal, offset);
3205            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3206            // Calling encoder.out_of_line_offset(0) is not allowed.
3207            if max_ordinal == 0 {
3208                return Ok(());
3209            }
3210            depth.increment()?;
3211            let envelope_size = 8;
3212            let bytes_len = max_ordinal as usize * envelope_size;
3213            #[allow(unused_variables)]
3214            let offset = encoder.out_of_line_offset(bytes_len);
3215            let mut _prev_end_offset: usize = 0;
3216            if 1 > max_ordinal {
3217                return Ok(());
3218            }
3219
3220            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3221            // are envelope_size bytes.
3222            let cur_offset: usize = (1 - 1) * envelope_size;
3223
3224            // Zero reserved fields.
3225            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3226
3227            // Safety:
3228            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3229            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3230            //   envelope_size bytes, there is always sufficient room.
3231            fidl::encoding::encode_in_envelope_optional::<
3232                RecordSource,
3233                fidl::encoding::DefaultFuchsiaResourceDialect,
3234            >(
3235                self.source.as_ref().map(<RecordSource as fidl::encoding::ValueTypeMarker>::borrow),
3236                encoder,
3237                offset + cur_offset,
3238                depth,
3239            )?;
3240
3241            _prev_end_offset = cur_offset + envelope_size;
3242            if 2 > max_ordinal {
3243                return Ok(());
3244            }
3245
3246            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3247            // are envelope_size bytes.
3248            let cur_offset: usize = (2 - 1) * envelope_size;
3249
3250            // Zero reserved fields.
3251            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3252
3253            // Safety:
3254            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3255            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3256            //   envelope_size bytes, there is always sufficient room.
3257            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_media::AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>(
3258            self.stream_type.as_ref().map(<fidl_fuchsia_media::AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow),
3259            encoder, offset + cur_offset, depth
3260        )?;
3261
3262            _prev_end_offset = cur_offset + envelope_size;
3263            if 3 > max_ordinal {
3264                return Ok(());
3265            }
3266
3267            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3268            // are envelope_size bytes.
3269            let cur_offset: usize = (3 - 1) * envelope_size;
3270
3271            // Zero reserved fields.
3272            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3273
3274            // Safety:
3275            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3276            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3277            //   envelope_size bytes, there is always sufficient room.
3278            fidl::encoding::encode_in_envelope_optional::<
3279                i64,
3280                fidl::encoding::DefaultFuchsiaResourceDialect,
3281            >(
3282                self.duration.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
3283                encoder,
3284                offset + cur_offset,
3285                depth,
3286            )?;
3287
3288            _prev_end_offset = cur_offset + envelope_size;
3289            if 4 > max_ordinal {
3290                return Ok(());
3291            }
3292
3293            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3294            // are envelope_size bytes.
3295            let cur_offset: usize = (4 - 1) * envelope_size;
3296
3297            // Zero reserved fields.
3298            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3299
3300            // Safety:
3301            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3302            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3303            //   envelope_size bytes, there is always sufficient room.
3304            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordCancelerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3305            self.canceler.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordCancelerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3306            encoder, offset + cur_offset, depth
3307        )?;
3308
3309            _prev_end_offset = cur_offset + envelope_size;
3310            if 5 > max_ordinal {
3311                return Ok(());
3312            }
3313
3314            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3315            // are envelope_size bytes.
3316            let cur_offset: usize = (5 - 1) * envelope_size;
3317
3318            // Zero reserved fields.
3319            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3320
3321            // Safety:
3322            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3323            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3324            //   envelope_size bytes, there is always sufficient room.
3325            fidl::encoding::encode_in_envelope_optional::<
3326                GainSettings,
3327                fidl::encoding::DefaultFuchsiaResourceDialect,
3328            >(
3329                self.gain_settings
3330                    .as_ref()
3331                    .map(<GainSettings as fidl::encoding::ValueTypeMarker>::borrow),
3332                encoder,
3333                offset + cur_offset,
3334                depth,
3335            )?;
3336
3337            _prev_end_offset = cur_offset + envelope_size;
3338            if 6 > max_ordinal {
3339                return Ok(());
3340            }
3341
3342            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3343            // are envelope_size bytes.
3344            let cur_offset: usize = (6 - 1) * envelope_size;
3345
3346            // Zero reserved fields.
3347            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3348
3349            // Safety:
3350            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3351            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3352            //   envelope_size bytes, there is always sufficient room.
3353            fidl::encoding::encode_in_envelope_optional::<
3354                u64,
3355                fidl::encoding::DefaultFuchsiaResourceDialect,
3356            >(
3357                self.buffer_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3358                encoder,
3359                offset + cur_offset,
3360                depth,
3361            )?;
3362
3363            _prev_end_offset = cur_offset + envelope_size;
3364            if 7 > max_ordinal {
3365                return Ok(());
3366            }
3367
3368            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3369            // are envelope_size bytes.
3370            let cur_offset: usize = (7 - 1) * envelope_size;
3371
3372            // Zero reserved fields.
3373            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3374
3375            // Safety:
3376            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3377            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3378            //   envelope_size bytes, there is always sufficient room.
3379            fidl::encoding::encode_in_envelope_optional::<
3380                fidl::encoding::HandleType<
3381                    fidl::Socket,
3382                    { fidl::ObjectType::SOCKET.into_raw() },
3383                    2147483648,
3384                >,
3385                fidl::encoding::DefaultFuchsiaResourceDialect,
3386            >(
3387                self.wav_data.as_mut().map(
3388                    <fidl::encoding::HandleType<
3389                        fidl::Socket,
3390                        { fidl::ObjectType::SOCKET.into_raw() },
3391                        2147483648,
3392                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3393                ),
3394                encoder,
3395                offset + cur_offset,
3396                depth,
3397            )?;
3398
3399            _prev_end_offset = cur_offset + envelope_size;
3400
3401            Ok(())
3402        }
3403    }
3404
3405    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3406        for RecorderRecordRequest
3407    {
3408        #[inline(always)]
3409        fn new_empty() -> Self {
3410            Self::default()
3411        }
3412
3413        unsafe fn decode(
3414            &mut self,
3415            decoder: &mut fidl::encoding::Decoder<
3416                '_,
3417                fidl::encoding::DefaultFuchsiaResourceDialect,
3418            >,
3419            offset: usize,
3420            mut depth: fidl::encoding::Depth,
3421        ) -> fidl::Result<()> {
3422            decoder.debug_check_bounds::<Self>(offset);
3423            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3424                None => return Err(fidl::Error::NotNullable),
3425                Some(len) => len,
3426            };
3427            // Calling decoder.out_of_line_offset(0) is not allowed.
3428            if len == 0 {
3429                return Ok(());
3430            };
3431            depth.increment()?;
3432            let envelope_size = 8;
3433            let bytes_len = len * envelope_size;
3434            let offset = decoder.out_of_line_offset(bytes_len)?;
3435            // Decode the envelope for each type.
3436            let mut _next_ordinal_to_read = 0;
3437            let mut next_offset = offset;
3438            let end_offset = offset + bytes_len;
3439            _next_ordinal_to_read += 1;
3440            if next_offset >= end_offset {
3441                return Ok(());
3442            }
3443
3444            // Decode unknown envelopes for gaps in ordinals.
3445            while _next_ordinal_to_read < 1 {
3446                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3447                _next_ordinal_to_read += 1;
3448                next_offset += envelope_size;
3449            }
3450
3451            let next_out_of_line = decoder.next_out_of_line();
3452            let handles_before = decoder.remaining_handles();
3453            if let Some((inlined, num_bytes, num_handles)) =
3454                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3455            {
3456                let member_inline_size =
3457                    <RecordSource as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3458                if inlined != (member_inline_size <= 4) {
3459                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3460                }
3461                let inner_offset;
3462                let mut inner_depth = depth.clone();
3463                if inlined {
3464                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3465                    inner_offset = next_offset;
3466                } else {
3467                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3468                    inner_depth.increment()?;
3469                }
3470                let val_ref = self.source.get_or_insert_with(|| {
3471                    fidl::new_empty!(RecordSource, fidl::encoding::DefaultFuchsiaResourceDialect)
3472                });
3473                fidl::decode!(
3474                    RecordSource,
3475                    fidl::encoding::DefaultFuchsiaResourceDialect,
3476                    val_ref,
3477                    decoder,
3478                    inner_offset,
3479                    inner_depth
3480                )?;
3481                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3482                {
3483                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3484                }
3485                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3486                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3487                }
3488            }
3489
3490            next_offset += envelope_size;
3491            _next_ordinal_to_read += 1;
3492            if next_offset >= end_offset {
3493                return Ok(());
3494            }
3495
3496            // Decode unknown envelopes for gaps in ordinals.
3497            while _next_ordinal_to_read < 2 {
3498                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3499                _next_ordinal_to_read += 1;
3500                next_offset += envelope_size;
3501            }
3502
3503            let next_out_of_line = decoder.next_out_of_line();
3504            let handles_before = decoder.remaining_handles();
3505            if let Some((inlined, num_bytes, num_handles)) =
3506                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3507            {
3508                let member_inline_size = <fidl_fuchsia_media::AudioStreamType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3509                if inlined != (member_inline_size <= 4) {
3510                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3511                }
3512                let inner_offset;
3513                let mut inner_depth = depth.clone();
3514                if inlined {
3515                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3516                    inner_offset = next_offset;
3517                } else {
3518                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3519                    inner_depth.increment()?;
3520                }
3521                let val_ref = self.stream_type.get_or_insert_with(|| {
3522                    fidl::new_empty!(
3523                        fidl_fuchsia_media::AudioStreamType,
3524                        fidl::encoding::DefaultFuchsiaResourceDialect
3525                    )
3526                });
3527                fidl::decode!(
3528                    fidl_fuchsia_media::AudioStreamType,
3529                    fidl::encoding::DefaultFuchsiaResourceDialect,
3530                    val_ref,
3531                    decoder,
3532                    inner_offset,
3533                    inner_depth
3534                )?;
3535                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3536                {
3537                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3538                }
3539                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3540                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3541                }
3542            }
3543
3544            next_offset += envelope_size;
3545            _next_ordinal_to_read += 1;
3546            if next_offset >= end_offset {
3547                return Ok(());
3548            }
3549
3550            // Decode unknown envelopes for gaps in ordinals.
3551            while _next_ordinal_to_read < 3 {
3552                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3553                _next_ordinal_to_read += 1;
3554                next_offset += envelope_size;
3555            }
3556
3557            let next_out_of_line = decoder.next_out_of_line();
3558            let handles_before = decoder.remaining_handles();
3559            if let Some((inlined, num_bytes, num_handles)) =
3560                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3561            {
3562                let member_inline_size =
3563                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3564                if inlined != (member_inline_size <= 4) {
3565                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3566                }
3567                let inner_offset;
3568                let mut inner_depth = depth.clone();
3569                if inlined {
3570                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3571                    inner_offset = next_offset;
3572                } else {
3573                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3574                    inner_depth.increment()?;
3575                }
3576                let val_ref = self.duration.get_or_insert_with(|| {
3577                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
3578                });
3579                fidl::decode!(
3580                    i64,
3581                    fidl::encoding::DefaultFuchsiaResourceDialect,
3582                    val_ref,
3583                    decoder,
3584                    inner_offset,
3585                    inner_depth
3586                )?;
3587                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3588                {
3589                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3590                }
3591                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3592                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3593                }
3594            }
3595
3596            next_offset += envelope_size;
3597            _next_ordinal_to_read += 1;
3598            if next_offset >= end_offset {
3599                return Ok(());
3600            }
3601
3602            // Decode unknown envelopes for gaps in ordinals.
3603            while _next_ordinal_to_read < 4 {
3604                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3605                _next_ordinal_to_read += 1;
3606                next_offset += envelope_size;
3607            }
3608
3609            let next_out_of_line = decoder.next_out_of_line();
3610            let handles_before = decoder.remaining_handles();
3611            if let Some((inlined, num_bytes, num_handles)) =
3612                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3613            {
3614                let member_inline_size = <fidl::encoding::Endpoint<
3615                    fidl::endpoints::ServerEnd<RecordCancelerMarker>,
3616                > as fidl::encoding::TypeMarker>::inline_size(
3617                    decoder.context
3618                );
3619                if inlined != (member_inline_size <= 4) {
3620                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3621                }
3622                let inner_offset;
3623                let mut inner_depth = depth.clone();
3624                if inlined {
3625                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3626                    inner_offset = next_offset;
3627                } else {
3628                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3629                    inner_depth.increment()?;
3630                }
3631                let val_ref = self.canceler.get_or_insert_with(|| {
3632                    fidl::new_empty!(
3633                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordCancelerMarker>>,
3634                        fidl::encoding::DefaultFuchsiaResourceDialect
3635                    )
3636                });
3637                fidl::decode!(
3638                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordCancelerMarker>>,
3639                    fidl::encoding::DefaultFuchsiaResourceDialect,
3640                    val_ref,
3641                    decoder,
3642                    inner_offset,
3643                    inner_depth
3644                )?;
3645                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3646                {
3647                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3648                }
3649                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3650                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3651                }
3652            }
3653
3654            next_offset += envelope_size;
3655            _next_ordinal_to_read += 1;
3656            if next_offset >= end_offset {
3657                return Ok(());
3658            }
3659
3660            // Decode unknown envelopes for gaps in ordinals.
3661            while _next_ordinal_to_read < 5 {
3662                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3663                _next_ordinal_to_read += 1;
3664                next_offset += envelope_size;
3665            }
3666
3667            let next_out_of_line = decoder.next_out_of_line();
3668            let handles_before = decoder.remaining_handles();
3669            if let Some((inlined, num_bytes, num_handles)) =
3670                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3671            {
3672                let member_inline_size =
3673                    <GainSettings as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3674                if inlined != (member_inline_size <= 4) {
3675                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3676                }
3677                let inner_offset;
3678                let mut inner_depth = depth.clone();
3679                if inlined {
3680                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3681                    inner_offset = next_offset;
3682                } else {
3683                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3684                    inner_depth.increment()?;
3685                }
3686                let val_ref = self.gain_settings.get_or_insert_with(|| {
3687                    fidl::new_empty!(GainSettings, fidl::encoding::DefaultFuchsiaResourceDialect)
3688                });
3689                fidl::decode!(
3690                    GainSettings,
3691                    fidl::encoding::DefaultFuchsiaResourceDialect,
3692                    val_ref,
3693                    decoder,
3694                    inner_offset,
3695                    inner_depth
3696                )?;
3697                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3698                {
3699                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3700                }
3701                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3702                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3703                }
3704            }
3705
3706            next_offset += envelope_size;
3707            _next_ordinal_to_read += 1;
3708            if next_offset >= end_offset {
3709                return Ok(());
3710            }
3711
3712            // Decode unknown envelopes for gaps in ordinals.
3713            while _next_ordinal_to_read < 6 {
3714                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3715                _next_ordinal_to_read += 1;
3716                next_offset += envelope_size;
3717            }
3718
3719            let next_out_of_line = decoder.next_out_of_line();
3720            let handles_before = decoder.remaining_handles();
3721            if let Some((inlined, num_bytes, num_handles)) =
3722                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3723            {
3724                let member_inline_size =
3725                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3726                if inlined != (member_inline_size <= 4) {
3727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3728                }
3729                let inner_offset;
3730                let mut inner_depth = depth.clone();
3731                if inlined {
3732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3733                    inner_offset = next_offset;
3734                } else {
3735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3736                    inner_depth.increment()?;
3737                }
3738                let val_ref = self.buffer_size.get_or_insert_with(|| {
3739                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
3740                });
3741                fidl::decode!(
3742                    u64,
3743                    fidl::encoding::DefaultFuchsiaResourceDialect,
3744                    val_ref,
3745                    decoder,
3746                    inner_offset,
3747                    inner_depth
3748                )?;
3749                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3750                {
3751                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3752                }
3753                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3754                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3755                }
3756            }
3757
3758            next_offset += envelope_size;
3759            _next_ordinal_to_read += 1;
3760            if next_offset >= end_offset {
3761                return Ok(());
3762            }
3763
3764            // Decode unknown envelopes for gaps in ordinals.
3765            while _next_ordinal_to_read < 7 {
3766                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3767                _next_ordinal_to_read += 1;
3768                next_offset += envelope_size;
3769            }
3770
3771            let next_out_of_line = decoder.next_out_of_line();
3772            let handles_before = decoder.remaining_handles();
3773            if let Some((inlined, num_bytes, num_handles)) =
3774                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3775            {
3776                let member_inline_size = <fidl::encoding::HandleType<
3777                    fidl::Socket,
3778                    { fidl::ObjectType::SOCKET.into_raw() },
3779                    2147483648,
3780                > as fidl::encoding::TypeMarker>::inline_size(
3781                    decoder.context
3782                );
3783                if inlined != (member_inline_size <= 4) {
3784                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3785                }
3786                let inner_offset;
3787                let mut inner_depth = depth.clone();
3788                if inlined {
3789                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3790                    inner_offset = next_offset;
3791                } else {
3792                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3793                    inner_depth.increment()?;
3794                }
3795                let val_ref =
3796                self.wav_data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3797                fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3798                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3799                {
3800                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3801                }
3802                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3803                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3804                }
3805            }
3806
3807            next_offset += envelope_size;
3808
3809            // Decode the remaining unknown envelopes.
3810            while next_offset < end_offset {
3811                _next_ordinal_to_read += 1;
3812                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3813                next_offset += envelope_size;
3814            }
3815
3816            Ok(())
3817        }
3818    }
3819
3820    impl RecorderRecordResponse {
3821        #[inline(always)]
3822        fn max_ordinal_present(&self) -> u64 {
3823            if let Some(_) = self.late_wakeups {
3824                return 3;
3825            }
3826            if let Some(_) = self.packets_processed {
3827                return 2;
3828            }
3829            if let Some(_) = self.bytes_processed {
3830                return 1;
3831            }
3832            0
3833        }
3834    }
3835
3836    impl fidl::encoding::ResourceTypeMarker for RecorderRecordResponse {
3837        type Borrowed<'a> = &'a mut Self;
3838        fn take_or_borrow<'a>(
3839            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3840        ) -> Self::Borrowed<'a> {
3841            value
3842        }
3843    }
3844
3845    unsafe impl fidl::encoding::TypeMarker for RecorderRecordResponse {
3846        type Owned = Self;
3847
3848        #[inline(always)]
3849        fn inline_align(_context: fidl::encoding::Context) -> usize {
3850            8
3851        }
3852
3853        #[inline(always)]
3854        fn inline_size(_context: fidl::encoding::Context) -> usize {
3855            16
3856        }
3857    }
3858
3859    unsafe impl
3860        fidl::encoding::Encode<
3861            RecorderRecordResponse,
3862            fidl::encoding::DefaultFuchsiaResourceDialect,
3863        > for &mut RecorderRecordResponse
3864    {
3865        unsafe fn encode(
3866            self,
3867            encoder: &mut fidl::encoding::Encoder<
3868                '_,
3869                fidl::encoding::DefaultFuchsiaResourceDialect,
3870            >,
3871            offset: usize,
3872            mut depth: fidl::encoding::Depth,
3873        ) -> fidl::Result<()> {
3874            encoder.debug_check_bounds::<RecorderRecordResponse>(offset);
3875            // Vector header
3876            let max_ordinal: u64 = self.max_ordinal_present();
3877            encoder.write_num(max_ordinal, offset);
3878            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3879            // Calling encoder.out_of_line_offset(0) is not allowed.
3880            if max_ordinal == 0 {
3881                return Ok(());
3882            }
3883            depth.increment()?;
3884            let envelope_size = 8;
3885            let bytes_len = max_ordinal as usize * envelope_size;
3886            #[allow(unused_variables)]
3887            let offset = encoder.out_of_line_offset(bytes_len);
3888            let mut _prev_end_offset: usize = 0;
3889            if 1 > max_ordinal {
3890                return Ok(());
3891            }
3892
3893            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3894            // are envelope_size bytes.
3895            let cur_offset: usize = (1 - 1) * envelope_size;
3896
3897            // Zero reserved fields.
3898            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3899
3900            // Safety:
3901            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3902            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3903            //   envelope_size bytes, there is always sufficient room.
3904            fidl::encoding::encode_in_envelope_optional::<
3905                u64,
3906                fidl::encoding::DefaultFuchsiaResourceDialect,
3907            >(
3908                self.bytes_processed.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3909                encoder,
3910                offset + cur_offset,
3911                depth,
3912            )?;
3913
3914            _prev_end_offset = cur_offset + envelope_size;
3915            if 2 > max_ordinal {
3916                return Ok(());
3917            }
3918
3919            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3920            // are envelope_size bytes.
3921            let cur_offset: usize = (2 - 1) * envelope_size;
3922
3923            // Zero reserved fields.
3924            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3925
3926            // Safety:
3927            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3928            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3929            //   envelope_size bytes, there is always sufficient room.
3930            fidl::encoding::encode_in_envelope_optional::<
3931                u64,
3932                fidl::encoding::DefaultFuchsiaResourceDialect,
3933            >(
3934                self.packets_processed
3935                    .as_ref()
3936                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3937                encoder,
3938                offset + cur_offset,
3939                depth,
3940            )?;
3941
3942            _prev_end_offset = cur_offset + envelope_size;
3943            if 3 > max_ordinal {
3944                return Ok(());
3945            }
3946
3947            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3948            // are envelope_size bytes.
3949            let cur_offset: usize = (3 - 1) * envelope_size;
3950
3951            // Zero reserved fields.
3952            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3953
3954            // Safety:
3955            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3956            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3957            //   envelope_size bytes, there is always sufficient room.
3958            fidl::encoding::encode_in_envelope_optional::<
3959                u64,
3960                fidl::encoding::DefaultFuchsiaResourceDialect,
3961            >(
3962                self.late_wakeups.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
3963                encoder,
3964                offset + cur_offset,
3965                depth,
3966            )?;
3967
3968            _prev_end_offset = cur_offset + envelope_size;
3969
3970            Ok(())
3971        }
3972    }
3973
3974    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3975        for RecorderRecordResponse
3976    {
3977        #[inline(always)]
3978        fn new_empty() -> Self {
3979            Self::default()
3980        }
3981
3982        unsafe fn decode(
3983            &mut self,
3984            decoder: &mut fidl::encoding::Decoder<
3985                '_,
3986                fidl::encoding::DefaultFuchsiaResourceDialect,
3987            >,
3988            offset: usize,
3989            mut depth: fidl::encoding::Depth,
3990        ) -> fidl::Result<()> {
3991            decoder.debug_check_bounds::<Self>(offset);
3992            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3993                None => return Err(fidl::Error::NotNullable),
3994                Some(len) => len,
3995            };
3996            // Calling decoder.out_of_line_offset(0) is not allowed.
3997            if len == 0 {
3998                return Ok(());
3999            };
4000            depth.increment()?;
4001            let envelope_size = 8;
4002            let bytes_len = len * envelope_size;
4003            let offset = decoder.out_of_line_offset(bytes_len)?;
4004            // Decode the envelope for each type.
4005            let mut _next_ordinal_to_read = 0;
4006            let mut next_offset = offset;
4007            let end_offset = offset + bytes_len;
4008            _next_ordinal_to_read += 1;
4009            if next_offset >= end_offset {
4010                return Ok(());
4011            }
4012
4013            // Decode unknown envelopes for gaps in ordinals.
4014            while _next_ordinal_to_read < 1 {
4015                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4016                _next_ordinal_to_read += 1;
4017                next_offset += envelope_size;
4018            }
4019
4020            let next_out_of_line = decoder.next_out_of_line();
4021            let handles_before = decoder.remaining_handles();
4022            if let Some((inlined, num_bytes, num_handles)) =
4023                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4024            {
4025                let member_inline_size =
4026                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4027                if inlined != (member_inline_size <= 4) {
4028                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4029                }
4030                let inner_offset;
4031                let mut inner_depth = depth.clone();
4032                if inlined {
4033                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4034                    inner_offset = next_offset;
4035                } else {
4036                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4037                    inner_depth.increment()?;
4038                }
4039                let val_ref = self.bytes_processed.get_or_insert_with(|| {
4040                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
4041                });
4042                fidl::decode!(
4043                    u64,
4044                    fidl::encoding::DefaultFuchsiaResourceDialect,
4045                    val_ref,
4046                    decoder,
4047                    inner_offset,
4048                    inner_depth
4049                )?;
4050                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4051                {
4052                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4053                }
4054                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4055                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4056                }
4057            }
4058
4059            next_offset += envelope_size;
4060            _next_ordinal_to_read += 1;
4061            if next_offset >= end_offset {
4062                return Ok(());
4063            }
4064
4065            // Decode unknown envelopes for gaps in ordinals.
4066            while _next_ordinal_to_read < 2 {
4067                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4068                _next_ordinal_to_read += 1;
4069                next_offset += envelope_size;
4070            }
4071
4072            let next_out_of_line = decoder.next_out_of_line();
4073            let handles_before = decoder.remaining_handles();
4074            if let Some((inlined, num_bytes, num_handles)) =
4075                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4076            {
4077                let member_inline_size =
4078                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4079                if inlined != (member_inline_size <= 4) {
4080                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4081                }
4082                let inner_offset;
4083                let mut inner_depth = depth.clone();
4084                if inlined {
4085                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4086                    inner_offset = next_offset;
4087                } else {
4088                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4089                    inner_depth.increment()?;
4090                }
4091                let val_ref = self.packets_processed.get_or_insert_with(|| {
4092                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
4093                });
4094                fidl::decode!(
4095                    u64,
4096                    fidl::encoding::DefaultFuchsiaResourceDialect,
4097                    val_ref,
4098                    decoder,
4099                    inner_offset,
4100                    inner_depth
4101                )?;
4102                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4103                {
4104                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4105                }
4106                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4107                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4108                }
4109            }
4110
4111            next_offset += envelope_size;
4112            _next_ordinal_to_read += 1;
4113            if next_offset >= end_offset {
4114                return Ok(());
4115            }
4116
4117            // Decode unknown envelopes for gaps in ordinals.
4118            while _next_ordinal_to_read < 3 {
4119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4120                _next_ordinal_to_read += 1;
4121                next_offset += envelope_size;
4122            }
4123
4124            let next_out_of_line = decoder.next_out_of_line();
4125            let handles_before = decoder.remaining_handles();
4126            if let Some((inlined, num_bytes, num_handles)) =
4127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4128            {
4129                let member_inline_size =
4130                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4131                if inlined != (member_inline_size <= 4) {
4132                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4133                }
4134                let inner_offset;
4135                let mut inner_depth = depth.clone();
4136                if inlined {
4137                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4138                    inner_offset = next_offset;
4139                } else {
4140                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4141                    inner_depth.increment()?;
4142                }
4143                let val_ref = self.late_wakeups.get_or_insert_with(|| {
4144                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
4145                });
4146                fidl::decode!(
4147                    u64,
4148                    fidl::encoding::DefaultFuchsiaResourceDialect,
4149                    val_ref,
4150                    decoder,
4151                    inner_offset,
4152                    inner_depth
4153                )?;
4154                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4155                {
4156                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4157                }
4158                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4159                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4160                }
4161            }
4162
4163            next_offset += envelope_size;
4164
4165            // Decode the remaining unknown envelopes.
4166            while next_offset < end_offset {
4167                _next_ordinal_to_read += 1;
4168                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4169                next_offset += envelope_size;
4170            }
4171
4172            Ok(())
4173        }
4174    }
4175}