Skip to main content

fidl_fuchsia_test_audio/
fidl_fuchsia_test_audio.rs

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