fidl_fuchsia_test_audio/
fidl_fuchsia_test_audio.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_test_audio__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CaptureGetOutputAudioResponse {
16    pub audio_reader: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for CaptureGetOutputAudioResponse
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25#[repr(C)]
26pub struct InjectionClearInputAudioRequest {
27    pub index: i32,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for InjectionClearInputAudioRequest
32{
33}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36#[repr(C)]
37pub struct InjectionStartInputInjectionRequest {
38    pub index: i32,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
42    for InjectionStartInputInjectionRequest
43{
44}
45
46#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
47pub struct InjectionWriteInputAudioRequest {
48    pub index: i32,
49    pub audio_writer: fidl::Socket,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for InjectionWriteInputAudioRequest
54{
55}
56
57#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
58pub struct CaptureMarker;
59
60impl fidl::endpoints::ProtocolMarker for CaptureMarker {
61    type Proxy = CaptureProxy;
62    type RequestStream = CaptureRequestStream;
63    #[cfg(target_os = "fuchsia")]
64    type SynchronousProxy = CaptureSynchronousProxy;
65
66    const DEBUG_NAME: &'static str = "fuchsia.test.audio.Capture";
67}
68impl fidl::endpoints::DiscoverableProtocolMarker for CaptureMarker {}
69pub type CaptureStartOutputCaptureResult = Result<(), AudioTestError>;
70pub type CaptureStopOutputCaptureResult = Result<(), AudioTestError>;
71pub type CaptureGetOutputAudioResult = Result<fidl::Socket, AudioTestError>;
72
73pub trait CaptureProxyInterface: Send + Sync {
74    type StartOutputCaptureResponseFut: std::future::Future<Output = Result<CaptureStartOutputCaptureResult, fidl::Error>>
75        + Send;
76    fn r#start_output_capture(&self) -> Self::StartOutputCaptureResponseFut;
77    type StopOutputCaptureResponseFut: std::future::Future<Output = Result<CaptureStopOutputCaptureResult, fidl::Error>>
78        + Send;
79    fn r#stop_output_capture(&self) -> Self::StopOutputCaptureResponseFut;
80    type GetOutputAudioResponseFut: std::future::Future<Output = Result<CaptureGetOutputAudioResult, fidl::Error>>
81        + Send;
82    fn r#get_output_audio(&self) -> Self::GetOutputAudioResponseFut;
83}
84#[derive(Debug)]
85#[cfg(target_os = "fuchsia")]
86pub struct CaptureSynchronousProxy {
87    client: fidl::client::sync::Client,
88}
89
90#[cfg(target_os = "fuchsia")]
91impl fidl::endpoints::SynchronousProxy for CaptureSynchronousProxy {
92    type Proxy = CaptureProxy;
93    type Protocol = CaptureMarker;
94
95    fn from_channel(inner: fidl::Channel) -> Self {
96        Self::new(inner)
97    }
98
99    fn into_channel(self) -> fidl::Channel {
100        self.client.into_channel()
101    }
102
103    fn as_channel(&self) -> &fidl::Channel {
104        self.client.as_channel()
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl CaptureSynchronousProxy {
110    pub fn new(channel: fidl::Channel) -> Self {
111        let protocol_name = <CaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
112        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
113    }
114
115    pub fn into_channel(self) -> fidl::Channel {
116        self.client.into_channel()
117    }
118
119    /// Waits until an event arrives and returns it. It is safe for other
120    /// threads to make concurrent requests while waiting for an event.
121    pub fn wait_for_event(
122        &self,
123        deadline: zx::MonotonicInstant,
124    ) -> Result<CaptureEvent, fidl::Error> {
125        CaptureEvent::decode(self.client.wait_for_event(deadline)?)
126    }
127
128    /// Start capturing the outgoing audio for this device.
129    ///
130    /// A virtual output device receives what would have played through the device's speakers.
131    /// This method reads from that virtual output device, into an internal buffer.
132    ///
133    /// After calling this method, use `StopOutputCapture` to stop recording output and
134    /// then `GetOutputAudio` to retrieve this captured audio.
135    ///
136    /// - response `error` description of failure action to take.
137    pub fn r#start_output_capture(
138        &self,
139        ___deadline: zx::MonotonicInstant,
140    ) -> Result<CaptureStartOutputCaptureResult, fidl::Error> {
141        let _response = self.client.send_query::<
142            fidl::encoding::EmptyPayload,
143            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
144        >(
145            (),
146            0x3da5afb01b70be17,
147            fidl::encoding::DynamicFlags::empty(),
148            ___deadline,
149        )?;
150        Ok(_response.map(|x| x))
151    }
152
153    /// Stop capturing the outgoing audio for this device.
154    ///
155    /// This method will succeed even if no output capture has been started.
156    ///
157    /// After calling this method, use `GetOutputAudio` to retrieve the captured
158    /// audio from the virtual device's internal buffer and return it to the client.
159    ///
160    /// - response `error` description of failure action to take.
161    pub fn r#stop_output_capture(
162        &self,
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<CaptureStopOutputCaptureResult, fidl::Error> {
165        let _response = self.client.send_query::<
166            fidl::encoding::EmptyPayload,
167            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
168        >(
169            (),
170            0x4598c765e8859b6b,
171            fidl::encoding::DynamicFlags::empty(),
172            ___deadline,
173        )?;
174        Ok(_response.map(|x| x))
175    }
176
177    /// Extract the captured outgoing audio data through a socket.
178    ///
179    /// The socket is closed once it is fully drained.
180    ///
181    /// User should have first called `StartOutputCapture` and `StopOutputCapture`. This method will
182    /// return the contents of the internal buffer that was populated between the calls to those
183    /// two methods.
184    ///
185    /// Audio output format is 2-channel 48kHz 16-bit PCM.
186    ///
187    /// + request `audio_reader` socket where full captured audio data will be streamed.
188    /// - response `error` description of failure action to take.
189    pub fn r#get_output_audio(
190        &self,
191        ___deadline: zx::MonotonicInstant,
192    ) -> Result<CaptureGetOutputAudioResult, fidl::Error> {
193        let _response = self.client.send_query::<
194            fidl::encoding::EmptyPayload,
195            fidl::encoding::ResultType<CaptureGetOutputAudioResponse, AudioTestError>,
196        >(
197            (),
198            0x23960702c8a96e54,
199            fidl::encoding::DynamicFlags::empty(),
200            ___deadline,
201        )?;
202        Ok(_response.map(|x| x.audio_reader))
203    }
204}
205
206#[cfg(target_os = "fuchsia")]
207impl From<CaptureSynchronousProxy> for zx::Handle {
208    fn from(value: CaptureSynchronousProxy) -> Self {
209        value.into_channel().into()
210    }
211}
212
213#[cfg(target_os = "fuchsia")]
214impl From<fidl::Channel> for CaptureSynchronousProxy {
215    fn from(value: fidl::Channel) -> Self {
216        Self::new(value)
217    }
218}
219
220#[derive(Debug, Clone)]
221pub struct CaptureProxy {
222    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
223}
224
225impl fidl::endpoints::Proxy for CaptureProxy {
226    type Protocol = CaptureMarker;
227
228    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
229        Self::new(inner)
230    }
231
232    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
233        self.client.into_channel().map_err(|client| Self { client })
234    }
235
236    fn as_channel(&self) -> &::fidl::AsyncChannel {
237        self.client.as_channel()
238    }
239}
240
241impl CaptureProxy {
242    /// Create a new Proxy for fuchsia.test.audio/Capture.
243    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
244        let protocol_name = <CaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
245        Self { client: fidl::client::Client::new(channel, protocol_name) }
246    }
247
248    /// Get a Stream of events from the remote end of the protocol.
249    ///
250    /// # Panics
251    ///
252    /// Panics if the event stream was already taken.
253    pub fn take_event_stream(&self) -> CaptureEventStream {
254        CaptureEventStream { event_receiver: self.client.take_event_receiver() }
255    }
256
257    /// Start capturing the outgoing audio for this device.
258    ///
259    /// A virtual output device receives what would have played through the device's speakers.
260    /// This method reads from that virtual output device, into an internal buffer.
261    ///
262    /// After calling this method, use `StopOutputCapture` to stop recording output and
263    /// then `GetOutputAudio` to retrieve this captured audio.
264    ///
265    /// - response `error` description of failure action to take.
266    pub fn r#start_output_capture(
267        &self,
268    ) -> fidl::client::QueryResponseFut<
269        CaptureStartOutputCaptureResult,
270        fidl::encoding::DefaultFuchsiaResourceDialect,
271    > {
272        CaptureProxyInterface::r#start_output_capture(self)
273    }
274
275    /// Stop capturing the outgoing audio for this device.
276    ///
277    /// This method will succeed even if no output capture has been started.
278    ///
279    /// After calling this method, use `GetOutputAudio` to retrieve the captured
280    /// audio from the virtual device's internal buffer and return it to the client.
281    ///
282    /// - response `error` description of failure action to take.
283    pub fn r#stop_output_capture(
284        &self,
285    ) -> fidl::client::QueryResponseFut<
286        CaptureStopOutputCaptureResult,
287        fidl::encoding::DefaultFuchsiaResourceDialect,
288    > {
289        CaptureProxyInterface::r#stop_output_capture(self)
290    }
291
292    /// Extract the captured outgoing audio data through a socket.
293    ///
294    /// The socket is closed once it is fully drained.
295    ///
296    /// User should have first called `StartOutputCapture` and `StopOutputCapture`. This method will
297    /// return the contents of the internal buffer that was populated between the calls to those
298    /// two methods.
299    ///
300    /// Audio output format is 2-channel 48kHz 16-bit PCM.
301    ///
302    /// + request `audio_reader` socket where full captured audio data will be streamed.
303    /// - response `error` description of failure action to take.
304    pub fn r#get_output_audio(
305        &self,
306    ) -> fidl::client::QueryResponseFut<
307        CaptureGetOutputAudioResult,
308        fidl::encoding::DefaultFuchsiaResourceDialect,
309    > {
310        CaptureProxyInterface::r#get_output_audio(self)
311    }
312}
313
314impl CaptureProxyInterface for CaptureProxy {
315    type StartOutputCaptureResponseFut = fidl::client::QueryResponseFut<
316        CaptureStartOutputCaptureResult,
317        fidl::encoding::DefaultFuchsiaResourceDialect,
318    >;
319    fn r#start_output_capture(&self) -> Self::StartOutputCaptureResponseFut {
320        fn _decode(
321            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
322        ) -> Result<CaptureStartOutputCaptureResult, fidl::Error> {
323            let _response = fidl::client::decode_transaction_body::<
324                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
325                fidl::encoding::DefaultFuchsiaResourceDialect,
326                0x3da5afb01b70be17,
327            >(_buf?)?;
328            Ok(_response.map(|x| x))
329        }
330        self.client
331            .send_query_and_decode::<fidl::encoding::EmptyPayload, CaptureStartOutputCaptureResult>(
332                (),
333                0x3da5afb01b70be17,
334                fidl::encoding::DynamicFlags::empty(),
335                _decode,
336            )
337    }
338
339    type StopOutputCaptureResponseFut = fidl::client::QueryResponseFut<
340        CaptureStopOutputCaptureResult,
341        fidl::encoding::DefaultFuchsiaResourceDialect,
342    >;
343    fn r#stop_output_capture(&self) -> Self::StopOutputCaptureResponseFut {
344        fn _decode(
345            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
346        ) -> Result<CaptureStopOutputCaptureResult, fidl::Error> {
347            let _response = fidl::client::decode_transaction_body::<
348                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
349                fidl::encoding::DefaultFuchsiaResourceDialect,
350                0x4598c765e8859b6b,
351            >(_buf?)?;
352            Ok(_response.map(|x| x))
353        }
354        self.client
355            .send_query_and_decode::<fidl::encoding::EmptyPayload, CaptureStopOutputCaptureResult>(
356                (),
357                0x4598c765e8859b6b,
358                fidl::encoding::DynamicFlags::empty(),
359                _decode,
360            )
361    }
362
363    type GetOutputAudioResponseFut = fidl::client::QueryResponseFut<
364        CaptureGetOutputAudioResult,
365        fidl::encoding::DefaultFuchsiaResourceDialect,
366    >;
367    fn r#get_output_audio(&self) -> Self::GetOutputAudioResponseFut {
368        fn _decode(
369            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
370        ) -> Result<CaptureGetOutputAudioResult, fidl::Error> {
371            let _response = fidl::client::decode_transaction_body::<
372                fidl::encoding::ResultType<CaptureGetOutputAudioResponse, AudioTestError>,
373                fidl::encoding::DefaultFuchsiaResourceDialect,
374                0x23960702c8a96e54,
375            >(_buf?)?;
376            Ok(_response.map(|x| x.audio_reader))
377        }
378        self.client
379            .send_query_and_decode::<fidl::encoding::EmptyPayload, CaptureGetOutputAudioResult>(
380                (),
381                0x23960702c8a96e54,
382                fidl::encoding::DynamicFlags::empty(),
383                _decode,
384            )
385    }
386}
387
388pub struct CaptureEventStream {
389    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
390}
391
392impl std::marker::Unpin for CaptureEventStream {}
393
394impl futures::stream::FusedStream for CaptureEventStream {
395    fn is_terminated(&self) -> bool {
396        self.event_receiver.is_terminated()
397    }
398}
399
400impl futures::Stream for CaptureEventStream {
401    type Item = Result<CaptureEvent, fidl::Error>;
402
403    fn poll_next(
404        mut self: std::pin::Pin<&mut Self>,
405        cx: &mut std::task::Context<'_>,
406    ) -> std::task::Poll<Option<Self::Item>> {
407        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
408            &mut self.event_receiver,
409            cx
410        )?) {
411            Some(buf) => std::task::Poll::Ready(Some(CaptureEvent::decode(buf))),
412            None => std::task::Poll::Ready(None),
413        }
414    }
415}
416
417#[derive(Debug)]
418pub enum CaptureEvent {
419    #[non_exhaustive]
420    _UnknownEvent {
421        /// Ordinal of the event that was sent.
422        ordinal: u64,
423    },
424}
425
426impl CaptureEvent {
427    /// Decodes a message buffer as a [`CaptureEvent`].
428    fn decode(
429        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
430    ) -> Result<CaptureEvent, fidl::Error> {
431        let (bytes, _handles) = buf.split_mut();
432        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
433        debug_assert_eq!(tx_header.tx_id, 0);
434        match tx_header.ordinal {
435            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
436                Ok(CaptureEvent::_UnknownEvent { ordinal: tx_header.ordinal })
437            }
438            _ => Err(fidl::Error::UnknownOrdinal {
439                ordinal: tx_header.ordinal,
440                protocol_name: <CaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
441            }),
442        }
443    }
444}
445
446/// A Stream of incoming requests for fuchsia.test.audio/Capture.
447pub struct CaptureRequestStream {
448    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
449    is_terminated: bool,
450}
451
452impl std::marker::Unpin for CaptureRequestStream {}
453
454impl futures::stream::FusedStream for CaptureRequestStream {
455    fn is_terminated(&self) -> bool {
456        self.is_terminated
457    }
458}
459
460impl fidl::endpoints::RequestStream for CaptureRequestStream {
461    type Protocol = CaptureMarker;
462    type ControlHandle = CaptureControlHandle;
463
464    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
465        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
466    }
467
468    fn control_handle(&self) -> Self::ControlHandle {
469        CaptureControlHandle { inner: self.inner.clone() }
470    }
471
472    fn into_inner(
473        self,
474    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
475    {
476        (self.inner, self.is_terminated)
477    }
478
479    fn from_inner(
480        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481        is_terminated: bool,
482    ) -> Self {
483        Self { inner, is_terminated }
484    }
485}
486
487impl futures::Stream for CaptureRequestStream {
488    type Item = Result<CaptureRequest, fidl::Error>;
489
490    fn poll_next(
491        mut self: std::pin::Pin<&mut Self>,
492        cx: &mut std::task::Context<'_>,
493    ) -> std::task::Poll<Option<Self::Item>> {
494        let this = &mut *self;
495        if this.inner.check_shutdown(cx) {
496            this.is_terminated = true;
497            return std::task::Poll::Ready(None);
498        }
499        if this.is_terminated {
500            panic!("polled CaptureRequestStream after completion");
501        }
502        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
503            |bytes, handles| {
504                match this.inner.channel().read_etc(cx, bytes, handles) {
505                    std::task::Poll::Ready(Ok(())) => {}
506                    std::task::Poll::Pending => return std::task::Poll::Pending,
507                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
508                        this.is_terminated = true;
509                        return std::task::Poll::Ready(None);
510                    }
511                    std::task::Poll::Ready(Err(e)) => {
512                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
513                            e.into(),
514                        ))))
515                    }
516                }
517
518                // A message has been received from the channel
519                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
520
521                std::task::Poll::Ready(Some(match header.ordinal {
522                    0x3da5afb01b70be17 => {
523                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
524                        let mut req = fidl::new_empty!(
525                            fidl::encoding::EmptyPayload,
526                            fidl::encoding::DefaultFuchsiaResourceDialect
527                        );
528                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
529                        let control_handle = CaptureControlHandle { inner: this.inner.clone() };
530                        Ok(CaptureRequest::StartOutputCapture {
531                            responder: CaptureStartOutputCaptureResponder {
532                                control_handle: std::mem::ManuallyDrop::new(control_handle),
533                                tx_id: header.tx_id,
534                            },
535                        })
536                    }
537                    0x4598c765e8859b6b => {
538                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
539                        let mut req = fidl::new_empty!(
540                            fidl::encoding::EmptyPayload,
541                            fidl::encoding::DefaultFuchsiaResourceDialect
542                        );
543                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
544                        let control_handle = CaptureControlHandle { inner: this.inner.clone() };
545                        Ok(CaptureRequest::StopOutputCapture {
546                            responder: CaptureStopOutputCaptureResponder {
547                                control_handle: std::mem::ManuallyDrop::new(control_handle),
548                                tx_id: header.tx_id,
549                            },
550                        })
551                    }
552                    0x23960702c8a96e54 => {
553                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
554                        let mut req = fidl::new_empty!(
555                            fidl::encoding::EmptyPayload,
556                            fidl::encoding::DefaultFuchsiaResourceDialect
557                        );
558                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
559                        let control_handle = CaptureControlHandle { inner: this.inner.clone() };
560                        Ok(CaptureRequest::GetOutputAudio {
561                            responder: CaptureGetOutputAudioResponder {
562                                control_handle: std::mem::ManuallyDrop::new(control_handle),
563                                tx_id: header.tx_id,
564                            },
565                        })
566                    }
567                    _ if header.tx_id == 0
568                        && header
569                            .dynamic_flags()
570                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
571                    {
572                        Ok(CaptureRequest::_UnknownMethod {
573                            ordinal: header.ordinal,
574                            control_handle: CaptureControlHandle { inner: this.inner.clone() },
575                            method_type: fidl::MethodType::OneWay,
576                        })
577                    }
578                    _ if header
579                        .dynamic_flags()
580                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
581                    {
582                        this.inner.send_framework_err(
583                            fidl::encoding::FrameworkErr::UnknownMethod,
584                            header.tx_id,
585                            header.ordinal,
586                            header.dynamic_flags(),
587                            (bytes, handles),
588                        )?;
589                        Ok(CaptureRequest::_UnknownMethod {
590                            ordinal: header.ordinal,
591                            control_handle: CaptureControlHandle { inner: this.inner.clone() },
592                            method_type: fidl::MethodType::TwoWay,
593                        })
594                    }
595                    _ => Err(fidl::Error::UnknownOrdinal {
596                        ordinal: header.ordinal,
597                        protocol_name:
598                            <CaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
599                    }),
600                }))
601            },
602        )
603    }
604}
605
606#[derive(Debug)]
607pub enum CaptureRequest {
608    /// Start capturing the outgoing audio for this device.
609    ///
610    /// A virtual output device receives what would have played through the device's speakers.
611    /// This method reads from that virtual output device, into an internal buffer.
612    ///
613    /// After calling this method, use `StopOutputCapture` to stop recording output and
614    /// then `GetOutputAudio` to retrieve this captured audio.
615    ///
616    /// - response `error` description of failure action to take.
617    StartOutputCapture { responder: CaptureStartOutputCaptureResponder },
618    /// Stop capturing the outgoing audio for this device.
619    ///
620    /// This method will succeed even if no output capture has been started.
621    ///
622    /// After calling this method, use `GetOutputAudio` to retrieve the captured
623    /// audio from the virtual device's internal buffer and return it to the client.
624    ///
625    /// - response `error` description of failure action to take.
626    StopOutputCapture { responder: CaptureStopOutputCaptureResponder },
627    /// Extract the captured outgoing audio data through a socket.
628    ///
629    /// The socket is closed once it is fully drained.
630    ///
631    /// User should have first called `StartOutputCapture` and `StopOutputCapture`. This method will
632    /// return the contents of the internal buffer that was populated between the calls to those
633    /// two methods.
634    ///
635    /// Audio output format is 2-channel 48kHz 16-bit PCM.
636    ///
637    /// + request `audio_reader` socket where full captured audio data will be streamed.
638    /// - response `error` description of failure action to take.
639    GetOutputAudio { responder: CaptureGetOutputAudioResponder },
640    /// An interaction was received which does not match any known method.
641    #[non_exhaustive]
642    _UnknownMethod {
643        /// Ordinal of the method that was called.
644        ordinal: u64,
645        control_handle: CaptureControlHandle,
646        method_type: fidl::MethodType,
647    },
648}
649
650impl CaptureRequest {
651    #[allow(irrefutable_let_patterns)]
652    pub fn into_start_output_capture(self) -> Option<(CaptureStartOutputCaptureResponder)> {
653        if let CaptureRequest::StartOutputCapture { responder } = self {
654            Some((responder))
655        } else {
656            None
657        }
658    }
659
660    #[allow(irrefutable_let_patterns)]
661    pub fn into_stop_output_capture(self) -> Option<(CaptureStopOutputCaptureResponder)> {
662        if let CaptureRequest::StopOutputCapture { responder } = self {
663            Some((responder))
664        } else {
665            None
666        }
667    }
668
669    #[allow(irrefutable_let_patterns)]
670    pub fn into_get_output_audio(self) -> Option<(CaptureGetOutputAudioResponder)> {
671        if let CaptureRequest::GetOutputAudio { responder } = self {
672            Some((responder))
673        } else {
674            None
675        }
676    }
677
678    /// Name of the method defined in FIDL
679    pub fn method_name(&self) -> &'static str {
680        match *self {
681            CaptureRequest::StartOutputCapture { .. } => "start_output_capture",
682            CaptureRequest::StopOutputCapture { .. } => "stop_output_capture",
683            CaptureRequest::GetOutputAudio { .. } => "get_output_audio",
684            CaptureRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
685                "unknown one-way method"
686            }
687            CaptureRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
688                "unknown two-way method"
689            }
690        }
691    }
692}
693
694#[derive(Debug, Clone)]
695pub struct CaptureControlHandle {
696    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
697}
698
699impl fidl::endpoints::ControlHandle for CaptureControlHandle {
700    fn shutdown(&self) {
701        self.inner.shutdown()
702    }
703    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
704        self.inner.shutdown_with_epitaph(status)
705    }
706
707    fn is_closed(&self) -> bool {
708        self.inner.channel().is_closed()
709    }
710    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
711        self.inner.channel().on_closed()
712    }
713
714    #[cfg(target_os = "fuchsia")]
715    fn signal_peer(
716        &self,
717        clear_mask: zx::Signals,
718        set_mask: zx::Signals,
719    ) -> Result<(), zx_status::Status> {
720        use fidl::Peered;
721        self.inner.channel().signal_peer(clear_mask, set_mask)
722    }
723}
724
725impl CaptureControlHandle {}
726
727#[must_use = "FIDL methods require a response to be sent"]
728#[derive(Debug)]
729pub struct CaptureStartOutputCaptureResponder {
730    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
731    tx_id: u32,
732}
733
734/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
735/// if the responder is dropped without sending a response, so that the client
736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
737impl std::ops::Drop for CaptureStartOutputCaptureResponder {
738    fn drop(&mut self) {
739        self.control_handle.shutdown();
740        // Safety: drops once, never accessed again
741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
742    }
743}
744
745impl fidl::endpoints::Responder for CaptureStartOutputCaptureResponder {
746    type ControlHandle = CaptureControlHandle;
747
748    fn control_handle(&self) -> &CaptureControlHandle {
749        &self.control_handle
750    }
751
752    fn drop_without_shutdown(mut self) {
753        // Safety: drops once, never accessed again due to mem::forget
754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
755        // Prevent Drop from running (which would shut down the channel)
756        std::mem::forget(self);
757    }
758}
759
760impl CaptureStartOutputCaptureResponder {
761    /// Sends a response to the FIDL transaction.
762    ///
763    /// Sets the channel to shutdown if an error occurs.
764    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
765        let _result = self.send_raw(result);
766        if _result.is_err() {
767            self.control_handle.shutdown();
768        }
769        self.drop_without_shutdown();
770        _result
771    }
772
773    /// Similar to "send" but does not shutdown the channel if an error occurs.
774    pub fn send_no_shutdown_on_err(
775        self,
776        mut result: Result<(), AudioTestError>,
777    ) -> Result<(), fidl::Error> {
778        let _result = self.send_raw(result);
779        self.drop_without_shutdown();
780        _result
781    }
782
783    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
784        self.control_handle.inner.send::<fidl::encoding::ResultType<
785            fidl::encoding::EmptyStruct,
786            AudioTestError,
787        >>(
788            result,
789            self.tx_id,
790            0x3da5afb01b70be17,
791            fidl::encoding::DynamicFlags::empty(),
792        )
793    }
794}
795
796#[must_use = "FIDL methods require a response to be sent"]
797#[derive(Debug)]
798pub struct CaptureStopOutputCaptureResponder {
799    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
800    tx_id: u32,
801}
802
803/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
804/// if the responder is dropped without sending a response, so that the client
805/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
806impl std::ops::Drop for CaptureStopOutputCaptureResponder {
807    fn drop(&mut self) {
808        self.control_handle.shutdown();
809        // Safety: drops once, never accessed again
810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
811    }
812}
813
814impl fidl::endpoints::Responder for CaptureStopOutputCaptureResponder {
815    type ControlHandle = CaptureControlHandle;
816
817    fn control_handle(&self) -> &CaptureControlHandle {
818        &self.control_handle
819    }
820
821    fn drop_without_shutdown(mut self) {
822        // Safety: drops once, never accessed again due to mem::forget
823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
824        // Prevent Drop from running (which would shut down the channel)
825        std::mem::forget(self);
826    }
827}
828
829impl CaptureStopOutputCaptureResponder {
830    /// Sends a response to the FIDL transaction.
831    ///
832    /// Sets the channel to shutdown if an error occurs.
833    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
834        let _result = self.send_raw(result);
835        if _result.is_err() {
836            self.control_handle.shutdown();
837        }
838        self.drop_without_shutdown();
839        _result
840    }
841
842    /// Similar to "send" but does not shutdown the channel if an error occurs.
843    pub fn send_no_shutdown_on_err(
844        self,
845        mut result: Result<(), AudioTestError>,
846    ) -> Result<(), fidl::Error> {
847        let _result = self.send_raw(result);
848        self.drop_without_shutdown();
849        _result
850    }
851
852    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
853        self.control_handle.inner.send::<fidl::encoding::ResultType<
854            fidl::encoding::EmptyStruct,
855            AudioTestError,
856        >>(
857            result,
858            self.tx_id,
859            0x4598c765e8859b6b,
860            fidl::encoding::DynamicFlags::empty(),
861        )
862    }
863}
864
865#[must_use = "FIDL methods require a response to be sent"]
866#[derive(Debug)]
867pub struct CaptureGetOutputAudioResponder {
868    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
869    tx_id: u32,
870}
871
872/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
873/// if the responder is dropped without sending a response, so that the client
874/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
875impl std::ops::Drop for CaptureGetOutputAudioResponder {
876    fn drop(&mut self) {
877        self.control_handle.shutdown();
878        // Safety: drops once, never accessed again
879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
880    }
881}
882
883impl fidl::endpoints::Responder for CaptureGetOutputAudioResponder {
884    type ControlHandle = CaptureControlHandle;
885
886    fn control_handle(&self) -> &CaptureControlHandle {
887        &self.control_handle
888    }
889
890    fn drop_without_shutdown(mut self) {
891        // Safety: drops once, never accessed again due to mem::forget
892        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
893        // Prevent Drop from running (which would shut down the channel)
894        std::mem::forget(self);
895    }
896}
897
898impl CaptureGetOutputAudioResponder {
899    /// Sends a response to the FIDL transaction.
900    ///
901    /// Sets the channel to shutdown if an error occurs.
902    pub fn send(self, mut result: Result<fidl::Socket, AudioTestError>) -> Result<(), fidl::Error> {
903        let _result = self.send_raw(result);
904        if _result.is_err() {
905            self.control_handle.shutdown();
906        }
907        self.drop_without_shutdown();
908        _result
909    }
910
911    /// Similar to "send" but does not shutdown the channel if an error occurs.
912    pub fn send_no_shutdown_on_err(
913        self,
914        mut result: Result<fidl::Socket, AudioTestError>,
915    ) -> Result<(), fidl::Error> {
916        let _result = self.send_raw(result);
917        self.drop_without_shutdown();
918        _result
919    }
920
921    fn send_raw(
922        &self,
923        mut result: Result<fidl::Socket, AudioTestError>,
924    ) -> Result<(), fidl::Error> {
925        self.control_handle.inner.send::<fidl::encoding::ResultType<
926            CaptureGetOutputAudioResponse,
927            AudioTestError,
928        >>(
929            result.map(|audio_reader| (audio_reader,)),
930            self.tx_id,
931            0x23960702c8a96e54,
932            fidl::encoding::DynamicFlags::empty(),
933        )
934    }
935}
936
937#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
938pub struct InjectionMarker;
939
940impl fidl::endpoints::ProtocolMarker for InjectionMarker {
941    type Proxy = InjectionProxy;
942    type RequestStream = InjectionRequestStream;
943    #[cfg(target_os = "fuchsia")]
944    type SynchronousProxy = InjectionSynchronousProxy;
945
946    const DEBUG_NAME: &'static str = "fuchsia.test.audio.Injection";
947}
948impl fidl::endpoints::DiscoverableProtocolMarker for InjectionMarker {}
949pub type InjectionGetInputAudioSizeResult = Result<u64, AudioTestError>;
950pub type InjectionClearInputAudioResult = Result<(), AudioTestError>;
951pub type InjectionWaitUntilInputIsDoneResult = Result<(), AudioTestError>;
952pub type InjectionStartInputInjectionResult = Result<(), AudioTestError>;
953pub type InjectionStopInputInjectionResult = Result<(), AudioTestError>;
954
955pub trait InjectionProxyInterface: Send + Sync {
956    fn r#write_input_audio(
957        &self,
958        index: i32,
959        audio_writer: fidl::Socket,
960    ) -> Result<(), fidl::Error>;
961    type GetInputAudioSizeResponseFut: std::future::Future<Output = Result<InjectionGetInputAudioSizeResult, fidl::Error>>
962        + Send;
963    fn r#get_input_audio_size(&self, index: i32) -> Self::GetInputAudioSizeResponseFut;
964    type ClearInputAudioResponseFut: std::future::Future<Output = Result<InjectionClearInputAudioResult, fidl::Error>>
965        + Send;
966    fn r#clear_input_audio(&self, index: i32) -> Self::ClearInputAudioResponseFut;
967    type WaitUntilInputIsDoneResponseFut: std::future::Future<Output = Result<InjectionWaitUntilInputIsDoneResult, fidl::Error>>
968        + Send;
969    fn r#wait_until_input_is_done(&self) -> Self::WaitUntilInputIsDoneResponseFut;
970    type StartInputInjectionResponseFut: std::future::Future<Output = Result<InjectionStartInputInjectionResult, fidl::Error>>
971        + Send;
972    fn r#start_input_injection(&self, index: i32) -> Self::StartInputInjectionResponseFut;
973    type StopInputInjectionResponseFut: std::future::Future<Output = Result<InjectionStopInputInjectionResult, fidl::Error>>
974        + Send;
975    fn r#stop_input_injection(&self) -> Self::StopInputInjectionResponseFut;
976}
977#[derive(Debug)]
978#[cfg(target_os = "fuchsia")]
979pub struct InjectionSynchronousProxy {
980    client: fidl::client::sync::Client,
981}
982
983#[cfg(target_os = "fuchsia")]
984impl fidl::endpoints::SynchronousProxy for InjectionSynchronousProxy {
985    type Proxy = InjectionProxy;
986    type Protocol = InjectionMarker;
987
988    fn from_channel(inner: fidl::Channel) -> Self {
989        Self::new(inner)
990    }
991
992    fn into_channel(self) -> fidl::Channel {
993        self.client.into_channel()
994    }
995
996    fn as_channel(&self) -> &fidl::Channel {
997        self.client.as_channel()
998    }
999}
1000
1001#[cfg(target_os = "fuchsia")]
1002impl InjectionSynchronousProxy {
1003    pub fn new(channel: fidl::Channel) -> Self {
1004        let protocol_name = <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1005        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1006    }
1007
1008    pub fn into_channel(self) -> fidl::Channel {
1009        self.client.into_channel()
1010    }
1011
1012    /// Waits until an event arrives and returns it. It is safe for other
1013    /// threads to make concurrent requests while waiting for an event.
1014    pub fn wait_for_event(
1015        &self,
1016        deadline: zx::MonotonicInstant,
1017    ) -> Result<InjectionEvent, fidl::Error> {
1018        InjectionEvent::decode(self.client.wait_for_event(deadline)?)
1019    }
1020
1021    /// Set the audio to be injected at `index`.
1022    ///
1023    /// The first time this is called, an empty vector will be created, subsequent calls will
1024    /// append to `audio_data` to the same vector.
1025    ///
1026    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
1027    ///
1028    /// Further requests on the same Injection connection are blocked until the audio_writer socket
1029    /// is drained completely. To determine when injection is complete, users may initiate
1030    /// a call to GetInputAudioSize immediately following the call to this method.
1031    ///
1032    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
1033    /// + request `audio_writer` socket where audio data will be loaded from.
1034    pub fn r#write_input_audio(
1035        &self,
1036        mut index: i32,
1037        mut audio_writer: fidl::Socket,
1038    ) -> Result<(), fidl::Error> {
1039        self.client.send::<InjectionWriteInputAudioRequest>(
1040            (index, audio_writer),
1041            0x2eaec6d4251a030d,
1042            fidl::encoding::DynamicFlags::empty(),
1043        )
1044    }
1045
1046    /// Get the size of audio data stored at `index`.
1047    ///
1048    /// This method returns the number of bytes of input data stored at the given index.
1049    ///
1050    /// If a `WriteInputAudio` call is pending for the given index,
1051    /// this method will block until the socket is drained and the data
1052    /// is fully stored.
1053    ///
1054    /// + request `index` refers to a specific `audio_data` input record.
1055    /// - response `error` description of failure action to take.
1056    pub fn r#get_input_audio_size(
1057        &self,
1058        mut index: i32,
1059        ___deadline: zx::MonotonicInstant,
1060    ) -> Result<InjectionGetInputAudioSizeResult, fidl::Error> {
1061        let _response = self.client.send_query::<
1062            InjectionGetInputAudioSizeRequest,
1063            fidl::encoding::ResultType<InjectionGetInputAudioSizeResponse, AudioTestError>,
1064        >(
1065            (index,),
1066            0x57684145b51cf28,
1067            fidl::encoding::DynamicFlags::empty(),
1068            ___deadline,
1069        )?;
1070        Ok(_response.map(|x| x.byte_count))
1071    }
1072
1073    /// Clears audio data stored at `index`.
1074    ///
1075    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
1076    ///
1077    /// + request `index` refers a specific `audio_data` input record to clear.
1078    /// - response `error` description of failure action to take.
1079    pub fn r#clear_input_audio(
1080        &self,
1081        mut index: i32,
1082        ___deadline: zx::MonotonicInstant,
1083    ) -> Result<InjectionClearInputAudioResult, fidl::Error> {
1084        let _response = self.client.send_query::<
1085            InjectionClearInputAudioRequest,
1086            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1087        >(
1088            (index,),
1089            0x33259f902aace7b7,
1090            fidl::encoding::DynamicFlags::empty(),
1091            ___deadline,
1092        )?;
1093        Ok(_response.map(|x| x))
1094    }
1095
1096    /// Wait until injected inputs are done playing.
1097    ///
1098    /// This function returns only when all injected audio tracks are complete.
1099    ///
1100    /// This is intended to be called after calling `StartInputInjection`.
1101    /// If no tracks have been started, or all started tracks have already completed,
1102    /// then this function will immediately return without error.
1103    ///
1104    /// - response `error` description of failure action to take.
1105    pub fn r#wait_until_input_is_done(
1106        &self,
1107        ___deadline: zx::MonotonicInstant,
1108    ) -> Result<InjectionWaitUntilInputIsDoneResult, fidl::Error> {
1109        let _response = self.client.send_query::<
1110            fidl::encoding::EmptyPayload,
1111            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1112        >(
1113            (),
1114            0x6cb5b4b48ffe7fc8,
1115            fidl::encoding::DynamicFlags::empty(),
1116            ___deadline,
1117        )?;
1118        Ok(_response.map(|x| x))
1119    }
1120
1121    /// Start injecting the incoming audio for this device, using the audio at `index`.
1122    ///
1123    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
1124    ///
1125    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
1126    /// - response `error` description of failure action to take.
1127    pub fn r#start_input_injection(
1128        &self,
1129        mut index: i32,
1130        ___deadline: zx::MonotonicInstant,
1131    ) -> Result<InjectionStartInputInjectionResult, fidl::Error> {
1132        let _response = self.client.send_query::<
1133            InjectionStartInputInjectionRequest,
1134            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1135        >(
1136            (index,),
1137            0x753a5415ad966b06,
1138            fidl::encoding::DynamicFlags::empty(),
1139            ___deadline,
1140        )?;
1141        Ok(_response.map(|x| x))
1142    }
1143
1144    /// Stop injecting audio data.
1145    ///
1146    /// This stops playing all injected tracks.
1147    ///
1148    /// This is intended to be called after calling `StartInputInjection`.
1149    /// If no tracks have been started, or if all started tracks have already completed,
1150    /// then this function will immediately return without error.
1151    ///
1152    /// - response `error` description of failure action to take.
1153    pub fn r#stop_input_injection(
1154        &self,
1155        ___deadline: zx::MonotonicInstant,
1156    ) -> Result<InjectionStopInputInjectionResult, fidl::Error> {
1157        let _response = self.client.send_query::<
1158            fidl::encoding::EmptyPayload,
1159            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1160        >(
1161            (),
1162            0x371fce6bb8d77fe,
1163            fidl::encoding::DynamicFlags::empty(),
1164            ___deadline,
1165        )?;
1166        Ok(_response.map(|x| x))
1167    }
1168}
1169
1170#[cfg(target_os = "fuchsia")]
1171impl From<InjectionSynchronousProxy> for zx::Handle {
1172    fn from(value: InjectionSynchronousProxy) -> Self {
1173        value.into_channel().into()
1174    }
1175}
1176
1177#[cfg(target_os = "fuchsia")]
1178impl From<fidl::Channel> for InjectionSynchronousProxy {
1179    fn from(value: fidl::Channel) -> Self {
1180        Self::new(value)
1181    }
1182}
1183
1184#[derive(Debug, Clone)]
1185pub struct InjectionProxy {
1186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1187}
1188
1189impl fidl::endpoints::Proxy for InjectionProxy {
1190    type Protocol = InjectionMarker;
1191
1192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1193        Self::new(inner)
1194    }
1195
1196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1197        self.client.into_channel().map_err(|client| Self { client })
1198    }
1199
1200    fn as_channel(&self) -> &::fidl::AsyncChannel {
1201        self.client.as_channel()
1202    }
1203}
1204
1205impl InjectionProxy {
1206    /// Create a new Proxy for fuchsia.test.audio/Injection.
1207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1208        let protocol_name = <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1209        Self { client: fidl::client::Client::new(channel, protocol_name) }
1210    }
1211
1212    /// Get a Stream of events from the remote end of the protocol.
1213    ///
1214    /// # Panics
1215    ///
1216    /// Panics if the event stream was already taken.
1217    pub fn take_event_stream(&self) -> InjectionEventStream {
1218        InjectionEventStream { event_receiver: self.client.take_event_receiver() }
1219    }
1220
1221    /// Set the audio to be injected at `index`.
1222    ///
1223    /// The first time this is called, an empty vector will be created, subsequent calls will
1224    /// append to `audio_data` to the same vector.
1225    ///
1226    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
1227    ///
1228    /// Further requests on the same Injection connection are blocked until the audio_writer socket
1229    /// is drained completely. To determine when injection is complete, users may initiate
1230    /// a call to GetInputAudioSize immediately following the call to this method.
1231    ///
1232    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
1233    /// + request `audio_writer` socket where audio data will be loaded from.
1234    pub fn r#write_input_audio(
1235        &self,
1236        mut index: i32,
1237        mut audio_writer: fidl::Socket,
1238    ) -> Result<(), fidl::Error> {
1239        InjectionProxyInterface::r#write_input_audio(self, index, audio_writer)
1240    }
1241
1242    /// Get the size of audio data stored at `index`.
1243    ///
1244    /// This method returns the number of bytes of input data stored at the given index.
1245    ///
1246    /// If a `WriteInputAudio` call is pending for the given index,
1247    /// this method will block until the socket is drained and the data
1248    /// is fully stored.
1249    ///
1250    /// + request `index` refers to a specific `audio_data` input record.
1251    /// - response `error` description of failure action to take.
1252    pub fn r#get_input_audio_size(
1253        &self,
1254        mut index: i32,
1255    ) -> fidl::client::QueryResponseFut<
1256        InjectionGetInputAudioSizeResult,
1257        fidl::encoding::DefaultFuchsiaResourceDialect,
1258    > {
1259        InjectionProxyInterface::r#get_input_audio_size(self, index)
1260    }
1261
1262    /// Clears audio data stored at `index`.
1263    ///
1264    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
1265    ///
1266    /// + request `index` refers a specific `audio_data` input record to clear.
1267    /// - response `error` description of failure action to take.
1268    pub fn r#clear_input_audio(
1269        &self,
1270        mut index: i32,
1271    ) -> fidl::client::QueryResponseFut<
1272        InjectionClearInputAudioResult,
1273        fidl::encoding::DefaultFuchsiaResourceDialect,
1274    > {
1275        InjectionProxyInterface::r#clear_input_audio(self, index)
1276    }
1277
1278    /// Wait until injected inputs are done playing.
1279    ///
1280    /// This function returns only when all injected audio tracks are complete.
1281    ///
1282    /// This is intended to be called after calling `StartInputInjection`.
1283    /// If no tracks have been started, or all started tracks have already completed,
1284    /// then this function will immediately return without error.
1285    ///
1286    /// - response `error` description of failure action to take.
1287    pub fn r#wait_until_input_is_done(
1288        &self,
1289    ) -> fidl::client::QueryResponseFut<
1290        InjectionWaitUntilInputIsDoneResult,
1291        fidl::encoding::DefaultFuchsiaResourceDialect,
1292    > {
1293        InjectionProxyInterface::r#wait_until_input_is_done(self)
1294    }
1295
1296    /// Start injecting the incoming audio for this device, using the audio at `index`.
1297    ///
1298    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
1299    ///
1300    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
1301    /// - response `error` description of failure action to take.
1302    pub fn r#start_input_injection(
1303        &self,
1304        mut index: i32,
1305    ) -> fidl::client::QueryResponseFut<
1306        InjectionStartInputInjectionResult,
1307        fidl::encoding::DefaultFuchsiaResourceDialect,
1308    > {
1309        InjectionProxyInterface::r#start_input_injection(self, index)
1310    }
1311
1312    /// Stop injecting audio data.
1313    ///
1314    /// This stops playing all injected tracks.
1315    ///
1316    /// This is intended to be called after calling `StartInputInjection`.
1317    /// If no tracks have been started, or if all started tracks have already completed,
1318    /// then this function will immediately return without error.
1319    ///
1320    /// - response `error` description of failure action to take.
1321    pub fn r#stop_input_injection(
1322        &self,
1323    ) -> fidl::client::QueryResponseFut<
1324        InjectionStopInputInjectionResult,
1325        fidl::encoding::DefaultFuchsiaResourceDialect,
1326    > {
1327        InjectionProxyInterface::r#stop_input_injection(self)
1328    }
1329}
1330
1331impl InjectionProxyInterface for InjectionProxy {
1332    fn r#write_input_audio(
1333        &self,
1334        mut index: i32,
1335        mut audio_writer: fidl::Socket,
1336    ) -> Result<(), fidl::Error> {
1337        self.client.send::<InjectionWriteInputAudioRequest>(
1338            (index, audio_writer),
1339            0x2eaec6d4251a030d,
1340            fidl::encoding::DynamicFlags::empty(),
1341        )
1342    }
1343
1344    type GetInputAudioSizeResponseFut = fidl::client::QueryResponseFut<
1345        InjectionGetInputAudioSizeResult,
1346        fidl::encoding::DefaultFuchsiaResourceDialect,
1347    >;
1348    fn r#get_input_audio_size(&self, mut index: i32) -> Self::GetInputAudioSizeResponseFut {
1349        fn _decode(
1350            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1351        ) -> Result<InjectionGetInputAudioSizeResult, fidl::Error> {
1352            let _response = fidl::client::decode_transaction_body::<
1353                fidl::encoding::ResultType<InjectionGetInputAudioSizeResponse, AudioTestError>,
1354                fidl::encoding::DefaultFuchsiaResourceDialect,
1355                0x57684145b51cf28,
1356            >(_buf?)?;
1357            Ok(_response.map(|x| x.byte_count))
1358        }
1359        self.client.send_query_and_decode::<
1360            InjectionGetInputAudioSizeRequest,
1361            InjectionGetInputAudioSizeResult,
1362        >(
1363            (index,),
1364            0x57684145b51cf28,
1365            fidl::encoding::DynamicFlags::empty(),
1366            _decode,
1367        )
1368    }
1369
1370    type ClearInputAudioResponseFut = fidl::client::QueryResponseFut<
1371        InjectionClearInputAudioResult,
1372        fidl::encoding::DefaultFuchsiaResourceDialect,
1373    >;
1374    fn r#clear_input_audio(&self, mut index: i32) -> Self::ClearInputAudioResponseFut {
1375        fn _decode(
1376            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1377        ) -> Result<InjectionClearInputAudioResult, fidl::Error> {
1378            let _response = fidl::client::decode_transaction_body::<
1379                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1380                fidl::encoding::DefaultFuchsiaResourceDialect,
1381                0x33259f902aace7b7,
1382            >(_buf?)?;
1383            Ok(_response.map(|x| x))
1384        }
1385        self.client.send_query_and_decode::<
1386            InjectionClearInputAudioRequest,
1387            InjectionClearInputAudioResult,
1388        >(
1389            (index,),
1390            0x33259f902aace7b7,
1391            fidl::encoding::DynamicFlags::empty(),
1392            _decode,
1393        )
1394    }
1395
1396    type WaitUntilInputIsDoneResponseFut = fidl::client::QueryResponseFut<
1397        InjectionWaitUntilInputIsDoneResult,
1398        fidl::encoding::DefaultFuchsiaResourceDialect,
1399    >;
1400    fn r#wait_until_input_is_done(&self) -> Self::WaitUntilInputIsDoneResponseFut {
1401        fn _decode(
1402            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1403        ) -> Result<InjectionWaitUntilInputIsDoneResult, fidl::Error> {
1404            let _response = fidl::client::decode_transaction_body::<
1405                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1406                fidl::encoding::DefaultFuchsiaResourceDialect,
1407                0x6cb5b4b48ffe7fc8,
1408            >(_buf?)?;
1409            Ok(_response.map(|x| x))
1410        }
1411        self.client.send_query_and_decode::<
1412            fidl::encoding::EmptyPayload,
1413            InjectionWaitUntilInputIsDoneResult,
1414        >(
1415            (),
1416            0x6cb5b4b48ffe7fc8,
1417            fidl::encoding::DynamicFlags::empty(),
1418            _decode,
1419        )
1420    }
1421
1422    type StartInputInjectionResponseFut = fidl::client::QueryResponseFut<
1423        InjectionStartInputInjectionResult,
1424        fidl::encoding::DefaultFuchsiaResourceDialect,
1425    >;
1426    fn r#start_input_injection(&self, mut index: i32) -> Self::StartInputInjectionResponseFut {
1427        fn _decode(
1428            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1429        ) -> Result<InjectionStartInputInjectionResult, fidl::Error> {
1430            let _response = fidl::client::decode_transaction_body::<
1431                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1432                fidl::encoding::DefaultFuchsiaResourceDialect,
1433                0x753a5415ad966b06,
1434            >(_buf?)?;
1435            Ok(_response.map(|x| x))
1436        }
1437        self.client.send_query_and_decode::<
1438            InjectionStartInputInjectionRequest,
1439            InjectionStartInputInjectionResult,
1440        >(
1441            (index,),
1442            0x753a5415ad966b06,
1443            fidl::encoding::DynamicFlags::empty(),
1444            _decode,
1445        )
1446    }
1447
1448    type StopInputInjectionResponseFut = fidl::client::QueryResponseFut<
1449        InjectionStopInputInjectionResult,
1450        fidl::encoding::DefaultFuchsiaResourceDialect,
1451    >;
1452    fn r#stop_input_injection(&self) -> Self::StopInputInjectionResponseFut {
1453        fn _decode(
1454            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1455        ) -> Result<InjectionStopInputInjectionResult, fidl::Error> {
1456            let _response = fidl::client::decode_transaction_body::<
1457                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1458                fidl::encoding::DefaultFuchsiaResourceDialect,
1459                0x371fce6bb8d77fe,
1460            >(_buf?)?;
1461            Ok(_response.map(|x| x))
1462        }
1463        self.client.send_query_and_decode::<
1464            fidl::encoding::EmptyPayload,
1465            InjectionStopInputInjectionResult,
1466        >(
1467            (),
1468            0x371fce6bb8d77fe,
1469            fidl::encoding::DynamicFlags::empty(),
1470            _decode,
1471        )
1472    }
1473}
1474
1475pub struct InjectionEventStream {
1476    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1477}
1478
1479impl std::marker::Unpin for InjectionEventStream {}
1480
1481impl futures::stream::FusedStream for InjectionEventStream {
1482    fn is_terminated(&self) -> bool {
1483        self.event_receiver.is_terminated()
1484    }
1485}
1486
1487impl futures::Stream for InjectionEventStream {
1488    type Item = Result<InjectionEvent, fidl::Error>;
1489
1490    fn poll_next(
1491        mut self: std::pin::Pin<&mut Self>,
1492        cx: &mut std::task::Context<'_>,
1493    ) -> std::task::Poll<Option<Self::Item>> {
1494        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1495            &mut self.event_receiver,
1496            cx
1497        )?) {
1498            Some(buf) => std::task::Poll::Ready(Some(InjectionEvent::decode(buf))),
1499            None => std::task::Poll::Ready(None),
1500        }
1501    }
1502}
1503
1504#[derive(Debug)]
1505pub enum InjectionEvent {
1506    #[non_exhaustive]
1507    _UnknownEvent {
1508        /// Ordinal of the event that was sent.
1509        ordinal: u64,
1510    },
1511}
1512
1513impl InjectionEvent {
1514    /// Decodes a message buffer as a [`InjectionEvent`].
1515    fn decode(
1516        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1517    ) -> Result<InjectionEvent, fidl::Error> {
1518        let (bytes, _handles) = buf.split_mut();
1519        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1520        debug_assert_eq!(tx_header.tx_id, 0);
1521        match tx_header.ordinal {
1522            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1523                Ok(InjectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1524            }
1525            _ => Err(fidl::Error::UnknownOrdinal {
1526                ordinal: tx_header.ordinal,
1527                protocol_name: <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1528            }),
1529        }
1530    }
1531}
1532
1533/// A Stream of incoming requests for fuchsia.test.audio/Injection.
1534pub struct InjectionRequestStream {
1535    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1536    is_terminated: bool,
1537}
1538
1539impl std::marker::Unpin for InjectionRequestStream {}
1540
1541impl futures::stream::FusedStream for InjectionRequestStream {
1542    fn is_terminated(&self) -> bool {
1543        self.is_terminated
1544    }
1545}
1546
1547impl fidl::endpoints::RequestStream for InjectionRequestStream {
1548    type Protocol = InjectionMarker;
1549    type ControlHandle = InjectionControlHandle;
1550
1551    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1552        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1553    }
1554
1555    fn control_handle(&self) -> Self::ControlHandle {
1556        InjectionControlHandle { inner: self.inner.clone() }
1557    }
1558
1559    fn into_inner(
1560        self,
1561    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1562    {
1563        (self.inner, self.is_terminated)
1564    }
1565
1566    fn from_inner(
1567        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1568        is_terminated: bool,
1569    ) -> Self {
1570        Self { inner, is_terminated }
1571    }
1572}
1573
1574impl futures::Stream for InjectionRequestStream {
1575    type Item = Result<InjectionRequest, fidl::Error>;
1576
1577    fn poll_next(
1578        mut self: std::pin::Pin<&mut Self>,
1579        cx: &mut std::task::Context<'_>,
1580    ) -> std::task::Poll<Option<Self::Item>> {
1581        let this = &mut *self;
1582        if this.inner.check_shutdown(cx) {
1583            this.is_terminated = true;
1584            return std::task::Poll::Ready(None);
1585        }
1586        if this.is_terminated {
1587            panic!("polled InjectionRequestStream after completion");
1588        }
1589        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1590            |bytes, handles| {
1591                match this.inner.channel().read_etc(cx, bytes, handles) {
1592                    std::task::Poll::Ready(Ok(())) => {}
1593                    std::task::Poll::Pending => return std::task::Poll::Pending,
1594                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1595                        this.is_terminated = true;
1596                        return std::task::Poll::Ready(None);
1597                    }
1598                    std::task::Poll::Ready(Err(e)) => {
1599                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1600                            e.into(),
1601                        ))))
1602                    }
1603                }
1604
1605                // A message has been received from the channel
1606                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1607
1608                std::task::Poll::Ready(Some(match header.ordinal {
1609                    0x2eaec6d4251a030d => {
1610                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1611                        let mut req = fidl::new_empty!(
1612                            InjectionWriteInputAudioRequest,
1613                            fidl::encoding::DefaultFuchsiaResourceDialect
1614                        );
1615                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionWriteInputAudioRequest>(&header, _body_bytes, handles, &mut req)?;
1616                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1617                        Ok(InjectionRequest::WriteInputAudio {
1618                            index: req.index,
1619                            audio_writer: req.audio_writer,
1620
1621                            control_handle,
1622                        })
1623                    }
1624                    0x57684145b51cf28 => {
1625                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1626                        let mut req = fidl::new_empty!(
1627                            InjectionGetInputAudioSizeRequest,
1628                            fidl::encoding::DefaultFuchsiaResourceDialect
1629                        );
1630                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionGetInputAudioSizeRequest>(&header, _body_bytes, handles, &mut req)?;
1631                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1632                        Ok(InjectionRequest::GetInputAudioSize {
1633                            index: req.index,
1634
1635                            responder: InjectionGetInputAudioSizeResponder {
1636                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1637                                tx_id: header.tx_id,
1638                            },
1639                        })
1640                    }
1641                    0x33259f902aace7b7 => {
1642                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1643                        let mut req = fidl::new_empty!(
1644                            InjectionClearInputAudioRequest,
1645                            fidl::encoding::DefaultFuchsiaResourceDialect
1646                        );
1647                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionClearInputAudioRequest>(&header, _body_bytes, handles, &mut req)?;
1648                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1649                        Ok(InjectionRequest::ClearInputAudio {
1650                            index: req.index,
1651
1652                            responder: InjectionClearInputAudioResponder {
1653                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1654                                tx_id: header.tx_id,
1655                            },
1656                        })
1657                    }
1658                    0x6cb5b4b48ffe7fc8 => {
1659                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1660                        let mut req = fidl::new_empty!(
1661                            fidl::encoding::EmptyPayload,
1662                            fidl::encoding::DefaultFuchsiaResourceDialect
1663                        );
1664                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1665                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1666                        Ok(InjectionRequest::WaitUntilInputIsDone {
1667                            responder: InjectionWaitUntilInputIsDoneResponder {
1668                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1669                                tx_id: header.tx_id,
1670                            },
1671                        })
1672                    }
1673                    0x753a5415ad966b06 => {
1674                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1675                        let mut req = fidl::new_empty!(
1676                            InjectionStartInputInjectionRequest,
1677                            fidl::encoding::DefaultFuchsiaResourceDialect
1678                        );
1679                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionStartInputInjectionRequest>(&header, _body_bytes, handles, &mut req)?;
1680                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1681                        Ok(InjectionRequest::StartInputInjection {
1682                            index: req.index,
1683
1684                            responder: InjectionStartInputInjectionResponder {
1685                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1686                                tx_id: header.tx_id,
1687                            },
1688                        })
1689                    }
1690                    0x371fce6bb8d77fe => {
1691                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1692                        let mut req = fidl::new_empty!(
1693                            fidl::encoding::EmptyPayload,
1694                            fidl::encoding::DefaultFuchsiaResourceDialect
1695                        );
1696                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1697                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
1698                        Ok(InjectionRequest::StopInputInjection {
1699                            responder: InjectionStopInputInjectionResponder {
1700                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1701                                tx_id: header.tx_id,
1702                            },
1703                        })
1704                    }
1705                    _ if header.tx_id == 0
1706                        && header
1707                            .dynamic_flags()
1708                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1709                    {
1710                        Ok(InjectionRequest::_UnknownMethod {
1711                            ordinal: header.ordinal,
1712                            control_handle: InjectionControlHandle { inner: this.inner.clone() },
1713                            method_type: fidl::MethodType::OneWay,
1714                        })
1715                    }
1716                    _ if header
1717                        .dynamic_flags()
1718                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1719                    {
1720                        this.inner.send_framework_err(
1721                            fidl::encoding::FrameworkErr::UnknownMethod,
1722                            header.tx_id,
1723                            header.ordinal,
1724                            header.dynamic_flags(),
1725                            (bytes, handles),
1726                        )?;
1727                        Ok(InjectionRequest::_UnknownMethod {
1728                            ordinal: header.ordinal,
1729                            control_handle: InjectionControlHandle { inner: this.inner.clone() },
1730                            method_type: fidl::MethodType::TwoWay,
1731                        })
1732                    }
1733                    _ => Err(fidl::Error::UnknownOrdinal {
1734                        ordinal: header.ordinal,
1735                        protocol_name:
1736                            <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1737                    }),
1738                }))
1739            },
1740        )
1741    }
1742}
1743
1744/// A protocol that supports audio input injection.
1745///
1746/// Connections to this protocol control a virtual input audio device which can be used to inject
1747/// audio as if it came from a microphone.
1748///
1749/// The server contains indexed tracks which can be independently queued and played.
1750/// When injecting audio, it is common to pre-load all required inputs for a test scenario and
1751/// play them sequentially, using WaitUntilInputIsDone to determine when to start the next stage.
1752#[derive(Debug)]
1753pub enum InjectionRequest {
1754    /// Set the audio to be injected at `index`.
1755    ///
1756    /// The first time this is called, an empty vector will be created, subsequent calls will
1757    /// append to `audio_data` to the same vector.
1758    ///
1759    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
1760    ///
1761    /// Further requests on the same Injection connection are blocked until the audio_writer socket
1762    /// is drained completely. To determine when injection is complete, users may initiate
1763    /// a call to GetInputAudioSize immediately following the call to this method.
1764    ///
1765    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
1766    /// + request `audio_writer` socket where audio data will be loaded from.
1767    WriteInputAudio {
1768        index: i32,
1769        audio_writer: fidl::Socket,
1770        control_handle: InjectionControlHandle,
1771    },
1772    /// Get the size of audio data stored at `index`.
1773    ///
1774    /// This method returns the number of bytes of input data stored at the given index.
1775    ///
1776    /// If a `WriteInputAudio` call is pending for the given index,
1777    /// this method will block until the socket is drained and the data
1778    /// is fully stored.
1779    ///
1780    /// + request `index` refers to a specific `audio_data` input record.
1781    /// - response `error` description of failure action to take.
1782    GetInputAudioSize { index: i32, responder: InjectionGetInputAudioSizeResponder },
1783    /// Clears audio data stored at `index`.
1784    ///
1785    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
1786    ///
1787    /// + request `index` refers a specific `audio_data` input record to clear.
1788    /// - response `error` description of failure action to take.
1789    ClearInputAudio { index: i32, responder: InjectionClearInputAudioResponder },
1790    /// Wait until injected inputs are done playing.
1791    ///
1792    /// This function returns only when all injected audio tracks are complete.
1793    ///
1794    /// This is intended to be called after calling `StartInputInjection`.
1795    /// If no tracks have been started, or all started tracks have already completed,
1796    /// then this function will immediately return without error.
1797    ///
1798    /// - response `error` description of failure action to take.
1799    WaitUntilInputIsDone { responder: InjectionWaitUntilInputIsDoneResponder },
1800    /// Start injecting the incoming audio for this device, using the audio at `index`.
1801    ///
1802    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
1803    ///
1804    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
1805    /// - response `error` description of failure action to take.
1806    StartInputInjection { index: i32, responder: InjectionStartInputInjectionResponder },
1807    /// Stop injecting audio data.
1808    ///
1809    /// This stops playing all injected tracks.
1810    ///
1811    /// This is intended to be called after calling `StartInputInjection`.
1812    /// If no tracks have been started, or if all started tracks have already completed,
1813    /// then this function will immediately return without error.
1814    ///
1815    /// - response `error` description of failure action to take.
1816    StopInputInjection { responder: InjectionStopInputInjectionResponder },
1817    /// An interaction was received which does not match any known method.
1818    #[non_exhaustive]
1819    _UnknownMethod {
1820        /// Ordinal of the method that was called.
1821        ordinal: u64,
1822        control_handle: InjectionControlHandle,
1823        method_type: fidl::MethodType,
1824    },
1825}
1826
1827impl InjectionRequest {
1828    #[allow(irrefutable_let_patterns)]
1829    pub fn into_write_input_audio(self) -> Option<(i32, fidl::Socket, InjectionControlHandle)> {
1830        if let InjectionRequest::WriteInputAudio { index, audio_writer, control_handle } = self {
1831            Some((index, audio_writer, control_handle))
1832        } else {
1833            None
1834        }
1835    }
1836
1837    #[allow(irrefutable_let_patterns)]
1838    pub fn into_get_input_audio_size(self) -> Option<(i32, InjectionGetInputAudioSizeResponder)> {
1839        if let InjectionRequest::GetInputAudioSize { index, responder } = self {
1840            Some((index, responder))
1841        } else {
1842            None
1843        }
1844    }
1845
1846    #[allow(irrefutable_let_patterns)]
1847    pub fn into_clear_input_audio(self) -> Option<(i32, InjectionClearInputAudioResponder)> {
1848        if let InjectionRequest::ClearInputAudio { index, responder } = self {
1849            Some((index, responder))
1850        } else {
1851            None
1852        }
1853    }
1854
1855    #[allow(irrefutable_let_patterns)]
1856    pub fn into_wait_until_input_is_done(self) -> Option<(InjectionWaitUntilInputIsDoneResponder)> {
1857        if let InjectionRequest::WaitUntilInputIsDone { responder } = self {
1858            Some((responder))
1859        } else {
1860            None
1861        }
1862    }
1863
1864    #[allow(irrefutable_let_patterns)]
1865    pub fn into_start_input_injection(
1866        self,
1867    ) -> Option<(i32, InjectionStartInputInjectionResponder)> {
1868        if let InjectionRequest::StartInputInjection { index, responder } = self {
1869            Some((index, responder))
1870        } else {
1871            None
1872        }
1873    }
1874
1875    #[allow(irrefutable_let_patterns)]
1876    pub fn into_stop_input_injection(self) -> Option<(InjectionStopInputInjectionResponder)> {
1877        if let InjectionRequest::StopInputInjection { responder } = self {
1878            Some((responder))
1879        } else {
1880            None
1881        }
1882    }
1883
1884    /// Name of the method defined in FIDL
1885    pub fn method_name(&self) -> &'static str {
1886        match *self {
1887            InjectionRequest::WriteInputAudio { .. } => "write_input_audio",
1888            InjectionRequest::GetInputAudioSize { .. } => "get_input_audio_size",
1889            InjectionRequest::ClearInputAudio { .. } => "clear_input_audio",
1890            InjectionRequest::WaitUntilInputIsDone { .. } => "wait_until_input_is_done",
1891            InjectionRequest::StartInputInjection { .. } => "start_input_injection",
1892            InjectionRequest::StopInputInjection { .. } => "stop_input_injection",
1893            InjectionRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1894                "unknown one-way method"
1895            }
1896            InjectionRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1897                "unknown two-way method"
1898            }
1899        }
1900    }
1901}
1902
1903#[derive(Debug, Clone)]
1904pub struct InjectionControlHandle {
1905    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1906}
1907
1908impl fidl::endpoints::ControlHandle for InjectionControlHandle {
1909    fn shutdown(&self) {
1910        self.inner.shutdown()
1911    }
1912    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1913        self.inner.shutdown_with_epitaph(status)
1914    }
1915
1916    fn is_closed(&self) -> bool {
1917        self.inner.channel().is_closed()
1918    }
1919    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1920        self.inner.channel().on_closed()
1921    }
1922
1923    #[cfg(target_os = "fuchsia")]
1924    fn signal_peer(
1925        &self,
1926        clear_mask: zx::Signals,
1927        set_mask: zx::Signals,
1928    ) -> Result<(), zx_status::Status> {
1929        use fidl::Peered;
1930        self.inner.channel().signal_peer(clear_mask, set_mask)
1931    }
1932}
1933
1934impl InjectionControlHandle {}
1935
1936#[must_use = "FIDL methods require a response to be sent"]
1937#[derive(Debug)]
1938pub struct InjectionGetInputAudioSizeResponder {
1939    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
1940    tx_id: u32,
1941}
1942
1943/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
1944/// if the responder is dropped without sending a response, so that the client
1945/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1946impl std::ops::Drop for InjectionGetInputAudioSizeResponder {
1947    fn drop(&mut self) {
1948        self.control_handle.shutdown();
1949        // Safety: drops once, never accessed again
1950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1951    }
1952}
1953
1954impl fidl::endpoints::Responder for InjectionGetInputAudioSizeResponder {
1955    type ControlHandle = InjectionControlHandle;
1956
1957    fn control_handle(&self) -> &InjectionControlHandle {
1958        &self.control_handle
1959    }
1960
1961    fn drop_without_shutdown(mut self) {
1962        // Safety: drops once, never accessed again due to mem::forget
1963        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1964        // Prevent Drop from running (which would shut down the channel)
1965        std::mem::forget(self);
1966    }
1967}
1968
1969impl InjectionGetInputAudioSizeResponder {
1970    /// Sends a response to the FIDL transaction.
1971    ///
1972    /// Sets the channel to shutdown if an error occurs.
1973    pub fn send(self, mut result: Result<u64, AudioTestError>) -> Result<(), fidl::Error> {
1974        let _result = self.send_raw(result);
1975        if _result.is_err() {
1976            self.control_handle.shutdown();
1977        }
1978        self.drop_without_shutdown();
1979        _result
1980    }
1981
1982    /// Similar to "send" but does not shutdown the channel if an error occurs.
1983    pub fn send_no_shutdown_on_err(
1984        self,
1985        mut result: Result<u64, AudioTestError>,
1986    ) -> Result<(), fidl::Error> {
1987        let _result = self.send_raw(result);
1988        self.drop_without_shutdown();
1989        _result
1990    }
1991
1992    fn send_raw(&self, mut result: Result<u64, AudioTestError>) -> Result<(), fidl::Error> {
1993        self.control_handle.inner.send::<fidl::encoding::ResultType<
1994            InjectionGetInputAudioSizeResponse,
1995            AudioTestError,
1996        >>(
1997            result.map(|byte_count| (byte_count,)),
1998            self.tx_id,
1999            0x57684145b51cf28,
2000            fidl::encoding::DynamicFlags::empty(),
2001        )
2002    }
2003}
2004
2005#[must_use = "FIDL methods require a response to be sent"]
2006#[derive(Debug)]
2007pub struct InjectionClearInputAudioResponder {
2008    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2009    tx_id: u32,
2010}
2011
2012/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2013/// if the responder is dropped without sending a response, so that the client
2014/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2015impl std::ops::Drop for InjectionClearInputAudioResponder {
2016    fn drop(&mut self) {
2017        self.control_handle.shutdown();
2018        // Safety: drops once, never accessed again
2019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2020    }
2021}
2022
2023impl fidl::endpoints::Responder for InjectionClearInputAudioResponder {
2024    type ControlHandle = InjectionControlHandle;
2025
2026    fn control_handle(&self) -> &InjectionControlHandle {
2027        &self.control_handle
2028    }
2029
2030    fn drop_without_shutdown(mut self) {
2031        // Safety: drops once, never accessed again due to mem::forget
2032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2033        // Prevent Drop from running (which would shut down the channel)
2034        std::mem::forget(self);
2035    }
2036}
2037
2038impl InjectionClearInputAudioResponder {
2039    /// Sends a response to the FIDL transaction.
2040    ///
2041    /// Sets the channel to shutdown if an error occurs.
2042    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2043        let _result = self.send_raw(result);
2044        if _result.is_err() {
2045            self.control_handle.shutdown();
2046        }
2047        self.drop_without_shutdown();
2048        _result
2049    }
2050
2051    /// Similar to "send" but does not shutdown the channel if an error occurs.
2052    pub fn send_no_shutdown_on_err(
2053        self,
2054        mut result: Result<(), AudioTestError>,
2055    ) -> Result<(), fidl::Error> {
2056        let _result = self.send_raw(result);
2057        self.drop_without_shutdown();
2058        _result
2059    }
2060
2061    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2062        self.control_handle.inner.send::<fidl::encoding::ResultType<
2063            fidl::encoding::EmptyStruct,
2064            AudioTestError,
2065        >>(
2066            result,
2067            self.tx_id,
2068            0x33259f902aace7b7,
2069            fidl::encoding::DynamicFlags::empty(),
2070        )
2071    }
2072}
2073
2074#[must_use = "FIDL methods require a response to be sent"]
2075#[derive(Debug)]
2076pub struct InjectionWaitUntilInputIsDoneResponder {
2077    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2078    tx_id: u32,
2079}
2080
2081/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2082/// if the responder is dropped without sending a response, so that the client
2083/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2084impl std::ops::Drop for InjectionWaitUntilInputIsDoneResponder {
2085    fn drop(&mut self) {
2086        self.control_handle.shutdown();
2087        // Safety: drops once, never accessed again
2088        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2089    }
2090}
2091
2092impl fidl::endpoints::Responder for InjectionWaitUntilInputIsDoneResponder {
2093    type ControlHandle = InjectionControlHandle;
2094
2095    fn control_handle(&self) -> &InjectionControlHandle {
2096        &self.control_handle
2097    }
2098
2099    fn drop_without_shutdown(mut self) {
2100        // Safety: drops once, never accessed again due to mem::forget
2101        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2102        // Prevent Drop from running (which would shut down the channel)
2103        std::mem::forget(self);
2104    }
2105}
2106
2107impl InjectionWaitUntilInputIsDoneResponder {
2108    /// Sends a response to the FIDL transaction.
2109    ///
2110    /// Sets the channel to shutdown if an error occurs.
2111    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2112        let _result = self.send_raw(result);
2113        if _result.is_err() {
2114            self.control_handle.shutdown();
2115        }
2116        self.drop_without_shutdown();
2117        _result
2118    }
2119
2120    /// Similar to "send" but does not shutdown the channel if an error occurs.
2121    pub fn send_no_shutdown_on_err(
2122        self,
2123        mut result: Result<(), AudioTestError>,
2124    ) -> Result<(), fidl::Error> {
2125        let _result = self.send_raw(result);
2126        self.drop_without_shutdown();
2127        _result
2128    }
2129
2130    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2131        self.control_handle.inner.send::<fidl::encoding::ResultType<
2132            fidl::encoding::EmptyStruct,
2133            AudioTestError,
2134        >>(
2135            result,
2136            self.tx_id,
2137            0x6cb5b4b48ffe7fc8,
2138            fidl::encoding::DynamicFlags::empty(),
2139        )
2140    }
2141}
2142
2143#[must_use = "FIDL methods require a response to be sent"]
2144#[derive(Debug)]
2145pub struct InjectionStartInputInjectionResponder {
2146    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2147    tx_id: u32,
2148}
2149
2150/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2151/// if the responder is dropped without sending a response, so that the client
2152/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2153impl std::ops::Drop for InjectionStartInputInjectionResponder {
2154    fn drop(&mut self) {
2155        self.control_handle.shutdown();
2156        // Safety: drops once, never accessed again
2157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2158    }
2159}
2160
2161impl fidl::endpoints::Responder for InjectionStartInputInjectionResponder {
2162    type ControlHandle = InjectionControlHandle;
2163
2164    fn control_handle(&self) -> &InjectionControlHandle {
2165        &self.control_handle
2166    }
2167
2168    fn drop_without_shutdown(mut self) {
2169        // Safety: drops once, never accessed again due to mem::forget
2170        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2171        // Prevent Drop from running (which would shut down the channel)
2172        std::mem::forget(self);
2173    }
2174}
2175
2176impl InjectionStartInputInjectionResponder {
2177    /// Sends a response to the FIDL transaction.
2178    ///
2179    /// Sets the channel to shutdown if an error occurs.
2180    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2181        let _result = self.send_raw(result);
2182        if _result.is_err() {
2183            self.control_handle.shutdown();
2184        }
2185        self.drop_without_shutdown();
2186        _result
2187    }
2188
2189    /// Similar to "send" but does not shutdown the channel if an error occurs.
2190    pub fn send_no_shutdown_on_err(
2191        self,
2192        mut result: Result<(), AudioTestError>,
2193    ) -> Result<(), fidl::Error> {
2194        let _result = self.send_raw(result);
2195        self.drop_without_shutdown();
2196        _result
2197    }
2198
2199    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2200        self.control_handle.inner.send::<fidl::encoding::ResultType<
2201            fidl::encoding::EmptyStruct,
2202            AudioTestError,
2203        >>(
2204            result,
2205            self.tx_id,
2206            0x753a5415ad966b06,
2207            fidl::encoding::DynamicFlags::empty(),
2208        )
2209    }
2210}
2211
2212#[must_use = "FIDL methods require a response to be sent"]
2213#[derive(Debug)]
2214pub struct InjectionStopInputInjectionResponder {
2215    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2216    tx_id: u32,
2217}
2218
2219/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2220/// if the responder is dropped without sending a response, so that the client
2221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2222impl std::ops::Drop for InjectionStopInputInjectionResponder {
2223    fn drop(&mut self) {
2224        self.control_handle.shutdown();
2225        // Safety: drops once, never accessed again
2226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2227    }
2228}
2229
2230impl fidl::endpoints::Responder for InjectionStopInputInjectionResponder {
2231    type ControlHandle = InjectionControlHandle;
2232
2233    fn control_handle(&self) -> &InjectionControlHandle {
2234        &self.control_handle
2235    }
2236
2237    fn drop_without_shutdown(mut self) {
2238        // Safety: drops once, never accessed again due to mem::forget
2239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2240        // Prevent Drop from running (which would shut down the channel)
2241        std::mem::forget(self);
2242    }
2243}
2244
2245impl InjectionStopInputInjectionResponder {
2246    /// Sends a response to the FIDL transaction.
2247    ///
2248    /// Sets the channel to shutdown if an error occurs.
2249    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2250        let _result = self.send_raw(result);
2251        if _result.is_err() {
2252            self.control_handle.shutdown();
2253        }
2254        self.drop_without_shutdown();
2255        _result
2256    }
2257
2258    /// Similar to "send" but does not shutdown the channel if an error occurs.
2259    pub fn send_no_shutdown_on_err(
2260        self,
2261        mut result: Result<(), AudioTestError>,
2262    ) -> Result<(), fidl::Error> {
2263        let _result = self.send_raw(result);
2264        self.drop_without_shutdown();
2265        _result
2266    }
2267
2268    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2269        self.control_handle.inner.send::<fidl::encoding::ResultType<
2270            fidl::encoding::EmptyStruct,
2271            AudioTestError,
2272        >>(
2273            result,
2274            self.tx_id,
2275            0x371fce6bb8d77fe,
2276            fidl::encoding::DynamicFlags::empty(),
2277        )
2278    }
2279}
2280
2281mod internal {
2282    use super::*;
2283
2284    impl fidl::encoding::ResourceTypeMarker for CaptureGetOutputAudioResponse {
2285        type Borrowed<'a> = &'a mut Self;
2286        fn take_or_borrow<'a>(
2287            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2288        ) -> Self::Borrowed<'a> {
2289            value
2290        }
2291    }
2292
2293    unsafe impl fidl::encoding::TypeMarker for CaptureGetOutputAudioResponse {
2294        type Owned = Self;
2295
2296        #[inline(always)]
2297        fn inline_align(_context: fidl::encoding::Context) -> usize {
2298            4
2299        }
2300
2301        #[inline(always)]
2302        fn inline_size(_context: fidl::encoding::Context) -> usize {
2303            4
2304        }
2305    }
2306
2307    unsafe impl
2308        fidl::encoding::Encode<
2309            CaptureGetOutputAudioResponse,
2310            fidl::encoding::DefaultFuchsiaResourceDialect,
2311        > for &mut CaptureGetOutputAudioResponse
2312    {
2313        #[inline]
2314        unsafe fn encode(
2315            self,
2316            encoder: &mut fidl::encoding::Encoder<
2317                '_,
2318                fidl::encoding::DefaultFuchsiaResourceDialect,
2319            >,
2320            offset: usize,
2321            _depth: fidl::encoding::Depth,
2322        ) -> fidl::Result<()> {
2323            encoder.debug_check_bounds::<CaptureGetOutputAudioResponse>(offset);
2324            // Delegate to tuple encoding.
2325            fidl::encoding::Encode::<
2326                CaptureGetOutputAudioResponse,
2327                fidl::encoding::DefaultFuchsiaResourceDialect,
2328            >::encode(
2329                (<fidl::encoding::HandleType<
2330                    fidl::Socket,
2331                    { fidl::ObjectType::SOCKET.into_raw() },
2332                    2147483648,
2333                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2334                    &mut self.audio_reader
2335                ),),
2336                encoder,
2337                offset,
2338                _depth,
2339            )
2340        }
2341    }
2342    unsafe impl<
2343            T0: fidl::encoding::Encode<
2344                fidl::encoding::HandleType<
2345                    fidl::Socket,
2346                    { fidl::ObjectType::SOCKET.into_raw() },
2347                    2147483648,
2348                >,
2349                fidl::encoding::DefaultFuchsiaResourceDialect,
2350            >,
2351        >
2352        fidl::encoding::Encode<
2353            CaptureGetOutputAudioResponse,
2354            fidl::encoding::DefaultFuchsiaResourceDialect,
2355        > for (T0,)
2356    {
2357        #[inline]
2358        unsafe fn encode(
2359            self,
2360            encoder: &mut fidl::encoding::Encoder<
2361                '_,
2362                fidl::encoding::DefaultFuchsiaResourceDialect,
2363            >,
2364            offset: usize,
2365            depth: fidl::encoding::Depth,
2366        ) -> fidl::Result<()> {
2367            encoder.debug_check_bounds::<CaptureGetOutputAudioResponse>(offset);
2368            // Zero out padding regions. There's no need to apply masks
2369            // because the unmasked parts will be overwritten by fields.
2370            // Write the fields.
2371            self.0.encode(encoder, offset + 0, depth)?;
2372            Ok(())
2373        }
2374    }
2375
2376    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2377        for CaptureGetOutputAudioResponse
2378    {
2379        #[inline(always)]
2380        fn new_empty() -> Self {
2381            Self {
2382                audio_reader: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2383            }
2384        }
2385
2386        #[inline]
2387        unsafe fn decode(
2388            &mut self,
2389            decoder: &mut fidl::encoding::Decoder<
2390                '_,
2391                fidl::encoding::DefaultFuchsiaResourceDialect,
2392            >,
2393            offset: usize,
2394            _depth: fidl::encoding::Depth,
2395        ) -> fidl::Result<()> {
2396            decoder.debug_check_bounds::<Self>(offset);
2397            // Verify that padding bytes are zero.
2398            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.audio_reader, decoder, offset + 0, _depth)?;
2399            Ok(())
2400        }
2401    }
2402
2403    impl fidl::encoding::ResourceTypeMarker for InjectionClearInputAudioRequest {
2404        type Borrowed<'a> = &'a mut Self;
2405        fn take_or_borrow<'a>(
2406            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2407        ) -> Self::Borrowed<'a> {
2408            value
2409        }
2410    }
2411
2412    unsafe impl fidl::encoding::TypeMarker for InjectionClearInputAudioRequest {
2413        type Owned = Self;
2414
2415        #[inline(always)]
2416        fn inline_align(_context: fidl::encoding::Context) -> usize {
2417            4
2418        }
2419
2420        #[inline(always)]
2421        fn inline_size(_context: fidl::encoding::Context) -> usize {
2422            4
2423        }
2424        #[inline(always)]
2425        fn encode_is_copy() -> bool {
2426            true
2427        }
2428
2429        #[inline(always)]
2430        fn decode_is_copy() -> bool {
2431            true
2432        }
2433    }
2434
2435    unsafe impl
2436        fidl::encoding::Encode<
2437            InjectionClearInputAudioRequest,
2438            fidl::encoding::DefaultFuchsiaResourceDialect,
2439        > for &mut InjectionClearInputAudioRequest
2440    {
2441        #[inline]
2442        unsafe fn encode(
2443            self,
2444            encoder: &mut fidl::encoding::Encoder<
2445                '_,
2446                fidl::encoding::DefaultFuchsiaResourceDialect,
2447            >,
2448            offset: usize,
2449            _depth: fidl::encoding::Depth,
2450        ) -> fidl::Result<()> {
2451            encoder.debug_check_bounds::<InjectionClearInputAudioRequest>(offset);
2452            unsafe {
2453                // Copy the object into the buffer.
2454                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2455                (buf_ptr as *mut InjectionClearInputAudioRequest)
2456                    .write_unaligned((self as *const InjectionClearInputAudioRequest).read());
2457                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2458                // done second because the memcpy will write garbage to these bytes.
2459            }
2460            Ok(())
2461        }
2462    }
2463    unsafe impl<T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>>
2464        fidl::encoding::Encode<
2465            InjectionClearInputAudioRequest,
2466            fidl::encoding::DefaultFuchsiaResourceDialect,
2467        > for (T0,)
2468    {
2469        #[inline]
2470        unsafe fn encode(
2471            self,
2472            encoder: &mut fidl::encoding::Encoder<
2473                '_,
2474                fidl::encoding::DefaultFuchsiaResourceDialect,
2475            >,
2476            offset: usize,
2477            depth: fidl::encoding::Depth,
2478        ) -> fidl::Result<()> {
2479            encoder.debug_check_bounds::<InjectionClearInputAudioRequest>(offset);
2480            // Zero out padding regions. There's no need to apply masks
2481            // because the unmasked parts will be overwritten by fields.
2482            // Write the fields.
2483            self.0.encode(encoder, offset + 0, depth)?;
2484            Ok(())
2485        }
2486    }
2487
2488    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2489        for InjectionClearInputAudioRequest
2490    {
2491        #[inline(always)]
2492        fn new_empty() -> Self {
2493            Self { index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect) }
2494        }
2495
2496        #[inline]
2497        unsafe fn decode(
2498            &mut self,
2499            decoder: &mut fidl::encoding::Decoder<
2500                '_,
2501                fidl::encoding::DefaultFuchsiaResourceDialect,
2502            >,
2503            offset: usize,
2504            _depth: fidl::encoding::Depth,
2505        ) -> fidl::Result<()> {
2506            decoder.debug_check_bounds::<Self>(offset);
2507            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2508            // Verify that padding bytes are zero.
2509            // Copy from the buffer into the object.
2510            unsafe {
2511                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
2512            }
2513            Ok(())
2514        }
2515    }
2516
2517    impl fidl::encoding::ResourceTypeMarker for InjectionStartInputInjectionRequest {
2518        type Borrowed<'a> = &'a mut Self;
2519        fn take_or_borrow<'a>(
2520            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2521        ) -> Self::Borrowed<'a> {
2522            value
2523        }
2524    }
2525
2526    unsafe impl fidl::encoding::TypeMarker for InjectionStartInputInjectionRequest {
2527        type Owned = Self;
2528
2529        #[inline(always)]
2530        fn inline_align(_context: fidl::encoding::Context) -> usize {
2531            4
2532        }
2533
2534        #[inline(always)]
2535        fn inline_size(_context: fidl::encoding::Context) -> usize {
2536            4
2537        }
2538        #[inline(always)]
2539        fn encode_is_copy() -> bool {
2540            true
2541        }
2542
2543        #[inline(always)]
2544        fn decode_is_copy() -> bool {
2545            true
2546        }
2547    }
2548
2549    unsafe impl
2550        fidl::encoding::Encode<
2551            InjectionStartInputInjectionRequest,
2552            fidl::encoding::DefaultFuchsiaResourceDialect,
2553        > for &mut InjectionStartInputInjectionRequest
2554    {
2555        #[inline]
2556        unsafe fn encode(
2557            self,
2558            encoder: &mut fidl::encoding::Encoder<
2559                '_,
2560                fidl::encoding::DefaultFuchsiaResourceDialect,
2561            >,
2562            offset: usize,
2563            _depth: fidl::encoding::Depth,
2564        ) -> fidl::Result<()> {
2565            encoder.debug_check_bounds::<InjectionStartInputInjectionRequest>(offset);
2566            unsafe {
2567                // Copy the object into the buffer.
2568                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2569                (buf_ptr as *mut InjectionStartInputInjectionRequest)
2570                    .write_unaligned((self as *const InjectionStartInputInjectionRequest).read());
2571                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
2572                // done second because the memcpy will write garbage to these bytes.
2573            }
2574            Ok(())
2575        }
2576    }
2577    unsafe impl<T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>>
2578        fidl::encoding::Encode<
2579            InjectionStartInputInjectionRequest,
2580            fidl::encoding::DefaultFuchsiaResourceDialect,
2581        > for (T0,)
2582    {
2583        #[inline]
2584        unsafe fn encode(
2585            self,
2586            encoder: &mut fidl::encoding::Encoder<
2587                '_,
2588                fidl::encoding::DefaultFuchsiaResourceDialect,
2589            >,
2590            offset: usize,
2591            depth: fidl::encoding::Depth,
2592        ) -> fidl::Result<()> {
2593            encoder.debug_check_bounds::<InjectionStartInputInjectionRequest>(offset);
2594            // Zero out padding regions. There's no need to apply masks
2595            // because the unmasked parts will be overwritten by fields.
2596            // Write the fields.
2597            self.0.encode(encoder, offset + 0, depth)?;
2598            Ok(())
2599        }
2600    }
2601
2602    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2603        for InjectionStartInputInjectionRequest
2604    {
2605        #[inline(always)]
2606        fn new_empty() -> Self {
2607            Self { index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect) }
2608        }
2609
2610        #[inline]
2611        unsafe fn decode(
2612            &mut self,
2613            decoder: &mut fidl::encoding::Decoder<
2614                '_,
2615                fidl::encoding::DefaultFuchsiaResourceDialect,
2616            >,
2617            offset: usize,
2618            _depth: fidl::encoding::Depth,
2619        ) -> fidl::Result<()> {
2620            decoder.debug_check_bounds::<Self>(offset);
2621            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2622            // Verify that padding bytes are zero.
2623            // Copy from the buffer into the object.
2624            unsafe {
2625                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
2626            }
2627            Ok(())
2628        }
2629    }
2630
2631    impl fidl::encoding::ResourceTypeMarker for InjectionWriteInputAudioRequest {
2632        type Borrowed<'a> = &'a mut Self;
2633        fn take_or_borrow<'a>(
2634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2635        ) -> Self::Borrowed<'a> {
2636            value
2637        }
2638    }
2639
2640    unsafe impl fidl::encoding::TypeMarker for InjectionWriteInputAudioRequest {
2641        type Owned = Self;
2642
2643        #[inline(always)]
2644        fn inline_align(_context: fidl::encoding::Context) -> usize {
2645            4
2646        }
2647
2648        #[inline(always)]
2649        fn inline_size(_context: fidl::encoding::Context) -> usize {
2650            8
2651        }
2652    }
2653
2654    unsafe impl
2655        fidl::encoding::Encode<
2656            InjectionWriteInputAudioRequest,
2657            fidl::encoding::DefaultFuchsiaResourceDialect,
2658        > for &mut InjectionWriteInputAudioRequest
2659    {
2660        #[inline]
2661        unsafe fn encode(
2662            self,
2663            encoder: &mut fidl::encoding::Encoder<
2664                '_,
2665                fidl::encoding::DefaultFuchsiaResourceDialect,
2666            >,
2667            offset: usize,
2668            _depth: fidl::encoding::Depth,
2669        ) -> fidl::Result<()> {
2670            encoder.debug_check_bounds::<InjectionWriteInputAudioRequest>(offset);
2671            // Delegate to tuple encoding.
2672            fidl::encoding::Encode::<
2673                InjectionWriteInputAudioRequest,
2674                fidl::encoding::DefaultFuchsiaResourceDialect,
2675            >::encode(
2676                (
2677                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.index),
2678                    <fidl::encoding::HandleType<
2679                        fidl::Socket,
2680                        { fidl::ObjectType::SOCKET.into_raw() },
2681                        2147483648,
2682                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2683                        &mut self.audio_writer,
2684                    ),
2685                ),
2686                encoder,
2687                offset,
2688                _depth,
2689            )
2690        }
2691    }
2692    unsafe impl<
2693            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2694            T1: fidl::encoding::Encode<
2695                fidl::encoding::HandleType<
2696                    fidl::Socket,
2697                    { fidl::ObjectType::SOCKET.into_raw() },
2698                    2147483648,
2699                >,
2700                fidl::encoding::DefaultFuchsiaResourceDialect,
2701            >,
2702        >
2703        fidl::encoding::Encode<
2704            InjectionWriteInputAudioRequest,
2705            fidl::encoding::DefaultFuchsiaResourceDialect,
2706        > for (T0, T1)
2707    {
2708        #[inline]
2709        unsafe fn encode(
2710            self,
2711            encoder: &mut fidl::encoding::Encoder<
2712                '_,
2713                fidl::encoding::DefaultFuchsiaResourceDialect,
2714            >,
2715            offset: usize,
2716            depth: fidl::encoding::Depth,
2717        ) -> fidl::Result<()> {
2718            encoder.debug_check_bounds::<InjectionWriteInputAudioRequest>(offset);
2719            // Zero out padding regions. There's no need to apply masks
2720            // because the unmasked parts will be overwritten by fields.
2721            // Write the fields.
2722            self.0.encode(encoder, offset + 0, depth)?;
2723            self.1.encode(encoder, offset + 4, depth)?;
2724            Ok(())
2725        }
2726    }
2727
2728    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2729        for InjectionWriteInputAudioRequest
2730    {
2731        #[inline(always)]
2732        fn new_empty() -> Self {
2733            Self {
2734                index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
2735                audio_writer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2736            }
2737        }
2738
2739        #[inline]
2740        unsafe fn decode(
2741            &mut self,
2742            decoder: &mut fidl::encoding::Decoder<
2743                '_,
2744                fidl::encoding::DefaultFuchsiaResourceDialect,
2745            >,
2746            offset: usize,
2747            _depth: fidl::encoding::Depth,
2748        ) -> fidl::Result<()> {
2749            decoder.debug_check_bounds::<Self>(offset);
2750            // Verify that padding bytes are zero.
2751            fidl::decode!(
2752                i32,
2753                fidl::encoding::DefaultFuchsiaResourceDialect,
2754                &mut self.index,
2755                decoder,
2756                offset + 0,
2757                _depth
2758            )?;
2759            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.audio_writer, decoder, offset + 4, _depth)?;
2760            Ok(())
2761        }
2762    }
2763}