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::NullableHandle {
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
1104    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1105        self.inner.shutdown_with_epitaph(status)
1106    }
1107
1108    fn is_closed(&self) -> bool {
1109        self.inner.channel().is_closed()
1110    }
1111    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1112        self.inner.channel().on_closed()
1113    }
1114
1115    #[cfg(target_os = "fuchsia")]
1116    fn signal_peer(
1117        &self,
1118        clear_mask: zx::Signals,
1119        set_mask: zx::Signals,
1120    ) -> Result<(), zx_status::Status> {
1121        use fidl::Peered;
1122        self.inner.channel().signal_peer(clear_mask, set_mask)
1123    }
1124}
1125
1126impl CaptureControlHandle {}
1127
1128#[must_use = "FIDL methods require a response to be sent"]
1129#[derive(Debug)]
1130pub struct CaptureStartOutputCaptureResponder {
1131    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1132    tx_id: u32,
1133}
1134
1135/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1136/// if the responder is dropped without sending a response, so that the client
1137/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1138impl std::ops::Drop for CaptureStartOutputCaptureResponder {
1139    fn drop(&mut self) {
1140        self.control_handle.shutdown();
1141        // Safety: drops once, never accessed again
1142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1143    }
1144}
1145
1146impl fidl::endpoints::Responder for CaptureStartOutputCaptureResponder {
1147    type ControlHandle = CaptureControlHandle;
1148
1149    fn control_handle(&self) -> &CaptureControlHandle {
1150        &self.control_handle
1151    }
1152
1153    fn drop_without_shutdown(mut self) {
1154        // Safety: drops once, never accessed again due to mem::forget
1155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1156        // Prevent Drop from running (which would shut down the channel)
1157        std::mem::forget(self);
1158    }
1159}
1160
1161impl CaptureStartOutputCaptureResponder {
1162    /// Sends a response to the FIDL transaction.
1163    ///
1164    /// Sets the channel to shutdown if an error occurs.
1165    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1166        let _result = self.send_raw(result);
1167        if _result.is_err() {
1168            self.control_handle.shutdown();
1169        }
1170        self.drop_without_shutdown();
1171        _result
1172    }
1173
1174    /// Similar to "send" but does not shutdown the channel if an error occurs.
1175    pub fn send_no_shutdown_on_err(
1176        self,
1177        mut result: Result<(), AudioTestError>,
1178    ) -> Result<(), fidl::Error> {
1179        let _result = self.send_raw(result);
1180        self.drop_without_shutdown();
1181        _result
1182    }
1183
1184    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1185        self.control_handle.inner.send::<fidl::encoding::ResultType<
1186            fidl::encoding::EmptyStruct,
1187            AudioTestError,
1188        >>(
1189            result,
1190            self.tx_id,
1191            0x3da5afb01b70be17,
1192            fidl::encoding::DynamicFlags::empty(),
1193        )
1194    }
1195}
1196
1197#[must_use = "FIDL methods require a response to be sent"]
1198#[derive(Debug)]
1199pub struct CaptureStopOutputCaptureResponder {
1200    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1201    tx_id: u32,
1202}
1203
1204/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1205/// if the responder is dropped without sending a response, so that the client
1206/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1207impl std::ops::Drop for CaptureStopOutputCaptureResponder {
1208    fn drop(&mut self) {
1209        self.control_handle.shutdown();
1210        // Safety: drops once, never accessed again
1211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1212    }
1213}
1214
1215impl fidl::endpoints::Responder for CaptureStopOutputCaptureResponder {
1216    type ControlHandle = CaptureControlHandle;
1217
1218    fn control_handle(&self) -> &CaptureControlHandle {
1219        &self.control_handle
1220    }
1221
1222    fn drop_without_shutdown(mut self) {
1223        // Safety: drops once, never accessed again due to mem::forget
1224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1225        // Prevent Drop from running (which would shut down the channel)
1226        std::mem::forget(self);
1227    }
1228}
1229
1230impl CaptureStopOutputCaptureResponder {
1231    /// Sends a response to the FIDL transaction.
1232    ///
1233    /// Sets the channel to shutdown if an error occurs.
1234    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1235        let _result = self.send_raw(result);
1236        if _result.is_err() {
1237            self.control_handle.shutdown();
1238        }
1239        self.drop_without_shutdown();
1240        _result
1241    }
1242
1243    /// Similar to "send" but does not shutdown the channel if an error occurs.
1244    pub fn send_no_shutdown_on_err(
1245        self,
1246        mut result: Result<(), AudioTestError>,
1247    ) -> Result<(), fidl::Error> {
1248        let _result = self.send_raw(result);
1249        self.drop_without_shutdown();
1250        _result
1251    }
1252
1253    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1254        self.control_handle.inner.send::<fidl::encoding::ResultType<
1255            fidl::encoding::EmptyStruct,
1256            AudioTestError,
1257        >>(
1258            result,
1259            self.tx_id,
1260            0x4598c765e8859b6b,
1261            fidl::encoding::DynamicFlags::empty(),
1262        )
1263    }
1264}
1265
1266#[must_use = "FIDL methods require a response to be sent"]
1267#[derive(Debug)]
1268pub struct CaptureWaitForQuietResponder {
1269    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1270    tx_id: u32,
1271}
1272
1273/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1274/// if the responder is dropped without sending a response, so that the client
1275/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1276impl std::ops::Drop for CaptureWaitForQuietResponder {
1277    fn drop(&mut self) {
1278        self.control_handle.shutdown();
1279        // Safety: drops once, never accessed again
1280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1281    }
1282}
1283
1284impl fidl::endpoints::Responder for CaptureWaitForQuietResponder {
1285    type ControlHandle = CaptureControlHandle;
1286
1287    fn control_handle(&self) -> &CaptureControlHandle {
1288        &self.control_handle
1289    }
1290
1291    fn drop_without_shutdown(mut self) {
1292        // Safety: drops once, never accessed again due to mem::forget
1293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1294        // Prevent Drop from running (which would shut down the channel)
1295        std::mem::forget(self);
1296    }
1297}
1298
1299impl CaptureWaitForQuietResponder {
1300    /// Sends a response to the FIDL transaction.
1301    ///
1302    /// Sets the channel to shutdown if an error occurs.
1303    pub fn send(
1304        self,
1305        mut result: Result<WaitForQuietResult, AudioTestError>,
1306    ) -> Result<(), fidl::Error> {
1307        let _result = self.send_raw(result);
1308        if _result.is_err() {
1309            self.control_handle.shutdown();
1310        }
1311        self.drop_without_shutdown();
1312        _result
1313    }
1314
1315    /// Similar to "send" but does not shutdown the channel if an error occurs.
1316    pub fn send_no_shutdown_on_err(
1317        self,
1318        mut result: Result<WaitForQuietResult, AudioTestError>,
1319    ) -> Result<(), fidl::Error> {
1320        let _result = self.send_raw(result);
1321        self.drop_without_shutdown();
1322        _result
1323    }
1324
1325    fn send_raw(
1326        &self,
1327        mut result: Result<WaitForQuietResult, AudioTestError>,
1328    ) -> Result<(), fidl::Error> {
1329        self.control_handle.inner.send::<fidl::encoding::ResultType<
1330            CaptureWaitForQuietResponse,
1331            AudioTestError,
1332        >>(
1333            result.map(|result| (result,)),
1334            self.tx_id,
1335            0x7f8de156ce46d54b,
1336            fidl::encoding::DynamicFlags::empty(),
1337        )
1338    }
1339}
1340
1341#[must_use = "FIDL methods require a response to be sent"]
1342#[derive(Debug)]
1343pub struct CaptureQueueTriggeredCaptureResponder {
1344    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1345    tx_id: u32,
1346}
1347
1348/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1349/// if the responder is dropped without sending a response, so that the client
1350/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1351impl std::ops::Drop for CaptureQueueTriggeredCaptureResponder {
1352    fn drop(&mut self) {
1353        self.control_handle.shutdown();
1354        // Safety: drops once, never accessed again
1355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1356    }
1357}
1358
1359impl fidl::endpoints::Responder for CaptureQueueTriggeredCaptureResponder {
1360    type ControlHandle = CaptureControlHandle;
1361
1362    fn control_handle(&self) -> &CaptureControlHandle {
1363        &self.control_handle
1364    }
1365
1366    fn drop_without_shutdown(mut self) {
1367        // Safety: drops once, never accessed again due to mem::forget
1368        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1369        // Prevent Drop from running (which would shut down the channel)
1370        std::mem::forget(self);
1371    }
1372}
1373
1374impl CaptureQueueTriggeredCaptureResponder {
1375    /// Sends a response to the FIDL transaction.
1376    ///
1377    /// Sets the channel to shutdown if an error occurs.
1378    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1379        let _result = self.send_raw(result);
1380        if _result.is_err() {
1381            self.control_handle.shutdown();
1382        }
1383        self.drop_without_shutdown();
1384        _result
1385    }
1386
1387    /// Similar to "send" but does not shutdown the channel if an error occurs.
1388    pub fn send_no_shutdown_on_err(
1389        self,
1390        mut result: Result<(), AudioTestError>,
1391    ) -> Result<(), fidl::Error> {
1392        let _result = self.send_raw(result);
1393        self.drop_without_shutdown();
1394        _result
1395    }
1396
1397    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
1398        self.control_handle.inner.send::<fidl::encoding::ResultType<
1399            fidl::encoding::EmptyStruct,
1400            AudioTestError,
1401        >>(
1402            result,
1403            self.tx_id,
1404            0x5d372fd28da4efb2,
1405            fidl::encoding::DynamicFlags::empty(),
1406        )
1407    }
1408}
1409
1410#[must_use = "FIDL methods require a response to be sent"]
1411#[derive(Debug)]
1412pub struct CaptureWaitForTriggeredCaptureResponder {
1413    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1414    tx_id: u32,
1415}
1416
1417/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1418/// if the responder is dropped without sending a response, so that the client
1419/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1420impl std::ops::Drop for CaptureWaitForTriggeredCaptureResponder {
1421    fn drop(&mut self) {
1422        self.control_handle.shutdown();
1423        // Safety: drops once, never accessed again
1424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1425    }
1426}
1427
1428impl fidl::endpoints::Responder for CaptureWaitForTriggeredCaptureResponder {
1429    type ControlHandle = CaptureControlHandle;
1430
1431    fn control_handle(&self) -> &CaptureControlHandle {
1432        &self.control_handle
1433    }
1434
1435    fn drop_without_shutdown(mut self) {
1436        // Safety: drops once, never accessed again due to mem::forget
1437        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1438        // Prevent Drop from running (which would shut down the channel)
1439        std::mem::forget(self);
1440    }
1441}
1442
1443impl CaptureWaitForTriggeredCaptureResponder {
1444    /// Sends a response to the FIDL transaction.
1445    ///
1446    /// Sets the channel to shutdown if an error occurs.
1447    pub fn send(
1448        self,
1449        mut result: Result<QueuedCaptureResult, AudioTestError>,
1450    ) -> Result<(), fidl::Error> {
1451        let _result = self.send_raw(result);
1452        if _result.is_err() {
1453            self.control_handle.shutdown();
1454        }
1455        self.drop_without_shutdown();
1456        _result
1457    }
1458
1459    /// Similar to "send" but does not shutdown the channel if an error occurs.
1460    pub fn send_no_shutdown_on_err(
1461        self,
1462        mut result: Result<QueuedCaptureResult, AudioTestError>,
1463    ) -> Result<(), fidl::Error> {
1464        let _result = self.send_raw(result);
1465        self.drop_without_shutdown();
1466        _result
1467    }
1468
1469    fn send_raw(
1470        &self,
1471        mut result: Result<QueuedCaptureResult, AudioTestError>,
1472    ) -> Result<(), fidl::Error> {
1473        self.control_handle.inner.send::<fidl::encoding::ResultType<
1474            CaptureWaitForTriggeredCaptureResponse,
1475            AudioTestError,
1476        >>(
1477            result.map(|result| (result,)),
1478            self.tx_id,
1479            0x7b55fa2cfe9c6c3,
1480            fidl::encoding::DynamicFlags::empty(),
1481        )
1482    }
1483}
1484
1485#[must_use = "FIDL methods require a response to be sent"]
1486#[derive(Debug)]
1487pub struct CaptureGetOutputAudioResponder {
1488    control_handle: std::mem::ManuallyDrop<CaptureControlHandle>,
1489    tx_id: u32,
1490}
1491
1492/// Set the the channel to be shutdown (see [`CaptureControlHandle::shutdown`])
1493/// if the responder is dropped without sending a response, so that the client
1494/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1495impl std::ops::Drop for CaptureGetOutputAudioResponder {
1496    fn drop(&mut self) {
1497        self.control_handle.shutdown();
1498        // Safety: drops once, never accessed again
1499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1500    }
1501}
1502
1503impl fidl::endpoints::Responder for CaptureGetOutputAudioResponder {
1504    type ControlHandle = CaptureControlHandle;
1505
1506    fn control_handle(&self) -> &CaptureControlHandle {
1507        &self.control_handle
1508    }
1509
1510    fn drop_without_shutdown(mut self) {
1511        // Safety: drops once, never accessed again due to mem::forget
1512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1513        // Prevent Drop from running (which would shut down the channel)
1514        std::mem::forget(self);
1515    }
1516}
1517
1518impl CaptureGetOutputAudioResponder {
1519    /// Sends a response to the FIDL transaction.
1520    ///
1521    /// Sets the channel to shutdown if an error occurs.
1522    pub fn send(self, mut result: Result<fidl::Socket, AudioTestError>) -> Result<(), fidl::Error> {
1523        let _result = self.send_raw(result);
1524        if _result.is_err() {
1525            self.control_handle.shutdown();
1526        }
1527        self.drop_without_shutdown();
1528        _result
1529    }
1530
1531    /// Similar to "send" but does not shutdown the channel if an error occurs.
1532    pub fn send_no_shutdown_on_err(
1533        self,
1534        mut result: Result<fidl::Socket, AudioTestError>,
1535    ) -> Result<(), fidl::Error> {
1536        let _result = self.send_raw(result);
1537        self.drop_without_shutdown();
1538        _result
1539    }
1540
1541    fn send_raw(
1542        &self,
1543        mut result: Result<fidl::Socket, AudioTestError>,
1544    ) -> Result<(), fidl::Error> {
1545        self.control_handle.inner.send::<fidl::encoding::ResultType<
1546            CaptureGetOutputAudioResponse,
1547            AudioTestError,
1548        >>(
1549            result.map(|audio_reader| (audio_reader,)),
1550            self.tx_id,
1551            0x23960702c8a96e54,
1552            fidl::encoding::DynamicFlags::empty(),
1553        )
1554    }
1555}
1556
1557#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1558pub struct InjectionMarker;
1559
1560impl fidl::endpoints::ProtocolMarker for InjectionMarker {
1561    type Proxy = InjectionProxy;
1562    type RequestStream = InjectionRequestStream;
1563    #[cfg(target_os = "fuchsia")]
1564    type SynchronousProxy = InjectionSynchronousProxy;
1565
1566    const DEBUG_NAME: &'static str = "fuchsia.test.audio.Injection";
1567}
1568impl fidl::endpoints::DiscoverableProtocolMarker for InjectionMarker {}
1569pub type InjectionGetInputAudioSizeResult = Result<u64, AudioTestError>;
1570pub type InjectionClearInputAudioResult = Result<(), AudioTestError>;
1571pub type InjectionWaitUntilInputIsDoneResult = Result<(), AudioTestError>;
1572pub type InjectionStartInputInjectionResult = Result<(), AudioTestError>;
1573pub type InjectionStopInputInjectionResult = Result<(), AudioTestError>;
1574
1575pub trait InjectionProxyInterface: Send + Sync {
1576    fn r#write_input_audio(
1577        &self,
1578        index: i32,
1579        audio_writer: fidl::Socket,
1580    ) -> Result<(), fidl::Error>;
1581    type GetInputAudioSizeResponseFut: std::future::Future<Output = Result<InjectionGetInputAudioSizeResult, fidl::Error>>
1582        + Send;
1583    fn r#get_input_audio_size(&self, index: i32) -> Self::GetInputAudioSizeResponseFut;
1584    type ClearInputAudioResponseFut: std::future::Future<Output = Result<InjectionClearInputAudioResult, fidl::Error>>
1585        + Send;
1586    fn r#clear_input_audio(&self, index: i32) -> Self::ClearInputAudioResponseFut;
1587    type WaitUntilInputIsDoneResponseFut: std::future::Future<Output = Result<InjectionWaitUntilInputIsDoneResult, fidl::Error>>
1588        + Send;
1589    fn r#wait_until_input_is_done(&self) -> Self::WaitUntilInputIsDoneResponseFut;
1590    type StartInputInjectionResponseFut: std::future::Future<Output = Result<InjectionStartInputInjectionResult, fidl::Error>>
1591        + Send;
1592    fn r#start_input_injection(&self, index: i32) -> Self::StartInputInjectionResponseFut;
1593    type StopInputInjectionResponseFut: std::future::Future<Output = Result<InjectionStopInputInjectionResult, fidl::Error>>
1594        + Send;
1595    fn r#stop_input_injection(&self) -> Self::StopInputInjectionResponseFut;
1596}
1597#[derive(Debug)]
1598#[cfg(target_os = "fuchsia")]
1599pub struct InjectionSynchronousProxy {
1600    client: fidl::client::sync::Client,
1601}
1602
1603#[cfg(target_os = "fuchsia")]
1604impl fidl::endpoints::SynchronousProxy for InjectionSynchronousProxy {
1605    type Proxy = InjectionProxy;
1606    type Protocol = InjectionMarker;
1607
1608    fn from_channel(inner: fidl::Channel) -> Self {
1609        Self::new(inner)
1610    }
1611
1612    fn into_channel(self) -> fidl::Channel {
1613        self.client.into_channel()
1614    }
1615
1616    fn as_channel(&self) -> &fidl::Channel {
1617        self.client.as_channel()
1618    }
1619}
1620
1621#[cfg(target_os = "fuchsia")]
1622impl InjectionSynchronousProxy {
1623    pub fn new(channel: fidl::Channel) -> Self {
1624        let protocol_name = <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1625        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1626    }
1627
1628    pub fn into_channel(self) -> fidl::Channel {
1629        self.client.into_channel()
1630    }
1631
1632    /// Waits until an event arrives and returns it. It is safe for other
1633    /// threads to make concurrent requests while waiting for an event.
1634    pub fn wait_for_event(
1635        &self,
1636        deadline: zx::MonotonicInstant,
1637    ) -> Result<InjectionEvent, fidl::Error> {
1638        InjectionEvent::decode(self.client.wait_for_event(deadline)?)
1639    }
1640
1641    /// Set the audio to be injected at `index`.
1642    ///
1643    /// The first time this is called, an empty vector will be created, subsequent calls will
1644    /// append to `audio_data` to the same vector.
1645    ///
1646    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
1647    ///
1648    /// Further requests on the same Injection connection are blocked until the audio_writer socket
1649    /// is drained completely. To determine when injection is complete, users may initiate
1650    /// a call to GetInputAudioSize immediately following the call to this method.
1651    ///
1652    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
1653    /// + request `audio_writer` socket where audio data will be loaded from.
1654    pub fn r#write_input_audio(
1655        &self,
1656        mut index: i32,
1657        mut audio_writer: fidl::Socket,
1658    ) -> Result<(), fidl::Error> {
1659        self.client.send::<InjectionWriteInputAudioRequest>(
1660            (index, audio_writer),
1661            0x2eaec6d4251a030d,
1662            fidl::encoding::DynamicFlags::empty(),
1663        )
1664    }
1665
1666    /// Get the size of audio data stored at `index`.
1667    ///
1668    /// This method returns the number of bytes of input data stored at the given index.
1669    ///
1670    /// If a `WriteInputAudio` call is pending for the given index,
1671    /// this method will block until the socket is drained and the data
1672    /// is fully stored.
1673    ///
1674    /// + request `index` refers to a specific `audio_data` input record.
1675    /// - response `error` description of failure action to take.
1676    pub fn r#get_input_audio_size(
1677        &self,
1678        mut index: i32,
1679        ___deadline: zx::MonotonicInstant,
1680    ) -> Result<InjectionGetInputAudioSizeResult, fidl::Error> {
1681        let _response = self.client.send_query::<
1682            InjectionGetInputAudioSizeRequest,
1683            fidl::encoding::ResultType<InjectionGetInputAudioSizeResponse, AudioTestError>,
1684        >(
1685            (index,),
1686            0x57684145b51cf28,
1687            fidl::encoding::DynamicFlags::empty(),
1688            ___deadline,
1689        )?;
1690        Ok(_response.map(|x| x.byte_count))
1691    }
1692
1693    /// Clears audio data stored at `index`.
1694    ///
1695    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
1696    ///
1697    /// + request `index` refers a specific `audio_data` input record to clear.
1698    /// - response `error` description of failure action to take.
1699    pub fn r#clear_input_audio(
1700        &self,
1701        mut index: i32,
1702        ___deadline: zx::MonotonicInstant,
1703    ) -> Result<InjectionClearInputAudioResult, fidl::Error> {
1704        let _response = self.client.send_query::<
1705            InjectionClearInputAudioRequest,
1706            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1707        >(
1708            (index,),
1709            0x33259f902aace7b7,
1710            fidl::encoding::DynamicFlags::empty(),
1711            ___deadline,
1712        )?;
1713        Ok(_response.map(|x| x))
1714    }
1715
1716    /// Wait until injected inputs are done playing.
1717    ///
1718    /// This function returns only when all injected audio tracks are complete.
1719    ///
1720    /// This is intended to be called after calling `StartInputInjection`.
1721    /// If no tracks have been started, or all started tracks have already completed,
1722    /// then this function will immediately return without error.
1723    ///
1724    /// - response `error` description of failure action to take.
1725    pub fn r#wait_until_input_is_done(
1726        &self,
1727        ___deadline: zx::MonotonicInstant,
1728    ) -> Result<InjectionWaitUntilInputIsDoneResult, fidl::Error> {
1729        let _response = self.client.send_query::<
1730            fidl::encoding::EmptyPayload,
1731            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1732        >(
1733            (),
1734            0x6cb5b4b48ffe7fc8,
1735            fidl::encoding::DynamicFlags::empty(),
1736            ___deadline,
1737        )?;
1738        Ok(_response.map(|x| x))
1739    }
1740
1741    /// Start injecting the incoming audio for this device, using the audio at `index`.
1742    ///
1743    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
1744    ///
1745    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
1746    /// - response `error` description of failure action to take.
1747    pub fn r#start_input_injection(
1748        &self,
1749        mut index: i32,
1750        ___deadline: zx::MonotonicInstant,
1751    ) -> Result<InjectionStartInputInjectionResult, fidl::Error> {
1752        let _response = self.client.send_query::<
1753            InjectionStartInputInjectionRequest,
1754            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1755        >(
1756            (index,),
1757            0x753a5415ad966b06,
1758            fidl::encoding::DynamicFlags::empty(),
1759            ___deadline,
1760        )?;
1761        Ok(_response.map(|x| x))
1762    }
1763
1764    /// Stop injecting audio data.
1765    ///
1766    /// This stops playing all injected tracks.
1767    ///
1768    /// This is intended to be called after calling `StartInputInjection`.
1769    /// If no tracks have been started, or if all started tracks have already completed,
1770    /// then this function will immediately return without error.
1771    ///
1772    /// - response `error` description of failure action to take.
1773    pub fn r#stop_input_injection(
1774        &self,
1775        ___deadline: zx::MonotonicInstant,
1776    ) -> Result<InjectionStopInputInjectionResult, fidl::Error> {
1777        let _response = self.client.send_query::<
1778            fidl::encoding::EmptyPayload,
1779            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
1780        >(
1781            (),
1782            0x371fce6bb8d77fe,
1783            fidl::encoding::DynamicFlags::empty(),
1784            ___deadline,
1785        )?;
1786        Ok(_response.map(|x| x))
1787    }
1788}
1789
1790#[cfg(target_os = "fuchsia")]
1791impl From<InjectionSynchronousProxy> for zx::NullableHandle {
1792    fn from(value: InjectionSynchronousProxy) -> Self {
1793        value.into_channel().into()
1794    }
1795}
1796
1797#[cfg(target_os = "fuchsia")]
1798impl From<fidl::Channel> for InjectionSynchronousProxy {
1799    fn from(value: fidl::Channel) -> Self {
1800        Self::new(value)
1801    }
1802}
1803
1804#[cfg(target_os = "fuchsia")]
1805impl fidl::endpoints::FromClient for InjectionSynchronousProxy {
1806    type Protocol = InjectionMarker;
1807
1808    fn from_client(value: fidl::endpoints::ClientEnd<InjectionMarker>) -> Self {
1809        Self::new(value.into_channel())
1810    }
1811}
1812
1813#[derive(Debug, Clone)]
1814pub struct InjectionProxy {
1815    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1816}
1817
1818impl fidl::endpoints::Proxy for InjectionProxy {
1819    type Protocol = InjectionMarker;
1820
1821    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1822        Self::new(inner)
1823    }
1824
1825    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1826        self.client.into_channel().map_err(|client| Self { client })
1827    }
1828
1829    fn as_channel(&self) -> &::fidl::AsyncChannel {
1830        self.client.as_channel()
1831    }
1832}
1833
1834impl InjectionProxy {
1835    /// Create a new Proxy for fuchsia.test.audio/Injection.
1836    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1837        let protocol_name = <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1838        Self { client: fidl::client::Client::new(channel, protocol_name) }
1839    }
1840
1841    /// Get a Stream of events from the remote end of the protocol.
1842    ///
1843    /// # Panics
1844    ///
1845    /// Panics if the event stream was already taken.
1846    pub fn take_event_stream(&self) -> InjectionEventStream {
1847        InjectionEventStream { event_receiver: self.client.take_event_receiver() }
1848    }
1849
1850    /// Set the audio to be injected at `index`.
1851    ///
1852    /// The first time this is called, an empty vector will be created, subsequent calls will
1853    /// append to `audio_data` to the same vector.
1854    ///
1855    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
1856    ///
1857    /// Further requests on the same Injection connection are blocked until the audio_writer socket
1858    /// is drained completely. To determine when injection is complete, users may initiate
1859    /// a call to GetInputAudioSize immediately following the call to this method.
1860    ///
1861    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
1862    /// + request `audio_writer` socket where audio data will be loaded from.
1863    pub fn r#write_input_audio(
1864        &self,
1865        mut index: i32,
1866        mut audio_writer: fidl::Socket,
1867    ) -> Result<(), fidl::Error> {
1868        InjectionProxyInterface::r#write_input_audio(self, index, audio_writer)
1869    }
1870
1871    /// Get the size of audio data stored at `index`.
1872    ///
1873    /// This method returns the number of bytes of input data stored at the given index.
1874    ///
1875    /// If a `WriteInputAudio` call is pending for the given index,
1876    /// this method will block until the socket is drained and the data
1877    /// is fully stored.
1878    ///
1879    /// + request `index` refers to a specific `audio_data` input record.
1880    /// - response `error` description of failure action to take.
1881    pub fn r#get_input_audio_size(
1882        &self,
1883        mut index: i32,
1884    ) -> fidl::client::QueryResponseFut<
1885        InjectionGetInputAudioSizeResult,
1886        fidl::encoding::DefaultFuchsiaResourceDialect,
1887    > {
1888        InjectionProxyInterface::r#get_input_audio_size(self, index)
1889    }
1890
1891    /// Clears audio data stored at `index`.
1892    ///
1893    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
1894    ///
1895    /// + request `index` refers a specific `audio_data` input record to clear.
1896    /// - response `error` description of failure action to take.
1897    pub fn r#clear_input_audio(
1898        &self,
1899        mut index: i32,
1900    ) -> fidl::client::QueryResponseFut<
1901        InjectionClearInputAudioResult,
1902        fidl::encoding::DefaultFuchsiaResourceDialect,
1903    > {
1904        InjectionProxyInterface::r#clear_input_audio(self, index)
1905    }
1906
1907    /// Wait until injected inputs are done playing.
1908    ///
1909    /// This function returns only when all injected audio tracks are complete.
1910    ///
1911    /// This is intended to be called after calling `StartInputInjection`.
1912    /// If no tracks have been started, or all started tracks have already completed,
1913    /// then this function will immediately return without error.
1914    ///
1915    /// - response `error` description of failure action to take.
1916    pub fn r#wait_until_input_is_done(
1917        &self,
1918    ) -> fidl::client::QueryResponseFut<
1919        InjectionWaitUntilInputIsDoneResult,
1920        fidl::encoding::DefaultFuchsiaResourceDialect,
1921    > {
1922        InjectionProxyInterface::r#wait_until_input_is_done(self)
1923    }
1924
1925    /// Start injecting the incoming audio for this device, using the audio at `index`.
1926    ///
1927    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
1928    ///
1929    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
1930    /// - response `error` description of failure action to take.
1931    pub fn r#start_input_injection(
1932        &self,
1933        mut index: i32,
1934    ) -> fidl::client::QueryResponseFut<
1935        InjectionStartInputInjectionResult,
1936        fidl::encoding::DefaultFuchsiaResourceDialect,
1937    > {
1938        InjectionProxyInterface::r#start_input_injection(self, index)
1939    }
1940
1941    /// Stop injecting audio data.
1942    ///
1943    /// This stops playing all injected tracks.
1944    ///
1945    /// This is intended to be called after calling `StartInputInjection`.
1946    /// If no tracks have been started, or if all started tracks have already completed,
1947    /// then this function will immediately return without error.
1948    ///
1949    /// - response `error` description of failure action to take.
1950    pub fn r#stop_input_injection(
1951        &self,
1952    ) -> fidl::client::QueryResponseFut<
1953        InjectionStopInputInjectionResult,
1954        fidl::encoding::DefaultFuchsiaResourceDialect,
1955    > {
1956        InjectionProxyInterface::r#stop_input_injection(self)
1957    }
1958}
1959
1960impl InjectionProxyInterface for InjectionProxy {
1961    fn r#write_input_audio(
1962        &self,
1963        mut index: i32,
1964        mut audio_writer: fidl::Socket,
1965    ) -> Result<(), fidl::Error> {
1966        self.client.send::<InjectionWriteInputAudioRequest>(
1967            (index, audio_writer),
1968            0x2eaec6d4251a030d,
1969            fidl::encoding::DynamicFlags::empty(),
1970        )
1971    }
1972
1973    type GetInputAudioSizeResponseFut = fidl::client::QueryResponseFut<
1974        InjectionGetInputAudioSizeResult,
1975        fidl::encoding::DefaultFuchsiaResourceDialect,
1976    >;
1977    fn r#get_input_audio_size(&self, mut index: i32) -> Self::GetInputAudioSizeResponseFut {
1978        fn _decode(
1979            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1980        ) -> Result<InjectionGetInputAudioSizeResult, fidl::Error> {
1981            let _response = fidl::client::decode_transaction_body::<
1982                fidl::encoding::ResultType<InjectionGetInputAudioSizeResponse, AudioTestError>,
1983                fidl::encoding::DefaultFuchsiaResourceDialect,
1984                0x57684145b51cf28,
1985            >(_buf?)?;
1986            Ok(_response.map(|x| x.byte_count))
1987        }
1988        self.client.send_query_and_decode::<
1989            InjectionGetInputAudioSizeRequest,
1990            InjectionGetInputAudioSizeResult,
1991        >(
1992            (index,),
1993            0x57684145b51cf28,
1994            fidl::encoding::DynamicFlags::empty(),
1995            _decode,
1996        )
1997    }
1998
1999    type ClearInputAudioResponseFut = fidl::client::QueryResponseFut<
2000        InjectionClearInputAudioResult,
2001        fidl::encoding::DefaultFuchsiaResourceDialect,
2002    >;
2003    fn r#clear_input_audio(&self, mut index: i32) -> Self::ClearInputAudioResponseFut {
2004        fn _decode(
2005            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2006        ) -> Result<InjectionClearInputAudioResult, fidl::Error> {
2007            let _response = fidl::client::decode_transaction_body::<
2008                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
2009                fidl::encoding::DefaultFuchsiaResourceDialect,
2010                0x33259f902aace7b7,
2011            >(_buf?)?;
2012            Ok(_response.map(|x| x))
2013        }
2014        self.client.send_query_and_decode::<
2015            InjectionClearInputAudioRequest,
2016            InjectionClearInputAudioResult,
2017        >(
2018            (index,),
2019            0x33259f902aace7b7,
2020            fidl::encoding::DynamicFlags::empty(),
2021            _decode,
2022        )
2023    }
2024
2025    type WaitUntilInputIsDoneResponseFut = fidl::client::QueryResponseFut<
2026        InjectionWaitUntilInputIsDoneResult,
2027        fidl::encoding::DefaultFuchsiaResourceDialect,
2028    >;
2029    fn r#wait_until_input_is_done(&self) -> Self::WaitUntilInputIsDoneResponseFut {
2030        fn _decode(
2031            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2032        ) -> Result<InjectionWaitUntilInputIsDoneResult, fidl::Error> {
2033            let _response = fidl::client::decode_transaction_body::<
2034                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
2035                fidl::encoding::DefaultFuchsiaResourceDialect,
2036                0x6cb5b4b48ffe7fc8,
2037            >(_buf?)?;
2038            Ok(_response.map(|x| x))
2039        }
2040        self.client.send_query_and_decode::<
2041            fidl::encoding::EmptyPayload,
2042            InjectionWaitUntilInputIsDoneResult,
2043        >(
2044            (),
2045            0x6cb5b4b48ffe7fc8,
2046            fidl::encoding::DynamicFlags::empty(),
2047            _decode,
2048        )
2049    }
2050
2051    type StartInputInjectionResponseFut = fidl::client::QueryResponseFut<
2052        InjectionStartInputInjectionResult,
2053        fidl::encoding::DefaultFuchsiaResourceDialect,
2054    >;
2055    fn r#start_input_injection(&self, mut index: i32) -> Self::StartInputInjectionResponseFut {
2056        fn _decode(
2057            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2058        ) -> Result<InjectionStartInputInjectionResult, fidl::Error> {
2059            let _response = fidl::client::decode_transaction_body::<
2060                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
2061                fidl::encoding::DefaultFuchsiaResourceDialect,
2062                0x753a5415ad966b06,
2063            >(_buf?)?;
2064            Ok(_response.map(|x| x))
2065        }
2066        self.client.send_query_and_decode::<
2067            InjectionStartInputInjectionRequest,
2068            InjectionStartInputInjectionResult,
2069        >(
2070            (index,),
2071            0x753a5415ad966b06,
2072            fidl::encoding::DynamicFlags::empty(),
2073            _decode,
2074        )
2075    }
2076
2077    type StopInputInjectionResponseFut = fidl::client::QueryResponseFut<
2078        InjectionStopInputInjectionResult,
2079        fidl::encoding::DefaultFuchsiaResourceDialect,
2080    >;
2081    fn r#stop_input_injection(&self) -> Self::StopInputInjectionResponseFut {
2082        fn _decode(
2083            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2084        ) -> Result<InjectionStopInputInjectionResult, fidl::Error> {
2085            let _response = fidl::client::decode_transaction_body::<
2086                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AudioTestError>,
2087                fidl::encoding::DefaultFuchsiaResourceDialect,
2088                0x371fce6bb8d77fe,
2089            >(_buf?)?;
2090            Ok(_response.map(|x| x))
2091        }
2092        self.client.send_query_and_decode::<
2093            fidl::encoding::EmptyPayload,
2094            InjectionStopInputInjectionResult,
2095        >(
2096            (),
2097            0x371fce6bb8d77fe,
2098            fidl::encoding::DynamicFlags::empty(),
2099            _decode,
2100        )
2101    }
2102}
2103
2104pub struct InjectionEventStream {
2105    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2106}
2107
2108impl std::marker::Unpin for InjectionEventStream {}
2109
2110impl futures::stream::FusedStream for InjectionEventStream {
2111    fn is_terminated(&self) -> bool {
2112        self.event_receiver.is_terminated()
2113    }
2114}
2115
2116impl futures::Stream for InjectionEventStream {
2117    type Item = Result<InjectionEvent, fidl::Error>;
2118
2119    fn poll_next(
2120        mut self: std::pin::Pin<&mut Self>,
2121        cx: &mut std::task::Context<'_>,
2122    ) -> std::task::Poll<Option<Self::Item>> {
2123        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2124            &mut self.event_receiver,
2125            cx
2126        )?) {
2127            Some(buf) => std::task::Poll::Ready(Some(InjectionEvent::decode(buf))),
2128            None => std::task::Poll::Ready(None),
2129        }
2130    }
2131}
2132
2133#[derive(Debug)]
2134pub enum InjectionEvent {
2135    #[non_exhaustive]
2136    _UnknownEvent {
2137        /// Ordinal of the event that was sent.
2138        ordinal: u64,
2139    },
2140}
2141
2142impl InjectionEvent {
2143    /// Decodes a message buffer as a [`InjectionEvent`].
2144    fn decode(
2145        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2146    ) -> Result<InjectionEvent, fidl::Error> {
2147        let (bytes, _handles) = buf.split_mut();
2148        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2149        debug_assert_eq!(tx_header.tx_id, 0);
2150        match tx_header.ordinal {
2151            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2152                Ok(InjectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2153            }
2154            _ => Err(fidl::Error::UnknownOrdinal {
2155                ordinal: tx_header.ordinal,
2156                protocol_name: <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2157            }),
2158        }
2159    }
2160}
2161
2162/// A Stream of incoming requests for fuchsia.test.audio/Injection.
2163pub struct InjectionRequestStream {
2164    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2165    is_terminated: bool,
2166}
2167
2168impl std::marker::Unpin for InjectionRequestStream {}
2169
2170impl futures::stream::FusedStream for InjectionRequestStream {
2171    fn is_terminated(&self) -> bool {
2172        self.is_terminated
2173    }
2174}
2175
2176impl fidl::endpoints::RequestStream for InjectionRequestStream {
2177    type Protocol = InjectionMarker;
2178    type ControlHandle = InjectionControlHandle;
2179
2180    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2181        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2182    }
2183
2184    fn control_handle(&self) -> Self::ControlHandle {
2185        InjectionControlHandle { inner: self.inner.clone() }
2186    }
2187
2188    fn into_inner(
2189        self,
2190    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2191    {
2192        (self.inner, self.is_terminated)
2193    }
2194
2195    fn from_inner(
2196        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2197        is_terminated: bool,
2198    ) -> Self {
2199        Self { inner, is_terminated }
2200    }
2201}
2202
2203impl futures::Stream for InjectionRequestStream {
2204    type Item = Result<InjectionRequest, fidl::Error>;
2205
2206    fn poll_next(
2207        mut self: std::pin::Pin<&mut Self>,
2208        cx: &mut std::task::Context<'_>,
2209    ) -> std::task::Poll<Option<Self::Item>> {
2210        let this = &mut *self;
2211        if this.inner.check_shutdown(cx) {
2212            this.is_terminated = true;
2213            return std::task::Poll::Ready(None);
2214        }
2215        if this.is_terminated {
2216            panic!("polled InjectionRequestStream after completion");
2217        }
2218        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2219            |bytes, handles| {
2220                match this.inner.channel().read_etc(cx, bytes, handles) {
2221                    std::task::Poll::Ready(Ok(())) => {}
2222                    std::task::Poll::Pending => return std::task::Poll::Pending,
2223                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2224                        this.is_terminated = true;
2225                        return std::task::Poll::Ready(None);
2226                    }
2227                    std::task::Poll::Ready(Err(e)) => {
2228                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2229                            e.into(),
2230                        ))));
2231                    }
2232                }
2233
2234                // A message has been received from the channel
2235                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2236
2237                std::task::Poll::Ready(Some(match header.ordinal {
2238                    0x2eaec6d4251a030d => {
2239                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2240                        let mut req = fidl::new_empty!(
2241                            InjectionWriteInputAudioRequest,
2242                            fidl::encoding::DefaultFuchsiaResourceDialect
2243                        );
2244                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionWriteInputAudioRequest>(&header, _body_bytes, handles, &mut req)?;
2245                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2246                        Ok(InjectionRequest::WriteInputAudio {
2247                            index: req.index,
2248                            audio_writer: req.audio_writer,
2249
2250                            control_handle,
2251                        })
2252                    }
2253                    0x57684145b51cf28 => {
2254                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2255                        let mut req = fidl::new_empty!(
2256                            InjectionGetInputAudioSizeRequest,
2257                            fidl::encoding::DefaultFuchsiaResourceDialect
2258                        );
2259                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionGetInputAudioSizeRequest>(&header, _body_bytes, handles, &mut req)?;
2260                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2261                        Ok(InjectionRequest::GetInputAudioSize {
2262                            index: req.index,
2263
2264                            responder: InjectionGetInputAudioSizeResponder {
2265                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2266                                tx_id: header.tx_id,
2267                            },
2268                        })
2269                    }
2270                    0x33259f902aace7b7 => {
2271                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2272                        let mut req = fidl::new_empty!(
2273                            InjectionClearInputAudioRequest,
2274                            fidl::encoding::DefaultFuchsiaResourceDialect
2275                        );
2276                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionClearInputAudioRequest>(&header, _body_bytes, handles, &mut req)?;
2277                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2278                        Ok(InjectionRequest::ClearInputAudio {
2279                            index: req.index,
2280
2281                            responder: InjectionClearInputAudioResponder {
2282                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2283                                tx_id: header.tx_id,
2284                            },
2285                        })
2286                    }
2287                    0x6cb5b4b48ffe7fc8 => {
2288                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2289                        let mut req = fidl::new_empty!(
2290                            fidl::encoding::EmptyPayload,
2291                            fidl::encoding::DefaultFuchsiaResourceDialect
2292                        );
2293                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2294                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2295                        Ok(InjectionRequest::WaitUntilInputIsDone {
2296                            responder: InjectionWaitUntilInputIsDoneResponder {
2297                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2298                                tx_id: header.tx_id,
2299                            },
2300                        })
2301                    }
2302                    0x753a5415ad966b06 => {
2303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2304                        let mut req = fidl::new_empty!(
2305                            InjectionStartInputInjectionRequest,
2306                            fidl::encoding::DefaultFuchsiaResourceDialect
2307                        );
2308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InjectionStartInputInjectionRequest>(&header, _body_bytes, handles, &mut req)?;
2309                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2310                        Ok(InjectionRequest::StartInputInjection {
2311                            index: req.index,
2312
2313                            responder: InjectionStartInputInjectionResponder {
2314                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2315                                tx_id: header.tx_id,
2316                            },
2317                        })
2318                    }
2319                    0x371fce6bb8d77fe => {
2320                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2321                        let mut req = fidl::new_empty!(
2322                            fidl::encoding::EmptyPayload,
2323                            fidl::encoding::DefaultFuchsiaResourceDialect
2324                        );
2325                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2326                        let control_handle = InjectionControlHandle { inner: this.inner.clone() };
2327                        Ok(InjectionRequest::StopInputInjection {
2328                            responder: InjectionStopInputInjectionResponder {
2329                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2330                                tx_id: header.tx_id,
2331                            },
2332                        })
2333                    }
2334                    _ if header.tx_id == 0
2335                        && header
2336                            .dynamic_flags()
2337                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2338                    {
2339                        Ok(InjectionRequest::_UnknownMethod {
2340                            ordinal: header.ordinal,
2341                            control_handle: InjectionControlHandle { inner: this.inner.clone() },
2342                            method_type: fidl::MethodType::OneWay,
2343                        })
2344                    }
2345                    _ if header
2346                        .dynamic_flags()
2347                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2348                    {
2349                        this.inner.send_framework_err(
2350                            fidl::encoding::FrameworkErr::UnknownMethod,
2351                            header.tx_id,
2352                            header.ordinal,
2353                            header.dynamic_flags(),
2354                            (bytes, handles),
2355                        )?;
2356                        Ok(InjectionRequest::_UnknownMethod {
2357                            ordinal: header.ordinal,
2358                            control_handle: InjectionControlHandle { inner: this.inner.clone() },
2359                            method_type: fidl::MethodType::TwoWay,
2360                        })
2361                    }
2362                    _ => Err(fidl::Error::UnknownOrdinal {
2363                        ordinal: header.ordinal,
2364                        protocol_name:
2365                            <InjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2366                    }),
2367                }))
2368            },
2369        )
2370    }
2371}
2372
2373/// A protocol that supports audio input injection.
2374///
2375/// Connections to this protocol control a virtual input audio device which can be used to inject
2376/// audio as if it came from a microphone.
2377///
2378/// The server contains indexed tracks which can be independently queued and played.
2379/// When injecting audio, it is common to pre-load all required inputs for a test scenario and
2380/// play them sequentially, using WaitUntilInputIsDone to determine when to start the next stage.
2381#[derive(Debug)]
2382pub enum InjectionRequest {
2383    /// Set the audio to be injected at `index`.
2384    ///
2385    /// The first time this is called, an empty vector will be created, subsequent calls will
2386    /// append to `audio_data` to the same vector.
2387    ///
2388    /// Use `ClearInputAudio` to clear audio input data stored at `index`.
2389    ///
2390    /// Further requests on the same Injection connection are blocked until the audio_writer socket
2391    /// is drained completely. To determine when injection is complete, users may initiate
2392    /// a call to GetInputAudioSize immediately following the call to this method.
2393    ///
2394    /// + request `index` refers a specific `audio_data` input record. We can have multiple records.
2395    /// + request `audio_writer` socket where audio data will be loaded from.
2396    WriteInputAudio {
2397        index: i32,
2398        audio_writer: fidl::Socket,
2399        control_handle: InjectionControlHandle,
2400    },
2401    /// Get the size of audio data stored at `index`.
2402    ///
2403    /// This method returns the number of bytes of input data stored at the given index.
2404    ///
2405    /// If a `WriteInputAudio` call is pending for the given index,
2406    /// this method will block until the socket is drained and the data
2407    /// is fully stored.
2408    ///
2409    /// + request `index` refers to a specific `audio_data` input record.
2410    /// - response `error` description of failure action to take.
2411    GetInputAudioSize { index: i32, responder: InjectionGetInputAudioSizeResponder },
2412    /// Clears audio data stored at `index`.
2413    ///
2414    /// If no data exists at `index` nothing will get cleared, but no error will be returned.
2415    ///
2416    /// + request `index` refers a specific `audio_data` input record to clear.
2417    /// - response `error` description of failure action to take.
2418    ClearInputAudio { index: i32, responder: InjectionClearInputAudioResponder },
2419    /// Wait until injected inputs are done playing.
2420    ///
2421    /// This function returns only when all injected audio tracks are complete.
2422    ///
2423    /// This is intended to be called after calling `StartInputInjection`.
2424    /// If no tracks have been started, or all started tracks have already completed,
2425    /// then this function will immediately return without error.
2426    ///
2427    /// - response `error` description of failure action to take.
2428    WaitUntilInputIsDone { responder: InjectionWaitUntilInputIsDoneResponder },
2429    /// Start injecting the incoming audio for this device, using the audio at `index`.
2430    ///
2431    /// Before calling this, use `WriteInputAudio` to store audio data at the given index.
2432    ///
2433    /// + request `index` refers a specific `audio_data` input record to play on the virtual microphone.
2434    /// - response `error` description of failure action to take.
2435    StartInputInjection { index: i32, responder: InjectionStartInputInjectionResponder },
2436    /// Stop injecting audio data.
2437    ///
2438    /// This stops playing all injected tracks.
2439    ///
2440    /// This is intended to be called after calling `StartInputInjection`.
2441    /// If no tracks have been started, or if all started tracks have already completed,
2442    /// then this function will immediately return without error.
2443    ///
2444    /// - response `error` description of failure action to take.
2445    StopInputInjection { responder: InjectionStopInputInjectionResponder },
2446    /// An interaction was received which does not match any known method.
2447    #[non_exhaustive]
2448    _UnknownMethod {
2449        /// Ordinal of the method that was called.
2450        ordinal: u64,
2451        control_handle: InjectionControlHandle,
2452        method_type: fidl::MethodType,
2453    },
2454}
2455
2456impl InjectionRequest {
2457    #[allow(irrefutable_let_patterns)]
2458    pub fn into_write_input_audio(self) -> Option<(i32, fidl::Socket, InjectionControlHandle)> {
2459        if let InjectionRequest::WriteInputAudio { index, audio_writer, control_handle } = self {
2460            Some((index, audio_writer, control_handle))
2461        } else {
2462            None
2463        }
2464    }
2465
2466    #[allow(irrefutable_let_patterns)]
2467    pub fn into_get_input_audio_size(self) -> Option<(i32, InjectionGetInputAudioSizeResponder)> {
2468        if let InjectionRequest::GetInputAudioSize { index, responder } = self {
2469            Some((index, responder))
2470        } else {
2471            None
2472        }
2473    }
2474
2475    #[allow(irrefutable_let_patterns)]
2476    pub fn into_clear_input_audio(self) -> Option<(i32, InjectionClearInputAudioResponder)> {
2477        if let InjectionRequest::ClearInputAudio { index, responder } = self {
2478            Some((index, responder))
2479        } else {
2480            None
2481        }
2482    }
2483
2484    #[allow(irrefutable_let_patterns)]
2485    pub fn into_wait_until_input_is_done(self) -> Option<(InjectionWaitUntilInputIsDoneResponder)> {
2486        if let InjectionRequest::WaitUntilInputIsDone { responder } = self {
2487            Some((responder))
2488        } else {
2489            None
2490        }
2491    }
2492
2493    #[allow(irrefutable_let_patterns)]
2494    pub fn into_start_input_injection(
2495        self,
2496    ) -> Option<(i32, InjectionStartInputInjectionResponder)> {
2497        if let InjectionRequest::StartInputInjection { index, responder } = self {
2498            Some((index, responder))
2499        } else {
2500            None
2501        }
2502    }
2503
2504    #[allow(irrefutable_let_patterns)]
2505    pub fn into_stop_input_injection(self) -> Option<(InjectionStopInputInjectionResponder)> {
2506        if let InjectionRequest::StopInputInjection { responder } = self {
2507            Some((responder))
2508        } else {
2509            None
2510        }
2511    }
2512
2513    /// Name of the method defined in FIDL
2514    pub fn method_name(&self) -> &'static str {
2515        match *self {
2516            InjectionRequest::WriteInputAudio { .. } => "write_input_audio",
2517            InjectionRequest::GetInputAudioSize { .. } => "get_input_audio_size",
2518            InjectionRequest::ClearInputAudio { .. } => "clear_input_audio",
2519            InjectionRequest::WaitUntilInputIsDone { .. } => "wait_until_input_is_done",
2520            InjectionRequest::StartInputInjection { .. } => "start_input_injection",
2521            InjectionRequest::StopInputInjection { .. } => "stop_input_injection",
2522            InjectionRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2523                "unknown one-way method"
2524            }
2525            InjectionRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2526                "unknown two-way method"
2527            }
2528        }
2529    }
2530}
2531
2532#[derive(Debug, Clone)]
2533pub struct InjectionControlHandle {
2534    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2535}
2536
2537impl fidl::endpoints::ControlHandle for InjectionControlHandle {
2538    fn shutdown(&self) {
2539        self.inner.shutdown()
2540    }
2541
2542    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2543        self.inner.shutdown_with_epitaph(status)
2544    }
2545
2546    fn is_closed(&self) -> bool {
2547        self.inner.channel().is_closed()
2548    }
2549    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2550        self.inner.channel().on_closed()
2551    }
2552
2553    #[cfg(target_os = "fuchsia")]
2554    fn signal_peer(
2555        &self,
2556        clear_mask: zx::Signals,
2557        set_mask: zx::Signals,
2558    ) -> Result<(), zx_status::Status> {
2559        use fidl::Peered;
2560        self.inner.channel().signal_peer(clear_mask, set_mask)
2561    }
2562}
2563
2564impl InjectionControlHandle {}
2565
2566#[must_use = "FIDL methods require a response to be sent"]
2567#[derive(Debug)]
2568pub struct InjectionGetInputAudioSizeResponder {
2569    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2570    tx_id: u32,
2571}
2572
2573/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2574/// if the responder is dropped without sending a response, so that the client
2575/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2576impl std::ops::Drop for InjectionGetInputAudioSizeResponder {
2577    fn drop(&mut self) {
2578        self.control_handle.shutdown();
2579        // Safety: drops once, never accessed again
2580        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2581    }
2582}
2583
2584impl fidl::endpoints::Responder for InjectionGetInputAudioSizeResponder {
2585    type ControlHandle = InjectionControlHandle;
2586
2587    fn control_handle(&self) -> &InjectionControlHandle {
2588        &self.control_handle
2589    }
2590
2591    fn drop_without_shutdown(mut self) {
2592        // Safety: drops once, never accessed again due to mem::forget
2593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2594        // Prevent Drop from running (which would shut down the channel)
2595        std::mem::forget(self);
2596    }
2597}
2598
2599impl InjectionGetInputAudioSizeResponder {
2600    /// Sends a response to the FIDL transaction.
2601    ///
2602    /// Sets the channel to shutdown if an error occurs.
2603    pub fn send(self, mut result: Result<u64, AudioTestError>) -> Result<(), fidl::Error> {
2604        let _result = self.send_raw(result);
2605        if _result.is_err() {
2606            self.control_handle.shutdown();
2607        }
2608        self.drop_without_shutdown();
2609        _result
2610    }
2611
2612    /// Similar to "send" but does not shutdown the channel if an error occurs.
2613    pub fn send_no_shutdown_on_err(
2614        self,
2615        mut result: Result<u64, AudioTestError>,
2616    ) -> Result<(), fidl::Error> {
2617        let _result = self.send_raw(result);
2618        self.drop_without_shutdown();
2619        _result
2620    }
2621
2622    fn send_raw(&self, mut result: Result<u64, AudioTestError>) -> Result<(), fidl::Error> {
2623        self.control_handle.inner.send::<fidl::encoding::ResultType<
2624            InjectionGetInputAudioSizeResponse,
2625            AudioTestError,
2626        >>(
2627            result.map(|byte_count| (byte_count,)),
2628            self.tx_id,
2629            0x57684145b51cf28,
2630            fidl::encoding::DynamicFlags::empty(),
2631        )
2632    }
2633}
2634
2635#[must_use = "FIDL methods require a response to be sent"]
2636#[derive(Debug)]
2637pub struct InjectionClearInputAudioResponder {
2638    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2639    tx_id: u32,
2640}
2641
2642/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2643/// if the responder is dropped without sending a response, so that the client
2644/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2645impl std::ops::Drop for InjectionClearInputAudioResponder {
2646    fn drop(&mut self) {
2647        self.control_handle.shutdown();
2648        // Safety: drops once, never accessed again
2649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2650    }
2651}
2652
2653impl fidl::endpoints::Responder for InjectionClearInputAudioResponder {
2654    type ControlHandle = InjectionControlHandle;
2655
2656    fn control_handle(&self) -> &InjectionControlHandle {
2657        &self.control_handle
2658    }
2659
2660    fn drop_without_shutdown(mut self) {
2661        // Safety: drops once, never accessed again due to mem::forget
2662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2663        // Prevent Drop from running (which would shut down the channel)
2664        std::mem::forget(self);
2665    }
2666}
2667
2668impl InjectionClearInputAudioResponder {
2669    /// Sends a response to the FIDL transaction.
2670    ///
2671    /// Sets the channel to shutdown if an error occurs.
2672    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2673        let _result = self.send_raw(result);
2674        if _result.is_err() {
2675            self.control_handle.shutdown();
2676        }
2677        self.drop_without_shutdown();
2678        _result
2679    }
2680
2681    /// Similar to "send" but does not shutdown the channel if an error occurs.
2682    pub fn send_no_shutdown_on_err(
2683        self,
2684        mut result: Result<(), AudioTestError>,
2685    ) -> Result<(), fidl::Error> {
2686        let _result = self.send_raw(result);
2687        self.drop_without_shutdown();
2688        _result
2689    }
2690
2691    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2692        self.control_handle.inner.send::<fidl::encoding::ResultType<
2693            fidl::encoding::EmptyStruct,
2694            AudioTestError,
2695        >>(
2696            result,
2697            self.tx_id,
2698            0x33259f902aace7b7,
2699            fidl::encoding::DynamicFlags::empty(),
2700        )
2701    }
2702}
2703
2704#[must_use = "FIDL methods require a response to be sent"]
2705#[derive(Debug)]
2706pub struct InjectionWaitUntilInputIsDoneResponder {
2707    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2708    tx_id: u32,
2709}
2710
2711/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2712/// if the responder is dropped without sending a response, so that the client
2713/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2714impl std::ops::Drop for InjectionWaitUntilInputIsDoneResponder {
2715    fn drop(&mut self) {
2716        self.control_handle.shutdown();
2717        // Safety: drops once, never accessed again
2718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2719    }
2720}
2721
2722impl fidl::endpoints::Responder for InjectionWaitUntilInputIsDoneResponder {
2723    type ControlHandle = InjectionControlHandle;
2724
2725    fn control_handle(&self) -> &InjectionControlHandle {
2726        &self.control_handle
2727    }
2728
2729    fn drop_without_shutdown(mut self) {
2730        // Safety: drops once, never accessed again due to mem::forget
2731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2732        // Prevent Drop from running (which would shut down the channel)
2733        std::mem::forget(self);
2734    }
2735}
2736
2737impl InjectionWaitUntilInputIsDoneResponder {
2738    /// Sends a response to the FIDL transaction.
2739    ///
2740    /// Sets the channel to shutdown if an error occurs.
2741    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2742        let _result = self.send_raw(result);
2743        if _result.is_err() {
2744            self.control_handle.shutdown();
2745        }
2746        self.drop_without_shutdown();
2747        _result
2748    }
2749
2750    /// Similar to "send" but does not shutdown the channel if an error occurs.
2751    pub fn send_no_shutdown_on_err(
2752        self,
2753        mut result: Result<(), AudioTestError>,
2754    ) -> Result<(), fidl::Error> {
2755        let _result = self.send_raw(result);
2756        self.drop_without_shutdown();
2757        _result
2758    }
2759
2760    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2761        self.control_handle.inner.send::<fidl::encoding::ResultType<
2762            fidl::encoding::EmptyStruct,
2763            AudioTestError,
2764        >>(
2765            result,
2766            self.tx_id,
2767            0x6cb5b4b48ffe7fc8,
2768            fidl::encoding::DynamicFlags::empty(),
2769        )
2770    }
2771}
2772
2773#[must_use = "FIDL methods require a response to be sent"]
2774#[derive(Debug)]
2775pub struct InjectionStartInputInjectionResponder {
2776    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2777    tx_id: u32,
2778}
2779
2780/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2781/// if the responder is dropped without sending a response, so that the client
2782/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2783impl std::ops::Drop for InjectionStartInputInjectionResponder {
2784    fn drop(&mut self) {
2785        self.control_handle.shutdown();
2786        // Safety: drops once, never accessed again
2787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2788    }
2789}
2790
2791impl fidl::endpoints::Responder for InjectionStartInputInjectionResponder {
2792    type ControlHandle = InjectionControlHandle;
2793
2794    fn control_handle(&self) -> &InjectionControlHandle {
2795        &self.control_handle
2796    }
2797
2798    fn drop_without_shutdown(mut self) {
2799        // Safety: drops once, never accessed again due to mem::forget
2800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2801        // Prevent Drop from running (which would shut down the channel)
2802        std::mem::forget(self);
2803    }
2804}
2805
2806impl InjectionStartInputInjectionResponder {
2807    /// Sends a response to the FIDL transaction.
2808    ///
2809    /// Sets the channel to shutdown if an error occurs.
2810    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2811        let _result = self.send_raw(result);
2812        if _result.is_err() {
2813            self.control_handle.shutdown();
2814        }
2815        self.drop_without_shutdown();
2816        _result
2817    }
2818
2819    /// Similar to "send" but does not shutdown the channel if an error occurs.
2820    pub fn send_no_shutdown_on_err(
2821        self,
2822        mut result: Result<(), AudioTestError>,
2823    ) -> Result<(), fidl::Error> {
2824        let _result = self.send_raw(result);
2825        self.drop_without_shutdown();
2826        _result
2827    }
2828
2829    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2830        self.control_handle.inner.send::<fidl::encoding::ResultType<
2831            fidl::encoding::EmptyStruct,
2832            AudioTestError,
2833        >>(
2834            result,
2835            self.tx_id,
2836            0x753a5415ad966b06,
2837            fidl::encoding::DynamicFlags::empty(),
2838        )
2839    }
2840}
2841
2842#[must_use = "FIDL methods require a response to be sent"]
2843#[derive(Debug)]
2844pub struct InjectionStopInputInjectionResponder {
2845    control_handle: std::mem::ManuallyDrop<InjectionControlHandle>,
2846    tx_id: u32,
2847}
2848
2849/// Set the the channel to be shutdown (see [`InjectionControlHandle::shutdown`])
2850/// if the responder is dropped without sending a response, so that the client
2851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2852impl std::ops::Drop for InjectionStopInputInjectionResponder {
2853    fn drop(&mut self) {
2854        self.control_handle.shutdown();
2855        // Safety: drops once, never accessed again
2856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2857    }
2858}
2859
2860impl fidl::endpoints::Responder for InjectionStopInputInjectionResponder {
2861    type ControlHandle = InjectionControlHandle;
2862
2863    fn control_handle(&self) -> &InjectionControlHandle {
2864        &self.control_handle
2865    }
2866
2867    fn drop_without_shutdown(mut self) {
2868        // Safety: drops once, never accessed again due to mem::forget
2869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2870        // Prevent Drop from running (which would shut down the channel)
2871        std::mem::forget(self);
2872    }
2873}
2874
2875impl InjectionStopInputInjectionResponder {
2876    /// Sends a response to the FIDL transaction.
2877    ///
2878    /// Sets the channel to shutdown if an error occurs.
2879    pub fn send(self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2880        let _result = self.send_raw(result);
2881        if _result.is_err() {
2882            self.control_handle.shutdown();
2883        }
2884        self.drop_without_shutdown();
2885        _result
2886    }
2887
2888    /// Similar to "send" but does not shutdown the channel if an error occurs.
2889    pub fn send_no_shutdown_on_err(
2890        self,
2891        mut result: Result<(), AudioTestError>,
2892    ) -> Result<(), fidl::Error> {
2893        let _result = self.send_raw(result);
2894        self.drop_without_shutdown();
2895        _result
2896    }
2897
2898    fn send_raw(&self, mut result: Result<(), AudioTestError>) -> Result<(), fidl::Error> {
2899        self.control_handle.inner.send::<fidl::encoding::ResultType<
2900            fidl::encoding::EmptyStruct,
2901            AudioTestError,
2902        >>(
2903            result,
2904            self.tx_id,
2905            0x371fce6bb8d77fe,
2906            fidl::encoding::DynamicFlags::empty(),
2907        )
2908    }
2909}
2910
2911mod internal {
2912    use super::*;
2913
2914    impl fidl::encoding::ResourceTypeMarker for CaptureGetOutputAudioResponse {
2915        type Borrowed<'a> = &'a mut Self;
2916        fn take_or_borrow<'a>(
2917            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2918        ) -> Self::Borrowed<'a> {
2919            value
2920        }
2921    }
2922
2923    unsafe impl fidl::encoding::TypeMarker for CaptureGetOutputAudioResponse {
2924        type Owned = Self;
2925
2926        #[inline(always)]
2927        fn inline_align(_context: fidl::encoding::Context) -> usize {
2928            4
2929        }
2930
2931        #[inline(always)]
2932        fn inline_size(_context: fidl::encoding::Context) -> usize {
2933            4
2934        }
2935    }
2936
2937    unsafe impl
2938        fidl::encoding::Encode<
2939            CaptureGetOutputAudioResponse,
2940            fidl::encoding::DefaultFuchsiaResourceDialect,
2941        > for &mut CaptureGetOutputAudioResponse
2942    {
2943        #[inline]
2944        unsafe fn encode(
2945            self,
2946            encoder: &mut fidl::encoding::Encoder<
2947                '_,
2948                fidl::encoding::DefaultFuchsiaResourceDialect,
2949            >,
2950            offset: usize,
2951            _depth: fidl::encoding::Depth,
2952        ) -> fidl::Result<()> {
2953            encoder.debug_check_bounds::<CaptureGetOutputAudioResponse>(offset);
2954            // Delegate to tuple encoding.
2955            fidl::encoding::Encode::<
2956                CaptureGetOutputAudioResponse,
2957                fidl::encoding::DefaultFuchsiaResourceDialect,
2958            >::encode(
2959                (<fidl::encoding::HandleType<
2960                    fidl::Socket,
2961                    { fidl::ObjectType::SOCKET.into_raw() },
2962                    2147483648,
2963                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2964                    &mut self.audio_reader
2965                ),),
2966                encoder,
2967                offset,
2968                _depth,
2969            )
2970        }
2971    }
2972    unsafe impl<
2973        T0: fidl::encoding::Encode<
2974                fidl::encoding::HandleType<
2975                    fidl::Socket,
2976                    { fidl::ObjectType::SOCKET.into_raw() },
2977                    2147483648,
2978                >,
2979                fidl::encoding::DefaultFuchsiaResourceDialect,
2980            >,
2981    >
2982        fidl::encoding::Encode<
2983            CaptureGetOutputAudioResponse,
2984            fidl::encoding::DefaultFuchsiaResourceDialect,
2985        > for (T0,)
2986    {
2987        #[inline]
2988        unsafe fn encode(
2989            self,
2990            encoder: &mut fidl::encoding::Encoder<
2991                '_,
2992                fidl::encoding::DefaultFuchsiaResourceDialect,
2993            >,
2994            offset: usize,
2995            depth: fidl::encoding::Depth,
2996        ) -> fidl::Result<()> {
2997            encoder.debug_check_bounds::<CaptureGetOutputAudioResponse>(offset);
2998            // Zero out padding regions. There's no need to apply masks
2999            // because the unmasked parts will be overwritten by fields.
3000            // Write the fields.
3001            self.0.encode(encoder, offset + 0, depth)?;
3002            Ok(())
3003        }
3004    }
3005
3006    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3007        for CaptureGetOutputAudioResponse
3008    {
3009        #[inline(always)]
3010        fn new_empty() -> Self {
3011            Self {
3012                audio_reader: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3013            }
3014        }
3015
3016        #[inline]
3017        unsafe fn decode(
3018            &mut self,
3019            decoder: &mut fidl::encoding::Decoder<
3020                '_,
3021                fidl::encoding::DefaultFuchsiaResourceDialect,
3022            >,
3023            offset: usize,
3024            _depth: fidl::encoding::Depth,
3025        ) -> fidl::Result<()> {
3026            decoder.debug_check_bounds::<Self>(offset);
3027            // Verify that padding bytes are zero.
3028            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.audio_reader, decoder, offset + 0, _depth)?;
3029            Ok(())
3030        }
3031    }
3032
3033    impl fidl::encoding::ResourceTypeMarker for InjectionClearInputAudioRequest {
3034        type Borrowed<'a> = &'a mut Self;
3035        fn take_or_borrow<'a>(
3036            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3037        ) -> Self::Borrowed<'a> {
3038            value
3039        }
3040    }
3041
3042    unsafe impl fidl::encoding::TypeMarker for InjectionClearInputAudioRequest {
3043        type Owned = Self;
3044
3045        #[inline(always)]
3046        fn inline_align(_context: fidl::encoding::Context) -> usize {
3047            4
3048        }
3049
3050        #[inline(always)]
3051        fn inline_size(_context: fidl::encoding::Context) -> usize {
3052            4
3053        }
3054        #[inline(always)]
3055        fn encode_is_copy() -> bool {
3056            true
3057        }
3058
3059        #[inline(always)]
3060        fn decode_is_copy() -> bool {
3061            true
3062        }
3063    }
3064
3065    unsafe impl
3066        fidl::encoding::Encode<
3067            InjectionClearInputAudioRequest,
3068            fidl::encoding::DefaultFuchsiaResourceDialect,
3069        > for &mut InjectionClearInputAudioRequest
3070    {
3071        #[inline]
3072        unsafe fn encode(
3073            self,
3074            encoder: &mut fidl::encoding::Encoder<
3075                '_,
3076                fidl::encoding::DefaultFuchsiaResourceDialect,
3077            >,
3078            offset: usize,
3079            _depth: fidl::encoding::Depth,
3080        ) -> fidl::Result<()> {
3081            encoder.debug_check_bounds::<InjectionClearInputAudioRequest>(offset);
3082            unsafe {
3083                // Copy the object into the buffer.
3084                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
3085                (buf_ptr as *mut InjectionClearInputAudioRequest)
3086                    .write_unaligned((self as *const InjectionClearInputAudioRequest).read());
3087                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
3088                // done second because the memcpy will write garbage to these bytes.
3089            }
3090            Ok(())
3091        }
3092    }
3093    unsafe impl<T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>>
3094        fidl::encoding::Encode<
3095            InjectionClearInputAudioRequest,
3096            fidl::encoding::DefaultFuchsiaResourceDialect,
3097        > for (T0,)
3098    {
3099        #[inline]
3100        unsafe fn encode(
3101            self,
3102            encoder: &mut fidl::encoding::Encoder<
3103                '_,
3104                fidl::encoding::DefaultFuchsiaResourceDialect,
3105            >,
3106            offset: usize,
3107            depth: fidl::encoding::Depth,
3108        ) -> fidl::Result<()> {
3109            encoder.debug_check_bounds::<InjectionClearInputAudioRequest>(offset);
3110            // Zero out padding regions. There's no need to apply masks
3111            // because the unmasked parts will be overwritten by fields.
3112            // Write the fields.
3113            self.0.encode(encoder, offset + 0, depth)?;
3114            Ok(())
3115        }
3116    }
3117
3118    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3119        for InjectionClearInputAudioRequest
3120    {
3121        #[inline(always)]
3122        fn new_empty() -> Self {
3123            Self { index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect) }
3124        }
3125
3126        #[inline]
3127        unsafe fn decode(
3128            &mut self,
3129            decoder: &mut fidl::encoding::Decoder<
3130                '_,
3131                fidl::encoding::DefaultFuchsiaResourceDialect,
3132            >,
3133            offset: usize,
3134            _depth: fidl::encoding::Depth,
3135        ) -> fidl::Result<()> {
3136            decoder.debug_check_bounds::<Self>(offset);
3137            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
3138            // Verify that padding bytes are zero.
3139            // Copy from the buffer into the object.
3140            unsafe {
3141                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
3142            }
3143            Ok(())
3144        }
3145    }
3146
3147    impl fidl::encoding::ResourceTypeMarker for InjectionStartInputInjectionRequest {
3148        type Borrowed<'a> = &'a mut Self;
3149        fn take_or_borrow<'a>(
3150            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3151        ) -> Self::Borrowed<'a> {
3152            value
3153        }
3154    }
3155
3156    unsafe impl fidl::encoding::TypeMarker for InjectionStartInputInjectionRequest {
3157        type Owned = Self;
3158
3159        #[inline(always)]
3160        fn inline_align(_context: fidl::encoding::Context) -> usize {
3161            4
3162        }
3163
3164        #[inline(always)]
3165        fn inline_size(_context: fidl::encoding::Context) -> usize {
3166            4
3167        }
3168        #[inline(always)]
3169        fn encode_is_copy() -> bool {
3170            true
3171        }
3172
3173        #[inline(always)]
3174        fn decode_is_copy() -> bool {
3175            true
3176        }
3177    }
3178
3179    unsafe impl
3180        fidl::encoding::Encode<
3181            InjectionStartInputInjectionRequest,
3182            fidl::encoding::DefaultFuchsiaResourceDialect,
3183        > for &mut InjectionStartInputInjectionRequest
3184    {
3185        #[inline]
3186        unsafe fn encode(
3187            self,
3188            encoder: &mut fidl::encoding::Encoder<
3189                '_,
3190                fidl::encoding::DefaultFuchsiaResourceDialect,
3191            >,
3192            offset: usize,
3193            _depth: fidl::encoding::Depth,
3194        ) -> fidl::Result<()> {
3195            encoder.debug_check_bounds::<InjectionStartInputInjectionRequest>(offset);
3196            unsafe {
3197                // Copy the object into the buffer.
3198                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
3199                (buf_ptr as *mut InjectionStartInputInjectionRequest)
3200                    .write_unaligned((self as *const InjectionStartInputInjectionRequest).read());
3201                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
3202                // done second because the memcpy will write garbage to these bytes.
3203            }
3204            Ok(())
3205        }
3206    }
3207    unsafe impl<T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>>
3208        fidl::encoding::Encode<
3209            InjectionStartInputInjectionRequest,
3210            fidl::encoding::DefaultFuchsiaResourceDialect,
3211        > for (T0,)
3212    {
3213        #[inline]
3214        unsafe fn encode(
3215            self,
3216            encoder: &mut fidl::encoding::Encoder<
3217                '_,
3218                fidl::encoding::DefaultFuchsiaResourceDialect,
3219            >,
3220            offset: usize,
3221            depth: fidl::encoding::Depth,
3222        ) -> fidl::Result<()> {
3223            encoder.debug_check_bounds::<InjectionStartInputInjectionRequest>(offset);
3224            // Zero out padding regions. There's no need to apply masks
3225            // because the unmasked parts will be overwritten by fields.
3226            // Write the fields.
3227            self.0.encode(encoder, offset + 0, depth)?;
3228            Ok(())
3229        }
3230    }
3231
3232    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3233        for InjectionStartInputInjectionRequest
3234    {
3235        #[inline(always)]
3236        fn new_empty() -> Self {
3237            Self { index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect) }
3238        }
3239
3240        #[inline]
3241        unsafe fn decode(
3242            &mut self,
3243            decoder: &mut fidl::encoding::Decoder<
3244                '_,
3245                fidl::encoding::DefaultFuchsiaResourceDialect,
3246            >,
3247            offset: usize,
3248            _depth: fidl::encoding::Depth,
3249        ) -> fidl::Result<()> {
3250            decoder.debug_check_bounds::<Self>(offset);
3251            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
3252            // Verify that padding bytes are zero.
3253            // Copy from the buffer into the object.
3254            unsafe {
3255                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
3256            }
3257            Ok(())
3258        }
3259    }
3260
3261    impl fidl::encoding::ResourceTypeMarker for InjectionWriteInputAudioRequest {
3262        type Borrowed<'a> = &'a mut Self;
3263        fn take_or_borrow<'a>(
3264            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3265        ) -> Self::Borrowed<'a> {
3266            value
3267        }
3268    }
3269
3270    unsafe impl fidl::encoding::TypeMarker for InjectionWriteInputAudioRequest {
3271        type Owned = Self;
3272
3273        #[inline(always)]
3274        fn inline_align(_context: fidl::encoding::Context) -> usize {
3275            4
3276        }
3277
3278        #[inline(always)]
3279        fn inline_size(_context: fidl::encoding::Context) -> usize {
3280            8
3281        }
3282    }
3283
3284    unsafe impl
3285        fidl::encoding::Encode<
3286            InjectionWriteInputAudioRequest,
3287            fidl::encoding::DefaultFuchsiaResourceDialect,
3288        > for &mut InjectionWriteInputAudioRequest
3289    {
3290        #[inline]
3291        unsafe fn encode(
3292            self,
3293            encoder: &mut fidl::encoding::Encoder<
3294                '_,
3295                fidl::encoding::DefaultFuchsiaResourceDialect,
3296            >,
3297            offset: usize,
3298            _depth: fidl::encoding::Depth,
3299        ) -> fidl::Result<()> {
3300            encoder.debug_check_bounds::<InjectionWriteInputAudioRequest>(offset);
3301            // Delegate to tuple encoding.
3302            fidl::encoding::Encode::<
3303                InjectionWriteInputAudioRequest,
3304                fidl::encoding::DefaultFuchsiaResourceDialect,
3305            >::encode(
3306                (
3307                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.index),
3308                    <fidl::encoding::HandleType<
3309                        fidl::Socket,
3310                        { fidl::ObjectType::SOCKET.into_raw() },
3311                        2147483648,
3312                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3313                        &mut self.audio_writer,
3314                    ),
3315                ),
3316                encoder,
3317                offset,
3318                _depth,
3319            )
3320        }
3321    }
3322    unsafe impl<
3323        T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3324        T1: fidl::encoding::Encode<
3325                fidl::encoding::HandleType<
3326                    fidl::Socket,
3327                    { fidl::ObjectType::SOCKET.into_raw() },
3328                    2147483648,
3329                >,
3330                fidl::encoding::DefaultFuchsiaResourceDialect,
3331            >,
3332    >
3333        fidl::encoding::Encode<
3334            InjectionWriteInputAudioRequest,
3335            fidl::encoding::DefaultFuchsiaResourceDialect,
3336        > for (T0, T1)
3337    {
3338        #[inline]
3339        unsafe fn encode(
3340            self,
3341            encoder: &mut fidl::encoding::Encoder<
3342                '_,
3343                fidl::encoding::DefaultFuchsiaResourceDialect,
3344            >,
3345            offset: usize,
3346            depth: fidl::encoding::Depth,
3347        ) -> fidl::Result<()> {
3348            encoder.debug_check_bounds::<InjectionWriteInputAudioRequest>(offset);
3349            // Zero out padding regions. There's no need to apply masks
3350            // because the unmasked parts will be overwritten by fields.
3351            // Write the fields.
3352            self.0.encode(encoder, offset + 0, depth)?;
3353            self.1.encode(encoder, offset + 4, depth)?;
3354            Ok(())
3355        }
3356    }
3357
3358    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3359        for InjectionWriteInputAudioRequest
3360    {
3361        #[inline(always)]
3362        fn new_empty() -> Self {
3363            Self {
3364                index: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
3365                audio_writer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3366            }
3367        }
3368
3369        #[inline]
3370        unsafe fn decode(
3371            &mut self,
3372            decoder: &mut fidl::encoding::Decoder<
3373                '_,
3374                fidl::encoding::DefaultFuchsiaResourceDialect,
3375            >,
3376            offset: usize,
3377            _depth: fidl::encoding::Depth,
3378        ) -> fidl::Result<()> {
3379            decoder.debug_check_bounds::<Self>(offset);
3380            // Verify that padding bytes are zero.
3381            fidl::decode!(
3382                i32,
3383                fidl::encoding::DefaultFuchsiaResourceDialect,
3384                &mut self.index,
3385                decoder,
3386                offset + 0,
3387                _depth
3388            )?;
3389            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.audio_writer, decoder, offset + 4, _depth)?;
3390            Ok(())
3391        }
3392    }
3393}