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