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