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