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