Skip to main content

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