fidl_fuchsia_audio_controller/
fidl_fuchsia_audio_controller.rs

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