fidl_fuchsia_virtualaudio/
fidl_fuchsia_virtualaudio.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_virtualaudio__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControlAddDeviceRequest {
16    pub config: Configuration,
17    pub server: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControlAddDeviceRequest {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct DeviceOnBufferCreatedRequest {
24    pub ring_buffer: fidl::Vmo,
25    pub num_ring_buffer_frames: u32,
26    pub notifications_per_ring: u32,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for DeviceOnBufferCreatedRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct DeviceGetBufferResponse {
36    pub ring_buffer: fidl::Vmo,
37    pub num_ring_buffer_frames: u32,
38    pub notifications_per_ring: u32,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetBufferResponse {}
42
43#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
44pub struct ControlMarker;
45
46impl fidl::endpoints::ProtocolMarker for ControlMarker {
47    type Proxy = ControlProxy;
48    type RequestStream = ControlRequestStream;
49    #[cfg(target_os = "fuchsia")]
50    type SynchronousProxy = ControlSynchronousProxy;
51
52    const DEBUG_NAME: &'static str = "(anonymous) Control";
53}
54pub type ControlGetDefaultConfigurationResult = Result<Configuration, Error>;
55pub type ControlAddDeviceResult = Result<(), Error>;
56
57pub trait ControlProxyInterface: Send + Sync {
58    type GetDefaultConfigurationResponseFut: std::future::Future<Output = Result<ControlGetDefaultConfigurationResult, fidl::Error>>
59        + Send;
60    fn r#get_default_configuration(
61        &self,
62        type_: DeviceType,
63        direction: &Direction,
64    ) -> Self::GetDefaultConfigurationResponseFut;
65    type AddDeviceResponseFut: std::future::Future<Output = Result<ControlAddDeviceResult, fidl::Error>>
66        + Send;
67    fn r#add_device(
68        &self,
69        config: &Configuration,
70        server: fidl::endpoints::ServerEnd<DeviceMarker>,
71    ) -> Self::AddDeviceResponseFut;
72    type GetNumDevicesResponseFut: std::future::Future<Output = Result<(u32, u32, u32), fidl::Error>>
73        + Send;
74    fn r#get_num_devices(&self) -> Self::GetNumDevicesResponseFut;
75    type RemoveAllResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
76    fn r#remove_all(&self) -> Self::RemoveAllResponseFut;
77}
78#[derive(Debug)]
79#[cfg(target_os = "fuchsia")]
80pub struct ControlSynchronousProxy {
81    client: fidl::client::sync::Client,
82}
83
84#[cfg(target_os = "fuchsia")]
85impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
86    type Proxy = ControlProxy;
87    type Protocol = ControlMarker;
88
89    fn from_channel(inner: fidl::Channel) -> Self {
90        Self::new(inner)
91    }
92
93    fn into_channel(self) -> fidl::Channel {
94        self.client.into_channel()
95    }
96
97    fn as_channel(&self) -> &fidl::Channel {
98        self.client.as_channel()
99    }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl ControlSynchronousProxy {
104    pub fn new(channel: fidl::Channel) -> Self {
105        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
106        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
107    }
108
109    pub fn into_channel(self) -> fidl::Channel {
110        self.client.into_channel()
111    }
112
113    /// Waits until an event arrives and returns it. It is safe for other
114    /// threads to make concurrent requests while waiting for an event.
115    pub fn wait_for_event(
116        &self,
117        deadline: zx::MonotonicInstant,
118    ) -> Result<ControlEvent, fidl::Error> {
119        ControlEvent::decode(self.client.wait_for_event(deadline)?)
120    }
121
122    /// Returns the default configuration for the given device type and direction.
123    pub fn r#get_default_configuration(
124        &self,
125        mut type_: DeviceType,
126        mut direction: &Direction,
127        ___deadline: zx::MonotonicInstant,
128    ) -> Result<ControlGetDefaultConfigurationResult, fidl::Error> {
129        let _response = self.client.send_query::<
130            ControlGetDefaultConfigurationRequest,
131            fidl::encoding::ResultType<ControlGetDefaultConfigurationResponse, Error>,
132        >(
133            (type_, direction,),
134            0x18fbd1298daa19e9,
135            fidl::encoding::DynamicFlags::empty(),
136            ___deadline,
137        )?;
138        Ok(_response.map(|x| x.config))
139    }
140
141    /// Adds a device to the device tree.
142    /// The device lives until the `Device` FIDL channel is closed.
143    pub fn r#add_device(
144        &self,
145        mut config: &Configuration,
146        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
147        ___deadline: zx::MonotonicInstant,
148    ) -> Result<ControlAddDeviceResult, fidl::Error> {
149        let _response = self.client.send_query::<
150            ControlAddDeviceRequest,
151            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
152        >(
153            (config, server,),
154            0x6b5fff2f3ed7ce9,
155            fidl::encoding::DynamicFlags::empty(),
156            ___deadline,
157        )?;
158        Ok(_response.map(|x| x))
159    }
160
161    /// Returns the number of active input and output devices and devices with unspecified
162    /// direction.
163    pub fn r#get_num_devices(
164        &self,
165        ___deadline: zx::MonotonicInstant,
166    ) -> Result<(u32, u32, u32), fidl::Error> {
167        let _response =
168            self.client.send_query::<fidl::encoding::EmptyPayload, ControlGetNumDevicesResponse>(
169                (),
170                0x256704ce2f8097af,
171                fidl::encoding::DynamicFlags::empty(),
172                ___deadline,
173            )?;
174        Ok((
175            _response.num_input_devices,
176            _response.num_output_devices,
177            _response.num_unspecified_direction_devices,
178        ))
179    }
180
181    /// Synchronously remove all all active input and output devices.
182    pub fn r#remove_all(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
183        let _response =
184            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
185                (),
186                0x7904287969087c4b,
187                fidl::encoding::DynamicFlags::empty(),
188                ___deadline,
189            )?;
190        Ok(_response)
191    }
192}
193
194#[cfg(target_os = "fuchsia")]
195impl From<ControlSynchronousProxy> for zx::Handle {
196    fn from(value: ControlSynchronousProxy) -> Self {
197        value.into_channel().into()
198    }
199}
200
201#[cfg(target_os = "fuchsia")]
202impl From<fidl::Channel> for ControlSynchronousProxy {
203    fn from(value: fidl::Channel) -> Self {
204        Self::new(value)
205    }
206}
207
208#[cfg(target_os = "fuchsia")]
209impl fidl::endpoints::FromClient for ControlSynchronousProxy {
210    type Protocol = ControlMarker;
211
212    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
213        Self::new(value.into_channel())
214    }
215}
216
217#[derive(Debug, Clone)]
218pub struct ControlProxy {
219    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
220}
221
222impl fidl::endpoints::Proxy for ControlProxy {
223    type Protocol = ControlMarker;
224
225    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
226        Self::new(inner)
227    }
228
229    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
230        self.client.into_channel().map_err(|client| Self { client })
231    }
232
233    fn as_channel(&self) -> &::fidl::AsyncChannel {
234        self.client.as_channel()
235    }
236}
237
238impl ControlProxy {
239    /// Create a new Proxy for fuchsia.virtualaudio/Control.
240    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
241        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
242        Self { client: fidl::client::Client::new(channel, protocol_name) }
243    }
244
245    /// Get a Stream of events from the remote end of the protocol.
246    ///
247    /// # Panics
248    ///
249    /// Panics if the event stream was already taken.
250    pub fn take_event_stream(&self) -> ControlEventStream {
251        ControlEventStream { event_receiver: self.client.take_event_receiver() }
252    }
253
254    /// Returns the default configuration for the given device type and direction.
255    pub fn r#get_default_configuration(
256        &self,
257        mut type_: DeviceType,
258        mut direction: &Direction,
259    ) -> fidl::client::QueryResponseFut<
260        ControlGetDefaultConfigurationResult,
261        fidl::encoding::DefaultFuchsiaResourceDialect,
262    > {
263        ControlProxyInterface::r#get_default_configuration(self, type_, direction)
264    }
265
266    /// Adds a device to the device tree.
267    /// The device lives until the `Device` FIDL channel is closed.
268    pub fn r#add_device(
269        &self,
270        mut config: &Configuration,
271        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
272    ) -> fidl::client::QueryResponseFut<
273        ControlAddDeviceResult,
274        fidl::encoding::DefaultFuchsiaResourceDialect,
275    > {
276        ControlProxyInterface::r#add_device(self, config, server)
277    }
278
279    /// Returns the number of active input and output devices and devices with unspecified
280    /// direction.
281    pub fn r#get_num_devices(
282        &self,
283    ) -> fidl::client::QueryResponseFut<
284        (u32, u32, u32),
285        fidl::encoding::DefaultFuchsiaResourceDialect,
286    > {
287        ControlProxyInterface::r#get_num_devices(self)
288    }
289
290    /// Synchronously remove all all active input and output devices.
291    pub fn r#remove_all(
292        &self,
293    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
294        ControlProxyInterface::r#remove_all(self)
295    }
296}
297
298impl ControlProxyInterface for ControlProxy {
299    type GetDefaultConfigurationResponseFut = fidl::client::QueryResponseFut<
300        ControlGetDefaultConfigurationResult,
301        fidl::encoding::DefaultFuchsiaResourceDialect,
302    >;
303    fn r#get_default_configuration(
304        &self,
305        mut type_: DeviceType,
306        mut direction: &Direction,
307    ) -> Self::GetDefaultConfigurationResponseFut {
308        fn _decode(
309            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
310        ) -> Result<ControlGetDefaultConfigurationResult, fidl::Error> {
311            let _response = fidl::client::decode_transaction_body::<
312                fidl::encoding::ResultType<ControlGetDefaultConfigurationResponse, Error>,
313                fidl::encoding::DefaultFuchsiaResourceDialect,
314                0x18fbd1298daa19e9,
315            >(_buf?)?;
316            Ok(_response.map(|x| x.config))
317        }
318        self.client.send_query_and_decode::<
319            ControlGetDefaultConfigurationRequest,
320            ControlGetDefaultConfigurationResult,
321        >(
322            (type_, direction,),
323            0x18fbd1298daa19e9,
324            fidl::encoding::DynamicFlags::empty(),
325            _decode,
326        )
327    }
328
329    type AddDeviceResponseFut = fidl::client::QueryResponseFut<
330        ControlAddDeviceResult,
331        fidl::encoding::DefaultFuchsiaResourceDialect,
332    >;
333    fn r#add_device(
334        &self,
335        mut config: &Configuration,
336        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
337    ) -> Self::AddDeviceResponseFut {
338        fn _decode(
339            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
340        ) -> Result<ControlAddDeviceResult, fidl::Error> {
341            let _response = fidl::client::decode_transaction_body::<
342                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
343                fidl::encoding::DefaultFuchsiaResourceDialect,
344                0x6b5fff2f3ed7ce9,
345            >(_buf?)?;
346            Ok(_response.map(|x| x))
347        }
348        self.client.send_query_and_decode::<ControlAddDeviceRequest, ControlAddDeviceResult>(
349            (config, server),
350            0x6b5fff2f3ed7ce9,
351            fidl::encoding::DynamicFlags::empty(),
352            _decode,
353        )
354    }
355
356    type GetNumDevicesResponseFut = fidl::client::QueryResponseFut<
357        (u32, u32, u32),
358        fidl::encoding::DefaultFuchsiaResourceDialect,
359    >;
360    fn r#get_num_devices(&self) -> Self::GetNumDevicesResponseFut {
361        fn _decode(
362            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
363        ) -> Result<(u32, u32, u32), fidl::Error> {
364            let _response = fidl::client::decode_transaction_body::<
365                ControlGetNumDevicesResponse,
366                fidl::encoding::DefaultFuchsiaResourceDialect,
367                0x256704ce2f8097af,
368            >(_buf?)?;
369            Ok((
370                _response.num_input_devices,
371                _response.num_output_devices,
372                _response.num_unspecified_direction_devices,
373            ))
374        }
375        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32, u32)>(
376            (),
377            0x256704ce2f8097af,
378            fidl::encoding::DynamicFlags::empty(),
379            _decode,
380        )
381    }
382
383    type RemoveAllResponseFut =
384        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
385    fn r#remove_all(&self) -> Self::RemoveAllResponseFut {
386        fn _decode(
387            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
388        ) -> Result<(), fidl::Error> {
389            let _response = fidl::client::decode_transaction_body::<
390                fidl::encoding::EmptyPayload,
391                fidl::encoding::DefaultFuchsiaResourceDialect,
392                0x7904287969087c4b,
393            >(_buf?)?;
394            Ok(_response)
395        }
396        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
397            (),
398            0x7904287969087c4b,
399            fidl::encoding::DynamicFlags::empty(),
400            _decode,
401        )
402    }
403}
404
405pub struct ControlEventStream {
406    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
407}
408
409impl std::marker::Unpin for ControlEventStream {}
410
411impl futures::stream::FusedStream for ControlEventStream {
412    fn is_terminated(&self) -> bool {
413        self.event_receiver.is_terminated()
414    }
415}
416
417impl futures::Stream for ControlEventStream {
418    type Item = Result<ControlEvent, fidl::Error>;
419
420    fn poll_next(
421        mut self: std::pin::Pin<&mut Self>,
422        cx: &mut std::task::Context<'_>,
423    ) -> std::task::Poll<Option<Self::Item>> {
424        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
425            &mut self.event_receiver,
426            cx
427        )?) {
428            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
429            None => std::task::Poll::Ready(None),
430        }
431    }
432}
433
434#[derive(Debug)]
435pub enum ControlEvent {}
436
437impl ControlEvent {
438    /// Decodes a message buffer as a [`ControlEvent`].
439    fn decode(
440        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
441    ) -> Result<ControlEvent, fidl::Error> {
442        let (bytes, _handles) = buf.split_mut();
443        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
444        debug_assert_eq!(tx_header.tx_id, 0);
445        match tx_header.ordinal {
446            _ => Err(fidl::Error::UnknownOrdinal {
447                ordinal: tx_header.ordinal,
448                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
449            }),
450        }
451    }
452}
453
454/// A Stream of incoming requests for fuchsia.virtualaudio/Control.
455pub struct ControlRequestStream {
456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
457    is_terminated: bool,
458}
459
460impl std::marker::Unpin for ControlRequestStream {}
461
462impl futures::stream::FusedStream for ControlRequestStream {
463    fn is_terminated(&self) -> bool {
464        self.is_terminated
465    }
466}
467
468impl fidl::endpoints::RequestStream for ControlRequestStream {
469    type Protocol = ControlMarker;
470    type ControlHandle = ControlControlHandle;
471
472    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
473        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
474    }
475
476    fn control_handle(&self) -> Self::ControlHandle {
477        ControlControlHandle { inner: self.inner.clone() }
478    }
479
480    fn into_inner(
481        self,
482    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
483    {
484        (self.inner, self.is_terminated)
485    }
486
487    fn from_inner(
488        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
489        is_terminated: bool,
490    ) -> Self {
491        Self { inner, is_terminated }
492    }
493}
494
495impl futures::Stream for ControlRequestStream {
496    type Item = Result<ControlRequest, fidl::Error>;
497
498    fn poll_next(
499        mut self: std::pin::Pin<&mut Self>,
500        cx: &mut std::task::Context<'_>,
501    ) -> std::task::Poll<Option<Self::Item>> {
502        let this = &mut *self;
503        if this.inner.check_shutdown(cx) {
504            this.is_terminated = true;
505            return std::task::Poll::Ready(None);
506        }
507        if this.is_terminated {
508            panic!("polled ControlRequestStream after completion");
509        }
510        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
511            |bytes, handles| {
512                match this.inner.channel().read_etc(cx, bytes, handles) {
513                    std::task::Poll::Ready(Ok(())) => {}
514                    std::task::Poll::Pending => return std::task::Poll::Pending,
515                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
516                        this.is_terminated = true;
517                        return std::task::Poll::Ready(None);
518                    }
519                    std::task::Poll::Ready(Err(e)) => {
520                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
521                            e.into(),
522                        ))))
523                    }
524                }
525
526                // A message has been received from the channel
527                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
528
529                std::task::Poll::Ready(Some(match header.ordinal {
530                    0x18fbd1298daa19e9 => {
531                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
532                        let mut req = fidl::new_empty!(
533                            ControlGetDefaultConfigurationRequest,
534                            fidl::encoding::DefaultFuchsiaResourceDialect
535                        );
536                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlGetDefaultConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
537                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
538                        Ok(ControlRequest::GetDefaultConfiguration {
539                            type_: req.type_,
540                            direction: req.direction,
541
542                            responder: ControlGetDefaultConfigurationResponder {
543                                control_handle: std::mem::ManuallyDrop::new(control_handle),
544                                tx_id: header.tx_id,
545                            },
546                        })
547                    }
548                    0x6b5fff2f3ed7ce9 => {
549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
550                        let mut req = fidl::new_empty!(
551                            ControlAddDeviceRequest,
552                            fidl::encoding::DefaultFuchsiaResourceDialect
553                        );
554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
555                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
556                        Ok(ControlRequest::AddDevice {
557                            config: req.config,
558                            server: req.server,
559
560                            responder: ControlAddDeviceResponder {
561                                control_handle: std::mem::ManuallyDrop::new(control_handle),
562                                tx_id: header.tx_id,
563                            },
564                        })
565                    }
566                    0x256704ce2f8097af => {
567                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
568                        let mut req = fidl::new_empty!(
569                            fidl::encoding::EmptyPayload,
570                            fidl::encoding::DefaultFuchsiaResourceDialect
571                        );
572                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
573                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
574                        Ok(ControlRequest::GetNumDevices {
575                            responder: ControlGetNumDevicesResponder {
576                                control_handle: std::mem::ManuallyDrop::new(control_handle),
577                                tx_id: header.tx_id,
578                            },
579                        })
580                    }
581                    0x7904287969087c4b => {
582                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
583                        let mut req = fidl::new_empty!(
584                            fidl::encoding::EmptyPayload,
585                            fidl::encoding::DefaultFuchsiaResourceDialect
586                        );
587                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
588                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
589                        Ok(ControlRequest::RemoveAll {
590                            responder: ControlRemoveAllResponder {
591                                control_handle: std::mem::ManuallyDrop::new(control_handle),
592                                tx_id: header.tx_id,
593                            },
594                        })
595                    }
596                    _ => Err(fidl::Error::UnknownOrdinal {
597                        ordinal: header.ordinal,
598                        protocol_name:
599                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
600                    }),
601                }))
602            },
603        )
604    }
605}
606
607/// This protocol provides methods for adding and removing virtual audio
608/// devices. This protocol is made available through the device tree via
609/// `CONTROL_NODE_NAME` and `LEGACY_CONTROL_NODE_NAME`.
610#[derive(Debug)]
611pub enum ControlRequest {
612    /// Returns the default configuration for the given device type and direction.
613    GetDefaultConfiguration {
614        type_: DeviceType,
615        direction: Direction,
616        responder: ControlGetDefaultConfigurationResponder,
617    },
618    /// Adds a device to the device tree.
619    /// The device lives until the `Device` FIDL channel is closed.
620    AddDevice {
621        config: Configuration,
622        server: fidl::endpoints::ServerEnd<DeviceMarker>,
623        responder: ControlAddDeviceResponder,
624    },
625    /// Returns the number of active input and output devices and devices with unspecified
626    /// direction.
627    GetNumDevices { responder: ControlGetNumDevicesResponder },
628    /// Synchronously remove all all active input and output devices.
629    RemoveAll { responder: ControlRemoveAllResponder },
630}
631
632impl ControlRequest {
633    #[allow(irrefutable_let_patterns)]
634    pub fn into_get_default_configuration(
635        self,
636    ) -> Option<(DeviceType, Direction, ControlGetDefaultConfigurationResponder)> {
637        if let ControlRequest::GetDefaultConfiguration { type_, direction, responder } = self {
638            Some((type_, direction, responder))
639        } else {
640            None
641        }
642    }
643
644    #[allow(irrefutable_let_patterns)]
645    pub fn into_add_device(
646        self,
647    ) -> Option<(Configuration, fidl::endpoints::ServerEnd<DeviceMarker>, ControlAddDeviceResponder)>
648    {
649        if let ControlRequest::AddDevice { config, server, responder } = self {
650            Some((config, server, responder))
651        } else {
652            None
653        }
654    }
655
656    #[allow(irrefutable_let_patterns)]
657    pub fn into_get_num_devices(self) -> Option<(ControlGetNumDevicesResponder)> {
658        if let ControlRequest::GetNumDevices { responder } = self {
659            Some((responder))
660        } else {
661            None
662        }
663    }
664
665    #[allow(irrefutable_let_patterns)]
666    pub fn into_remove_all(self) -> Option<(ControlRemoveAllResponder)> {
667        if let ControlRequest::RemoveAll { responder } = self {
668            Some((responder))
669        } else {
670            None
671        }
672    }
673
674    /// Name of the method defined in FIDL
675    pub fn method_name(&self) -> &'static str {
676        match *self {
677            ControlRequest::GetDefaultConfiguration { .. } => "get_default_configuration",
678            ControlRequest::AddDevice { .. } => "add_device",
679            ControlRequest::GetNumDevices { .. } => "get_num_devices",
680            ControlRequest::RemoveAll { .. } => "remove_all",
681        }
682    }
683}
684
685#[derive(Debug, Clone)]
686pub struct ControlControlHandle {
687    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
688}
689
690impl fidl::endpoints::ControlHandle for ControlControlHandle {
691    fn shutdown(&self) {
692        self.inner.shutdown()
693    }
694    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
695        self.inner.shutdown_with_epitaph(status)
696    }
697
698    fn is_closed(&self) -> bool {
699        self.inner.channel().is_closed()
700    }
701    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
702        self.inner.channel().on_closed()
703    }
704
705    #[cfg(target_os = "fuchsia")]
706    fn signal_peer(
707        &self,
708        clear_mask: zx::Signals,
709        set_mask: zx::Signals,
710    ) -> Result<(), zx_status::Status> {
711        use fidl::Peered;
712        self.inner.channel().signal_peer(clear_mask, set_mask)
713    }
714}
715
716impl ControlControlHandle {}
717
718#[must_use = "FIDL methods require a response to be sent"]
719#[derive(Debug)]
720pub struct ControlGetDefaultConfigurationResponder {
721    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
722    tx_id: u32,
723}
724
725/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
726/// if the responder is dropped without sending a response, so that the client
727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
728impl std::ops::Drop for ControlGetDefaultConfigurationResponder {
729    fn drop(&mut self) {
730        self.control_handle.shutdown();
731        // Safety: drops once, never accessed again
732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
733    }
734}
735
736impl fidl::endpoints::Responder for ControlGetDefaultConfigurationResponder {
737    type ControlHandle = ControlControlHandle;
738
739    fn control_handle(&self) -> &ControlControlHandle {
740        &self.control_handle
741    }
742
743    fn drop_without_shutdown(mut self) {
744        // Safety: drops once, never accessed again due to mem::forget
745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
746        // Prevent Drop from running (which would shut down the channel)
747        std::mem::forget(self);
748    }
749}
750
751impl ControlGetDefaultConfigurationResponder {
752    /// Sends a response to the FIDL transaction.
753    ///
754    /// Sets the channel to shutdown if an error occurs.
755    pub fn send(self, mut result: Result<&Configuration, Error>) -> Result<(), fidl::Error> {
756        let _result = self.send_raw(result);
757        if _result.is_err() {
758            self.control_handle.shutdown();
759        }
760        self.drop_without_shutdown();
761        _result
762    }
763
764    /// Similar to "send" but does not shutdown the channel if an error occurs.
765    pub fn send_no_shutdown_on_err(
766        self,
767        mut result: Result<&Configuration, Error>,
768    ) -> Result<(), fidl::Error> {
769        let _result = self.send_raw(result);
770        self.drop_without_shutdown();
771        _result
772    }
773
774    fn send_raw(&self, mut result: Result<&Configuration, Error>) -> Result<(), fidl::Error> {
775        self.control_handle.inner.send::<fidl::encoding::ResultType<
776            ControlGetDefaultConfigurationResponse,
777            Error,
778        >>(
779            result.map(|config| (config,)),
780            self.tx_id,
781            0x18fbd1298daa19e9,
782            fidl::encoding::DynamicFlags::empty(),
783        )
784    }
785}
786
787#[must_use = "FIDL methods require a response to be sent"]
788#[derive(Debug)]
789pub struct ControlAddDeviceResponder {
790    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
791    tx_id: u32,
792}
793
794/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
795/// if the responder is dropped without sending a response, so that the client
796/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
797impl std::ops::Drop for ControlAddDeviceResponder {
798    fn drop(&mut self) {
799        self.control_handle.shutdown();
800        // Safety: drops once, never accessed again
801        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
802    }
803}
804
805impl fidl::endpoints::Responder for ControlAddDeviceResponder {
806    type ControlHandle = ControlControlHandle;
807
808    fn control_handle(&self) -> &ControlControlHandle {
809        &self.control_handle
810    }
811
812    fn drop_without_shutdown(mut self) {
813        // Safety: drops once, never accessed again due to mem::forget
814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
815        // Prevent Drop from running (which would shut down the channel)
816        std::mem::forget(self);
817    }
818}
819
820impl ControlAddDeviceResponder {
821    /// Sends a response to the FIDL transaction.
822    ///
823    /// Sets the channel to shutdown if an error occurs.
824    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
825        let _result = self.send_raw(result);
826        if _result.is_err() {
827            self.control_handle.shutdown();
828        }
829        self.drop_without_shutdown();
830        _result
831    }
832
833    /// Similar to "send" but does not shutdown the channel if an error occurs.
834    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
835        let _result = self.send_raw(result);
836        self.drop_without_shutdown();
837        _result
838    }
839
840    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
841        self.control_handle
842            .inner
843            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
844                result,
845                self.tx_id,
846                0x6b5fff2f3ed7ce9,
847                fidl::encoding::DynamicFlags::empty(),
848            )
849    }
850}
851
852#[must_use = "FIDL methods require a response to be sent"]
853#[derive(Debug)]
854pub struct ControlGetNumDevicesResponder {
855    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
856    tx_id: u32,
857}
858
859/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
860/// if the responder is dropped without sending a response, so that the client
861/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
862impl std::ops::Drop for ControlGetNumDevicesResponder {
863    fn drop(&mut self) {
864        self.control_handle.shutdown();
865        // Safety: drops once, never accessed again
866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
867    }
868}
869
870impl fidl::endpoints::Responder for ControlGetNumDevicesResponder {
871    type ControlHandle = ControlControlHandle;
872
873    fn control_handle(&self) -> &ControlControlHandle {
874        &self.control_handle
875    }
876
877    fn drop_without_shutdown(mut self) {
878        // Safety: drops once, never accessed again due to mem::forget
879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
880        // Prevent Drop from running (which would shut down the channel)
881        std::mem::forget(self);
882    }
883}
884
885impl ControlGetNumDevicesResponder {
886    /// Sends a response to the FIDL transaction.
887    ///
888    /// Sets the channel to shutdown if an error occurs.
889    pub fn send(
890        self,
891        mut num_input_devices: u32,
892        mut num_output_devices: u32,
893        mut num_unspecified_direction_devices: u32,
894    ) -> Result<(), fidl::Error> {
895        let _result =
896            self.send_raw(num_input_devices, num_output_devices, num_unspecified_direction_devices);
897        if _result.is_err() {
898            self.control_handle.shutdown();
899        }
900        self.drop_without_shutdown();
901        _result
902    }
903
904    /// Similar to "send" but does not shutdown the channel if an error occurs.
905    pub fn send_no_shutdown_on_err(
906        self,
907        mut num_input_devices: u32,
908        mut num_output_devices: u32,
909        mut num_unspecified_direction_devices: u32,
910    ) -> Result<(), fidl::Error> {
911        let _result =
912            self.send_raw(num_input_devices, num_output_devices, num_unspecified_direction_devices);
913        self.drop_without_shutdown();
914        _result
915    }
916
917    fn send_raw(
918        &self,
919        mut num_input_devices: u32,
920        mut num_output_devices: u32,
921        mut num_unspecified_direction_devices: u32,
922    ) -> Result<(), fidl::Error> {
923        self.control_handle.inner.send::<ControlGetNumDevicesResponse>(
924            (num_input_devices, num_output_devices, num_unspecified_direction_devices),
925            self.tx_id,
926            0x256704ce2f8097af,
927            fidl::encoding::DynamicFlags::empty(),
928        )
929    }
930}
931
932#[must_use = "FIDL methods require a response to be sent"]
933#[derive(Debug)]
934pub struct ControlRemoveAllResponder {
935    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
936    tx_id: u32,
937}
938
939/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
940/// if the responder is dropped without sending a response, so that the client
941/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
942impl std::ops::Drop for ControlRemoveAllResponder {
943    fn drop(&mut self) {
944        self.control_handle.shutdown();
945        // Safety: drops once, never accessed again
946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
947    }
948}
949
950impl fidl::endpoints::Responder for ControlRemoveAllResponder {
951    type ControlHandle = ControlControlHandle;
952
953    fn control_handle(&self) -> &ControlControlHandle {
954        &self.control_handle
955    }
956
957    fn drop_without_shutdown(mut self) {
958        // Safety: drops once, never accessed again due to mem::forget
959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
960        // Prevent Drop from running (which would shut down the channel)
961        std::mem::forget(self);
962    }
963}
964
965impl ControlRemoveAllResponder {
966    /// Sends a response to the FIDL transaction.
967    ///
968    /// Sets the channel to shutdown if an error occurs.
969    pub fn send(self) -> Result<(), fidl::Error> {
970        let _result = self.send_raw();
971        if _result.is_err() {
972            self.control_handle.shutdown();
973        }
974        self.drop_without_shutdown();
975        _result
976    }
977
978    /// Similar to "send" but does not shutdown the channel if an error occurs.
979    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
980        let _result = self.send_raw();
981        self.drop_without_shutdown();
982        _result
983    }
984
985    fn send_raw(&self) -> Result<(), fidl::Error> {
986        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
987            (),
988            self.tx_id,
989            0x7904287969087c4b,
990            fidl::encoding::DynamicFlags::empty(),
991        )
992    }
993}
994
995#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
996pub struct DeviceMarker;
997
998impl fidl::endpoints::ProtocolMarker for DeviceMarker {
999    type Proxy = DeviceProxy;
1000    type RequestStream = DeviceRequestStream;
1001    #[cfg(target_os = "fuchsia")]
1002    type SynchronousProxy = DeviceSynchronousProxy;
1003
1004    const DEBUG_NAME: &'static str = "(anonymous) Device";
1005}
1006pub type DeviceGetFormatResult = Result<(u32, u32, u32, i64), Error>;
1007pub type DeviceGetGainResult = Result<(bool, bool, f32), Error>;
1008pub type DeviceGetBufferResult = Result<(fidl::Vmo, u32, u32), Error>;
1009pub type DeviceSetNotificationFrequencyResult = Result<(), Error>;
1010pub type DeviceGetPositionResult = Result<(i64, u32), Error>;
1011pub type DeviceChangePlugStateResult = Result<(), Error>;
1012pub type DeviceAdjustClockRateResult = Result<(), Error>;
1013
1014pub trait DeviceProxyInterface: Send + Sync {
1015    type GetFormatResponseFut: std::future::Future<Output = Result<DeviceGetFormatResult, fidl::Error>>
1016        + Send;
1017    fn r#get_format(&self) -> Self::GetFormatResponseFut;
1018    type GetGainResponseFut: std::future::Future<Output = Result<DeviceGetGainResult, fidl::Error>>
1019        + Send;
1020    fn r#get_gain(&self) -> Self::GetGainResponseFut;
1021    type GetBufferResponseFut: std::future::Future<Output = Result<DeviceGetBufferResult, fidl::Error>>
1022        + Send;
1023    fn r#get_buffer(&self) -> Self::GetBufferResponseFut;
1024    type SetNotificationFrequencyResponseFut: std::future::Future<Output = Result<DeviceSetNotificationFrequencyResult, fidl::Error>>
1025        + Send;
1026    fn r#set_notification_frequency(
1027        &self,
1028        notifications_per_ring: u32,
1029    ) -> Self::SetNotificationFrequencyResponseFut;
1030    type GetPositionResponseFut: std::future::Future<Output = Result<DeviceGetPositionResult, fidl::Error>>
1031        + Send;
1032    fn r#get_position(&self) -> Self::GetPositionResponseFut;
1033    type ChangePlugStateResponseFut: std::future::Future<Output = Result<DeviceChangePlugStateResult, fidl::Error>>
1034        + Send;
1035    fn r#change_plug_state(
1036        &self,
1037        plug_change_time: i64,
1038        plugged: bool,
1039    ) -> Self::ChangePlugStateResponseFut;
1040    type AdjustClockRateResponseFut: std::future::Future<Output = Result<DeviceAdjustClockRateResult, fidl::Error>>
1041        + Send;
1042    fn r#adjust_clock_rate(&self, ppm_from_monotonic: i32) -> Self::AdjustClockRateResponseFut;
1043}
1044#[derive(Debug)]
1045#[cfg(target_os = "fuchsia")]
1046pub struct DeviceSynchronousProxy {
1047    client: fidl::client::sync::Client,
1048}
1049
1050#[cfg(target_os = "fuchsia")]
1051impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
1052    type Proxy = DeviceProxy;
1053    type Protocol = DeviceMarker;
1054
1055    fn from_channel(inner: fidl::Channel) -> Self {
1056        Self::new(inner)
1057    }
1058
1059    fn into_channel(self) -> fidl::Channel {
1060        self.client.into_channel()
1061    }
1062
1063    fn as_channel(&self) -> &fidl::Channel {
1064        self.client.as_channel()
1065    }
1066}
1067
1068#[cfg(target_os = "fuchsia")]
1069impl DeviceSynchronousProxy {
1070    pub fn new(channel: fidl::Channel) -> Self {
1071        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1072        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1073    }
1074
1075    pub fn into_channel(self) -> fidl::Channel {
1076        self.client.into_channel()
1077    }
1078
1079    /// Waits until an event arrives and returns it. It is safe for other
1080    /// threads to make concurrent requests while waiting for an event.
1081    pub fn wait_for_event(
1082        &self,
1083        deadline: zx::MonotonicInstant,
1084    ) -> Result<DeviceEvent, fidl::Error> {
1085        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
1086    }
1087
1088    /// Returns the format selected by the client, or `NO_RING_BUFFER` if the
1089    /// client has not yet selected a ring buffer format.
1090    pub fn r#get_format(
1091        &self,
1092        ___deadline: zx::MonotonicInstant,
1093    ) -> Result<DeviceGetFormatResult, fidl::Error> {
1094        let _response = self.client.send_query::<
1095            fidl::encoding::EmptyPayload,
1096            fidl::encoding::ResultType<DeviceGetFormatResponse, Error>,
1097        >(
1098            (),
1099            0x6107d32083bacc1b,
1100            fidl::encoding::DynamicFlags::empty(),
1101            ___deadline,
1102        )?;
1103        Ok(_response
1104            .map(|x| (x.frames_per_second, x.sample_format, x.num_channels, x.external_delay)))
1105    }
1106
1107    /// Returns the current gain state for this device.
1108    pub fn r#get_gain(
1109        &self,
1110        ___deadline: zx::MonotonicInstant,
1111    ) -> Result<DeviceGetGainResult, fidl::Error> {
1112        let _response = self.client.send_query::<
1113            fidl::encoding::EmptyPayload,
1114            fidl::encoding::ResultType<DeviceGetGainResponse, Error>,
1115        >(
1116            (),
1117            0x6d85d82b49fb28e9,
1118            fidl::encoding::DynamicFlags::empty(),
1119            ___deadline,
1120        )?;
1121        Ok(_response.map(|x| (x.current_mute, x.current_agc, x.current_gain_db)))
1122    }
1123
1124    /// Returns details about the ring buffer. Returns `NO_RING_BUFFER` if the
1125    /// client has not yet created the ring buffer.
1126    pub fn r#get_buffer(
1127        &self,
1128        ___deadline: zx::MonotonicInstant,
1129    ) -> Result<DeviceGetBufferResult, fidl::Error> {
1130        let _response = self.client.send_query::<
1131            fidl::encoding::EmptyPayload,
1132            fidl::encoding::ResultType<DeviceGetBufferResponse, Error>,
1133        >(
1134            (),
1135            0x38e202be0db060d0,
1136            fidl::encoding::DynamicFlags::empty(),
1137            ___deadline,
1138        )?;
1139        Ok(_response.map(|x| (x.ring_buffer, x.num_ring_buffer_frames, x.notifications_per_ring)))
1140    }
1141
1142    /// Overrides the position notification frequency for this stream.
1143    /// This affects the frequency of `OnPositionNotify` events only. It does
1144    /// not affect the frequency of notification events sent through the audio
1145    /// driver APIs.
1146    pub fn r#set_notification_frequency(
1147        &self,
1148        mut notifications_per_ring: u32,
1149        ___deadline: zx::MonotonicInstant,
1150    ) -> Result<DeviceSetNotificationFrequencyResult, fidl::Error> {
1151        let _response = self.client.send_query::<
1152            DeviceSetNotificationFrequencyRequest,
1153            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1154        >(
1155            (notifications_per_ring,),
1156            0x45789b88ca9185b8,
1157            fidl::encoding::DynamicFlags::empty(),
1158            ___deadline,
1159        )?;
1160        Ok(_response.map(|x| x))
1161    }
1162
1163    /// Returns the current position (in bytes) within the ring buffer, along
1164    /// with the time (per MONOTONIC clock) that corresponds with that position.
1165    /// This can only be called after the ring buffer is established. Returns
1166    /// `NOT_STARTED` if the device has not yet Started streaming.
1167    pub fn r#get_position(
1168        &self,
1169        ___deadline: zx::MonotonicInstant,
1170    ) -> Result<DeviceGetPositionResult, fidl::Error> {
1171        let _response = self.client.send_query::<
1172            fidl::encoding::EmptyPayload,
1173            fidl::encoding::ResultType<DeviceGetPositionResponse, Error>,
1174        >(
1175            (),
1176            0x6fe5bbf9065258e8,
1177            fidl::encoding::DynamicFlags::empty(),
1178            ___deadline,
1179        )?;
1180        Ok(_response.map(|x| (x.monotonic_time, x.ring_position)))
1181    }
1182
1183    /// Hot-plugs or hot-unplugs an active virtual device, at the specified
1184    /// time.
1185    pub fn r#change_plug_state(
1186        &self,
1187        mut plug_change_time: i64,
1188        mut plugged: bool,
1189        ___deadline: zx::MonotonicInstant,
1190    ) -> Result<DeviceChangePlugStateResult, fidl::Error> {
1191        let _response = self.client.send_query::<
1192            DeviceChangePlugStateRequest,
1193            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1194        >(
1195            (plug_change_time, plugged,),
1196            0x61aa2d370caaf8f0,
1197            fidl::encoding::DynamicFlags::empty(),
1198            ___deadline,
1199        )?;
1200        Ok(_response.map(|x| x))
1201    }
1202
1203    /// Immediately change the virtual device's clock rate, as expressed in the
1204    /// timing and content of position notifications the driver emits.
1205    /// 'ppm_monotonic' cannot exceed [-1000,+1000]. Each rate change in rate is
1206    /// standalone; i.e. successive rate changes are not cumulative.
1207    pub fn r#adjust_clock_rate(
1208        &self,
1209        mut ppm_from_monotonic: i32,
1210        ___deadline: zx::MonotonicInstant,
1211    ) -> Result<DeviceAdjustClockRateResult, fidl::Error> {
1212        let _response = self.client.send_query::<
1213            DeviceAdjustClockRateRequest,
1214            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1215        >(
1216            (ppm_from_monotonic,),
1217            0x754661f655350134,
1218            fidl::encoding::DynamicFlags::empty(),
1219            ___deadline,
1220        )?;
1221        Ok(_response.map(|x| x))
1222    }
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl From<DeviceSynchronousProxy> for zx::Handle {
1227    fn from(value: DeviceSynchronousProxy) -> Self {
1228        value.into_channel().into()
1229    }
1230}
1231
1232#[cfg(target_os = "fuchsia")]
1233impl From<fidl::Channel> for DeviceSynchronousProxy {
1234    fn from(value: fidl::Channel) -> Self {
1235        Self::new(value)
1236    }
1237}
1238
1239#[cfg(target_os = "fuchsia")]
1240impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
1241    type Protocol = DeviceMarker;
1242
1243    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
1244        Self::new(value.into_channel())
1245    }
1246}
1247
1248#[derive(Debug, Clone)]
1249pub struct DeviceProxy {
1250    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1251}
1252
1253impl fidl::endpoints::Proxy for DeviceProxy {
1254    type Protocol = DeviceMarker;
1255
1256    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1257        Self::new(inner)
1258    }
1259
1260    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1261        self.client.into_channel().map_err(|client| Self { client })
1262    }
1263
1264    fn as_channel(&self) -> &::fidl::AsyncChannel {
1265        self.client.as_channel()
1266    }
1267}
1268
1269impl DeviceProxy {
1270    /// Create a new Proxy for fuchsia.virtualaudio/Device.
1271    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1272        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1273        Self { client: fidl::client::Client::new(channel, protocol_name) }
1274    }
1275
1276    /// Get a Stream of events from the remote end of the protocol.
1277    ///
1278    /// # Panics
1279    ///
1280    /// Panics if the event stream was already taken.
1281    pub fn take_event_stream(&self) -> DeviceEventStream {
1282        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1283    }
1284
1285    /// Returns the format selected by the client, or `NO_RING_BUFFER` if the
1286    /// client has not yet selected a ring buffer format.
1287    pub fn r#get_format(
1288        &self,
1289    ) -> fidl::client::QueryResponseFut<
1290        DeviceGetFormatResult,
1291        fidl::encoding::DefaultFuchsiaResourceDialect,
1292    > {
1293        DeviceProxyInterface::r#get_format(self)
1294    }
1295
1296    /// Returns the current gain state for this device.
1297    pub fn r#get_gain(
1298        &self,
1299    ) -> fidl::client::QueryResponseFut<
1300        DeviceGetGainResult,
1301        fidl::encoding::DefaultFuchsiaResourceDialect,
1302    > {
1303        DeviceProxyInterface::r#get_gain(self)
1304    }
1305
1306    /// Returns details about the ring buffer. Returns `NO_RING_BUFFER` if the
1307    /// client has not yet created the ring buffer.
1308    pub fn r#get_buffer(
1309        &self,
1310    ) -> fidl::client::QueryResponseFut<
1311        DeviceGetBufferResult,
1312        fidl::encoding::DefaultFuchsiaResourceDialect,
1313    > {
1314        DeviceProxyInterface::r#get_buffer(self)
1315    }
1316
1317    /// Overrides the position notification frequency for this stream.
1318    /// This affects the frequency of `OnPositionNotify` events only. It does
1319    /// not affect the frequency of notification events sent through the audio
1320    /// driver APIs.
1321    pub fn r#set_notification_frequency(
1322        &self,
1323        mut notifications_per_ring: u32,
1324    ) -> fidl::client::QueryResponseFut<
1325        DeviceSetNotificationFrequencyResult,
1326        fidl::encoding::DefaultFuchsiaResourceDialect,
1327    > {
1328        DeviceProxyInterface::r#set_notification_frequency(self, notifications_per_ring)
1329    }
1330
1331    /// Returns the current position (in bytes) within the ring buffer, along
1332    /// with the time (per MONOTONIC clock) that corresponds with that position.
1333    /// This can only be called after the ring buffer is established. Returns
1334    /// `NOT_STARTED` if the device has not yet Started streaming.
1335    pub fn r#get_position(
1336        &self,
1337    ) -> fidl::client::QueryResponseFut<
1338        DeviceGetPositionResult,
1339        fidl::encoding::DefaultFuchsiaResourceDialect,
1340    > {
1341        DeviceProxyInterface::r#get_position(self)
1342    }
1343
1344    /// Hot-plugs or hot-unplugs an active virtual device, at the specified
1345    /// time.
1346    pub fn r#change_plug_state(
1347        &self,
1348        mut plug_change_time: i64,
1349        mut plugged: bool,
1350    ) -> fidl::client::QueryResponseFut<
1351        DeviceChangePlugStateResult,
1352        fidl::encoding::DefaultFuchsiaResourceDialect,
1353    > {
1354        DeviceProxyInterface::r#change_plug_state(self, plug_change_time, plugged)
1355    }
1356
1357    /// Immediately change the virtual device's clock rate, as expressed in the
1358    /// timing and content of position notifications the driver emits.
1359    /// 'ppm_monotonic' cannot exceed [-1000,+1000]. Each rate change in rate is
1360    /// standalone; i.e. successive rate changes are not cumulative.
1361    pub fn r#adjust_clock_rate(
1362        &self,
1363        mut ppm_from_monotonic: i32,
1364    ) -> fidl::client::QueryResponseFut<
1365        DeviceAdjustClockRateResult,
1366        fidl::encoding::DefaultFuchsiaResourceDialect,
1367    > {
1368        DeviceProxyInterface::r#adjust_clock_rate(self, ppm_from_monotonic)
1369    }
1370}
1371
1372impl DeviceProxyInterface for DeviceProxy {
1373    type GetFormatResponseFut = fidl::client::QueryResponseFut<
1374        DeviceGetFormatResult,
1375        fidl::encoding::DefaultFuchsiaResourceDialect,
1376    >;
1377    fn r#get_format(&self) -> Self::GetFormatResponseFut {
1378        fn _decode(
1379            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1380        ) -> Result<DeviceGetFormatResult, fidl::Error> {
1381            let _response = fidl::client::decode_transaction_body::<
1382                fidl::encoding::ResultType<DeviceGetFormatResponse, Error>,
1383                fidl::encoding::DefaultFuchsiaResourceDialect,
1384                0x6107d32083bacc1b,
1385            >(_buf?)?;
1386            Ok(_response
1387                .map(|x| (x.frames_per_second, x.sample_format, x.num_channels, x.external_delay)))
1388        }
1389        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetFormatResult>(
1390            (),
1391            0x6107d32083bacc1b,
1392            fidl::encoding::DynamicFlags::empty(),
1393            _decode,
1394        )
1395    }
1396
1397    type GetGainResponseFut = fidl::client::QueryResponseFut<
1398        DeviceGetGainResult,
1399        fidl::encoding::DefaultFuchsiaResourceDialect,
1400    >;
1401    fn r#get_gain(&self) -> Self::GetGainResponseFut {
1402        fn _decode(
1403            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1404        ) -> Result<DeviceGetGainResult, fidl::Error> {
1405            let _response = fidl::client::decode_transaction_body::<
1406                fidl::encoding::ResultType<DeviceGetGainResponse, Error>,
1407                fidl::encoding::DefaultFuchsiaResourceDialect,
1408                0x6d85d82b49fb28e9,
1409            >(_buf?)?;
1410            Ok(_response.map(|x| (x.current_mute, x.current_agc, x.current_gain_db)))
1411        }
1412        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetGainResult>(
1413            (),
1414            0x6d85d82b49fb28e9,
1415            fidl::encoding::DynamicFlags::empty(),
1416            _decode,
1417        )
1418    }
1419
1420    type GetBufferResponseFut = fidl::client::QueryResponseFut<
1421        DeviceGetBufferResult,
1422        fidl::encoding::DefaultFuchsiaResourceDialect,
1423    >;
1424    fn r#get_buffer(&self) -> Self::GetBufferResponseFut {
1425        fn _decode(
1426            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1427        ) -> Result<DeviceGetBufferResult, fidl::Error> {
1428            let _response = fidl::client::decode_transaction_body::<
1429                fidl::encoding::ResultType<DeviceGetBufferResponse, Error>,
1430                fidl::encoding::DefaultFuchsiaResourceDialect,
1431                0x38e202be0db060d0,
1432            >(_buf?)?;
1433            Ok(_response
1434                .map(|x| (x.ring_buffer, x.num_ring_buffer_frames, x.notifications_per_ring)))
1435        }
1436        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetBufferResult>(
1437            (),
1438            0x38e202be0db060d0,
1439            fidl::encoding::DynamicFlags::empty(),
1440            _decode,
1441        )
1442    }
1443
1444    type SetNotificationFrequencyResponseFut = fidl::client::QueryResponseFut<
1445        DeviceSetNotificationFrequencyResult,
1446        fidl::encoding::DefaultFuchsiaResourceDialect,
1447    >;
1448    fn r#set_notification_frequency(
1449        &self,
1450        mut notifications_per_ring: u32,
1451    ) -> Self::SetNotificationFrequencyResponseFut {
1452        fn _decode(
1453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1454        ) -> Result<DeviceSetNotificationFrequencyResult, fidl::Error> {
1455            let _response = fidl::client::decode_transaction_body::<
1456                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1457                fidl::encoding::DefaultFuchsiaResourceDialect,
1458                0x45789b88ca9185b8,
1459            >(_buf?)?;
1460            Ok(_response.map(|x| x))
1461        }
1462        self.client.send_query_and_decode::<
1463            DeviceSetNotificationFrequencyRequest,
1464            DeviceSetNotificationFrequencyResult,
1465        >(
1466            (notifications_per_ring,),
1467            0x45789b88ca9185b8,
1468            fidl::encoding::DynamicFlags::empty(),
1469            _decode,
1470        )
1471    }
1472
1473    type GetPositionResponseFut = fidl::client::QueryResponseFut<
1474        DeviceGetPositionResult,
1475        fidl::encoding::DefaultFuchsiaResourceDialect,
1476    >;
1477    fn r#get_position(&self) -> Self::GetPositionResponseFut {
1478        fn _decode(
1479            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1480        ) -> Result<DeviceGetPositionResult, fidl::Error> {
1481            let _response = fidl::client::decode_transaction_body::<
1482                fidl::encoding::ResultType<DeviceGetPositionResponse, Error>,
1483                fidl::encoding::DefaultFuchsiaResourceDialect,
1484                0x6fe5bbf9065258e8,
1485            >(_buf?)?;
1486            Ok(_response.map(|x| (x.monotonic_time, x.ring_position)))
1487        }
1488        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetPositionResult>(
1489            (),
1490            0x6fe5bbf9065258e8,
1491            fidl::encoding::DynamicFlags::empty(),
1492            _decode,
1493        )
1494    }
1495
1496    type ChangePlugStateResponseFut = fidl::client::QueryResponseFut<
1497        DeviceChangePlugStateResult,
1498        fidl::encoding::DefaultFuchsiaResourceDialect,
1499    >;
1500    fn r#change_plug_state(
1501        &self,
1502        mut plug_change_time: i64,
1503        mut plugged: bool,
1504    ) -> Self::ChangePlugStateResponseFut {
1505        fn _decode(
1506            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1507        ) -> Result<DeviceChangePlugStateResult, fidl::Error> {
1508            let _response = fidl::client::decode_transaction_body::<
1509                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1510                fidl::encoding::DefaultFuchsiaResourceDialect,
1511                0x61aa2d370caaf8f0,
1512            >(_buf?)?;
1513            Ok(_response.map(|x| x))
1514        }
1515        self.client
1516            .send_query_and_decode::<DeviceChangePlugStateRequest, DeviceChangePlugStateResult>(
1517                (plug_change_time, plugged),
1518                0x61aa2d370caaf8f0,
1519                fidl::encoding::DynamicFlags::empty(),
1520                _decode,
1521            )
1522    }
1523
1524    type AdjustClockRateResponseFut = fidl::client::QueryResponseFut<
1525        DeviceAdjustClockRateResult,
1526        fidl::encoding::DefaultFuchsiaResourceDialect,
1527    >;
1528    fn r#adjust_clock_rate(&self, mut ppm_from_monotonic: i32) -> Self::AdjustClockRateResponseFut {
1529        fn _decode(
1530            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1531        ) -> Result<DeviceAdjustClockRateResult, fidl::Error> {
1532            let _response = fidl::client::decode_transaction_body::<
1533                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535                0x754661f655350134,
1536            >(_buf?)?;
1537            Ok(_response.map(|x| x))
1538        }
1539        self.client
1540            .send_query_and_decode::<DeviceAdjustClockRateRequest, DeviceAdjustClockRateResult>(
1541                (ppm_from_monotonic,),
1542                0x754661f655350134,
1543                fidl::encoding::DynamicFlags::empty(),
1544                _decode,
1545            )
1546    }
1547}
1548
1549pub struct DeviceEventStream {
1550    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1551}
1552
1553impl std::marker::Unpin for DeviceEventStream {}
1554
1555impl futures::stream::FusedStream for DeviceEventStream {
1556    fn is_terminated(&self) -> bool {
1557        self.event_receiver.is_terminated()
1558    }
1559}
1560
1561impl futures::Stream for DeviceEventStream {
1562    type Item = Result<DeviceEvent, fidl::Error>;
1563
1564    fn poll_next(
1565        mut self: std::pin::Pin<&mut Self>,
1566        cx: &mut std::task::Context<'_>,
1567    ) -> std::task::Poll<Option<Self::Item>> {
1568        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1569            &mut self.event_receiver,
1570            cx
1571        )?) {
1572            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1573            None => std::task::Poll::Ready(None),
1574        }
1575    }
1576}
1577
1578#[derive(Debug)]
1579pub enum DeviceEvent {
1580    OnSetFormat {
1581        frames_per_second: u32,
1582        sample_format: u32,
1583        num_channels: u32,
1584        external_delay: i64,
1585    },
1586    OnSetGain {
1587        current_mute: bool,
1588        current_agc: bool,
1589        current_gain_db: f32,
1590    },
1591    OnBufferCreated {
1592        ring_buffer: fidl::Vmo,
1593        num_ring_buffer_frames: u32,
1594        notifications_per_ring: u32,
1595    },
1596    OnStart {
1597        start_time: i64,
1598    },
1599    OnStop {
1600        stop_time: i64,
1601        ring_position: u32,
1602    },
1603    OnPositionNotify {
1604        monotonic_time: i64,
1605        ring_position: u32,
1606    },
1607}
1608
1609impl DeviceEvent {
1610    #[allow(irrefutable_let_patterns)]
1611    pub fn into_on_set_format(self) -> Option<(u32, u32, u32, i64)> {
1612        if let DeviceEvent::OnSetFormat {
1613            frames_per_second,
1614            sample_format,
1615            num_channels,
1616            external_delay,
1617        } = self
1618        {
1619            Some((frames_per_second, sample_format, num_channels, external_delay))
1620        } else {
1621            None
1622        }
1623    }
1624    #[allow(irrefutable_let_patterns)]
1625    pub fn into_on_set_gain(self) -> Option<(bool, bool, f32)> {
1626        if let DeviceEvent::OnSetGain { current_mute, current_agc, current_gain_db } = self {
1627            Some((current_mute, current_agc, current_gain_db))
1628        } else {
1629            None
1630        }
1631    }
1632    #[allow(irrefutable_let_patterns)]
1633    pub fn into_on_buffer_created(self) -> Option<(fidl::Vmo, u32, u32)> {
1634        if let DeviceEvent::OnBufferCreated {
1635            ring_buffer,
1636            num_ring_buffer_frames,
1637            notifications_per_ring,
1638        } = self
1639        {
1640            Some((ring_buffer, num_ring_buffer_frames, notifications_per_ring))
1641        } else {
1642            None
1643        }
1644    }
1645    #[allow(irrefutable_let_patterns)]
1646    pub fn into_on_start(self) -> Option<i64> {
1647        if let DeviceEvent::OnStart { start_time } = self {
1648            Some((start_time))
1649        } else {
1650            None
1651        }
1652    }
1653    #[allow(irrefutable_let_patterns)]
1654    pub fn into_on_stop(self) -> Option<(i64, u32)> {
1655        if let DeviceEvent::OnStop { stop_time, ring_position } = self {
1656            Some((stop_time, ring_position))
1657        } else {
1658            None
1659        }
1660    }
1661    #[allow(irrefutable_let_patterns)]
1662    pub fn into_on_position_notify(self) -> Option<(i64, u32)> {
1663        if let DeviceEvent::OnPositionNotify { monotonic_time, ring_position } = self {
1664            Some((monotonic_time, ring_position))
1665        } else {
1666            None
1667        }
1668    }
1669
1670    /// Decodes a message buffer as a [`DeviceEvent`].
1671    fn decode(
1672        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1673    ) -> Result<DeviceEvent, fidl::Error> {
1674        let (bytes, _handles) = buf.split_mut();
1675        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1676        debug_assert_eq!(tx_header.tx_id, 0);
1677        match tx_header.ordinal {
1678            0x2a547759ab3678b2 => {
1679                let mut out = fidl::new_empty!(
1680                    DeviceOnSetFormatRequest,
1681                    fidl::encoding::DefaultFuchsiaResourceDialect
1682                );
1683                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnSetFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1684                Ok((DeviceEvent::OnSetFormat {
1685                    frames_per_second: out.frames_per_second,
1686                    sample_format: out.sample_format,
1687                    num_channels: out.num_channels,
1688                    external_delay: out.external_delay,
1689                }))
1690            }
1691            0x31fffec81b3a9393 => {
1692                let mut out = fidl::new_empty!(
1693                    DeviceOnSetGainRequest,
1694                    fidl::encoding::DefaultFuchsiaResourceDialect
1695                );
1696                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnSetGainRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1697                Ok((DeviceEvent::OnSetGain {
1698                    current_mute: out.current_mute,
1699                    current_agc: out.current_agc,
1700                    current_gain_db: out.current_gain_db,
1701                }))
1702            }
1703            0x5c2eb72e264afefd => {
1704                let mut out = fidl::new_empty!(
1705                    DeviceOnBufferCreatedRequest,
1706                    fidl::encoding::DefaultFuchsiaResourceDialect
1707                );
1708                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnBufferCreatedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1709                Ok((DeviceEvent::OnBufferCreated {
1710                    ring_buffer: out.ring_buffer,
1711                    num_ring_buffer_frames: out.num_ring_buffer_frames,
1712                    notifications_per_ring: out.notifications_per_ring,
1713                }))
1714            }
1715            0x498f0b7e64d7ca58 => {
1716                let mut out = fidl::new_empty!(
1717                    DeviceOnStartRequest,
1718                    fidl::encoding::DefaultFuchsiaResourceDialect
1719                );
1720                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnStartRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1721                Ok((DeviceEvent::OnStart { start_time: out.start_time }))
1722            }
1723            0x6f5d4d2fe223ae5b => {
1724                let mut out = fidl::new_empty!(
1725                    DeviceOnStopRequest,
1726                    fidl::encoding::DefaultFuchsiaResourceDialect
1727                );
1728                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnStopRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1729                Ok((DeviceEvent::OnStop {
1730                    stop_time: out.stop_time,
1731                    ring_position: out.ring_position,
1732                }))
1733            }
1734            0x79274c4de9013585 => {
1735                let mut out = fidl::new_empty!(
1736                    DeviceOnPositionNotifyRequest,
1737                    fidl::encoding::DefaultFuchsiaResourceDialect
1738                );
1739                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnPositionNotifyRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1740                Ok((DeviceEvent::OnPositionNotify {
1741                    monotonic_time: out.monotonic_time,
1742                    ring_position: out.ring_position,
1743                }))
1744            }
1745            _ => Err(fidl::Error::UnknownOrdinal {
1746                ordinal: tx_header.ordinal,
1747                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1748            }),
1749        }
1750    }
1751}
1752
1753/// A Stream of incoming requests for fuchsia.virtualaudio/Device.
1754pub struct DeviceRequestStream {
1755    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1756    is_terminated: bool,
1757}
1758
1759impl std::marker::Unpin for DeviceRequestStream {}
1760
1761impl futures::stream::FusedStream for DeviceRequestStream {
1762    fn is_terminated(&self) -> bool {
1763        self.is_terminated
1764    }
1765}
1766
1767impl fidl::endpoints::RequestStream for DeviceRequestStream {
1768    type Protocol = DeviceMarker;
1769    type ControlHandle = DeviceControlHandle;
1770
1771    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1772        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1773    }
1774
1775    fn control_handle(&self) -> Self::ControlHandle {
1776        DeviceControlHandle { inner: self.inner.clone() }
1777    }
1778
1779    fn into_inner(
1780        self,
1781    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1782    {
1783        (self.inner, self.is_terminated)
1784    }
1785
1786    fn from_inner(
1787        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1788        is_terminated: bool,
1789    ) -> Self {
1790        Self { inner, is_terminated }
1791    }
1792}
1793
1794impl futures::Stream for DeviceRequestStream {
1795    type Item = Result<DeviceRequest, fidl::Error>;
1796
1797    fn poll_next(
1798        mut self: std::pin::Pin<&mut Self>,
1799        cx: &mut std::task::Context<'_>,
1800    ) -> std::task::Poll<Option<Self::Item>> {
1801        let this = &mut *self;
1802        if this.inner.check_shutdown(cx) {
1803            this.is_terminated = true;
1804            return std::task::Poll::Ready(None);
1805        }
1806        if this.is_terminated {
1807            panic!("polled DeviceRequestStream after completion");
1808        }
1809        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1810            |bytes, handles| {
1811                match this.inner.channel().read_etc(cx, bytes, handles) {
1812                    std::task::Poll::Ready(Ok(())) => {}
1813                    std::task::Poll::Pending => return std::task::Poll::Pending,
1814                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1815                        this.is_terminated = true;
1816                        return std::task::Poll::Ready(None);
1817                    }
1818                    std::task::Poll::Ready(Err(e)) => {
1819                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1820                            e.into(),
1821                        ))))
1822                    }
1823                }
1824
1825                // A message has been received from the channel
1826                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1827
1828                std::task::Poll::Ready(Some(match header.ordinal {
1829                    0x6107d32083bacc1b => {
1830                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1831                        let mut req = fidl::new_empty!(
1832                            fidl::encoding::EmptyPayload,
1833                            fidl::encoding::DefaultFuchsiaResourceDialect
1834                        );
1835                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1836                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1837                        Ok(DeviceRequest::GetFormat {
1838                            responder: DeviceGetFormatResponder {
1839                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1840                                tx_id: header.tx_id,
1841                            },
1842                        })
1843                    }
1844                    0x6d85d82b49fb28e9 => {
1845                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1846                        let mut req = fidl::new_empty!(
1847                            fidl::encoding::EmptyPayload,
1848                            fidl::encoding::DefaultFuchsiaResourceDialect
1849                        );
1850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1851                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1852                        Ok(DeviceRequest::GetGain {
1853                            responder: DeviceGetGainResponder {
1854                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1855                                tx_id: header.tx_id,
1856                            },
1857                        })
1858                    }
1859                    0x38e202be0db060d0 => {
1860                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1861                        let mut req = fidl::new_empty!(
1862                            fidl::encoding::EmptyPayload,
1863                            fidl::encoding::DefaultFuchsiaResourceDialect
1864                        );
1865                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1866                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1867                        Ok(DeviceRequest::GetBuffer {
1868                            responder: DeviceGetBufferResponder {
1869                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1870                                tx_id: header.tx_id,
1871                            },
1872                        })
1873                    }
1874                    0x45789b88ca9185b8 => {
1875                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1876                        let mut req = fidl::new_empty!(
1877                            DeviceSetNotificationFrequencyRequest,
1878                            fidl::encoding::DefaultFuchsiaResourceDialect
1879                        );
1880                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetNotificationFrequencyRequest>(&header, _body_bytes, handles, &mut req)?;
1881                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1882                        Ok(DeviceRequest::SetNotificationFrequency {
1883                            notifications_per_ring: req.notifications_per_ring,
1884
1885                            responder: DeviceSetNotificationFrequencyResponder {
1886                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1887                                tx_id: header.tx_id,
1888                            },
1889                        })
1890                    }
1891                    0x6fe5bbf9065258e8 => {
1892                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1893                        let mut req = fidl::new_empty!(
1894                            fidl::encoding::EmptyPayload,
1895                            fidl::encoding::DefaultFuchsiaResourceDialect
1896                        );
1897                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1898                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1899                        Ok(DeviceRequest::GetPosition {
1900                            responder: DeviceGetPositionResponder {
1901                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1902                                tx_id: header.tx_id,
1903                            },
1904                        })
1905                    }
1906                    0x61aa2d370caaf8f0 => {
1907                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1908                        let mut req = fidl::new_empty!(
1909                            DeviceChangePlugStateRequest,
1910                            fidl::encoding::DefaultFuchsiaResourceDialect
1911                        );
1912                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceChangePlugStateRequest>(&header, _body_bytes, handles, &mut req)?;
1913                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1914                        Ok(DeviceRequest::ChangePlugState {
1915                            plug_change_time: req.plug_change_time,
1916                            plugged: req.plugged,
1917
1918                            responder: DeviceChangePlugStateResponder {
1919                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1920                                tx_id: header.tx_id,
1921                            },
1922                        })
1923                    }
1924                    0x754661f655350134 => {
1925                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1926                        let mut req = fidl::new_empty!(
1927                            DeviceAdjustClockRateRequest,
1928                            fidl::encoding::DefaultFuchsiaResourceDialect
1929                        );
1930                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceAdjustClockRateRequest>(&header, _body_bytes, handles, &mut req)?;
1931                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1932                        Ok(DeviceRequest::AdjustClockRate {
1933                            ppm_from_monotonic: req.ppm_from_monotonic,
1934
1935                            responder: DeviceAdjustClockRateResponder {
1936                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1937                                tx_id: header.tx_id,
1938                            },
1939                        })
1940                    }
1941                    _ => Err(fidl::Error::UnknownOrdinal {
1942                        ordinal: header.ordinal,
1943                        protocol_name:
1944                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1945                    }),
1946                }))
1947            },
1948        )
1949    }
1950}
1951
1952/// This protocol represents the base functionality of active audio devices. A
1953/// device is active until this protocol is closed, at which point the device is
1954/// automatically removed.
1955#[derive(Debug)]
1956pub enum DeviceRequest {
1957    /// Returns the format selected by the client, or `NO_RING_BUFFER` if the
1958    /// client has not yet selected a ring buffer format.
1959    GetFormat { responder: DeviceGetFormatResponder },
1960    /// Returns the current gain state for this device.
1961    GetGain { responder: DeviceGetGainResponder },
1962    /// Returns details about the ring buffer. Returns `NO_RING_BUFFER` if the
1963    /// client has not yet created the ring buffer.
1964    GetBuffer { responder: DeviceGetBufferResponder },
1965    /// Overrides the position notification frequency for this stream.
1966    /// This affects the frequency of `OnPositionNotify` events only. It does
1967    /// not affect the frequency of notification events sent through the audio
1968    /// driver APIs.
1969    SetNotificationFrequency {
1970        notifications_per_ring: u32,
1971        responder: DeviceSetNotificationFrequencyResponder,
1972    },
1973    /// Returns the current position (in bytes) within the ring buffer, along
1974    /// with the time (per MONOTONIC clock) that corresponds with that position.
1975    /// This can only be called after the ring buffer is established. Returns
1976    /// `NOT_STARTED` if the device has not yet Started streaming.
1977    GetPosition { responder: DeviceGetPositionResponder },
1978    /// Hot-plugs or hot-unplugs an active virtual device, at the specified
1979    /// time.
1980    ChangePlugState {
1981        plug_change_time: i64,
1982        plugged: bool,
1983        responder: DeviceChangePlugStateResponder,
1984    },
1985    /// Immediately change the virtual device's clock rate, as expressed in the
1986    /// timing and content of position notifications the driver emits.
1987    /// 'ppm_monotonic' cannot exceed [-1000,+1000]. Each rate change in rate is
1988    /// standalone; i.e. successive rate changes are not cumulative.
1989    AdjustClockRate { ppm_from_monotonic: i32, responder: DeviceAdjustClockRateResponder },
1990}
1991
1992impl DeviceRequest {
1993    #[allow(irrefutable_let_patterns)]
1994    pub fn into_get_format(self) -> Option<(DeviceGetFormatResponder)> {
1995        if let DeviceRequest::GetFormat { responder } = self {
1996            Some((responder))
1997        } else {
1998            None
1999        }
2000    }
2001
2002    #[allow(irrefutable_let_patterns)]
2003    pub fn into_get_gain(self) -> Option<(DeviceGetGainResponder)> {
2004        if let DeviceRequest::GetGain { responder } = self {
2005            Some((responder))
2006        } else {
2007            None
2008        }
2009    }
2010
2011    #[allow(irrefutable_let_patterns)]
2012    pub fn into_get_buffer(self) -> Option<(DeviceGetBufferResponder)> {
2013        if let DeviceRequest::GetBuffer { responder } = self {
2014            Some((responder))
2015        } else {
2016            None
2017        }
2018    }
2019
2020    #[allow(irrefutable_let_patterns)]
2021    pub fn into_set_notification_frequency(
2022        self,
2023    ) -> Option<(u32, DeviceSetNotificationFrequencyResponder)> {
2024        if let DeviceRequest::SetNotificationFrequency { notifications_per_ring, responder } = self
2025        {
2026            Some((notifications_per_ring, responder))
2027        } else {
2028            None
2029        }
2030    }
2031
2032    #[allow(irrefutable_let_patterns)]
2033    pub fn into_get_position(self) -> Option<(DeviceGetPositionResponder)> {
2034        if let DeviceRequest::GetPosition { responder } = self {
2035            Some((responder))
2036        } else {
2037            None
2038        }
2039    }
2040
2041    #[allow(irrefutable_let_patterns)]
2042    pub fn into_change_plug_state(self) -> Option<(i64, bool, DeviceChangePlugStateResponder)> {
2043        if let DeviceRequest::ChangePlugState { plug_change_time, plugged, responder } = self {
2044            Some((plug_change_time, plugged, responder))
2045        } else {
2046            None
2047        }
2048    }
2049
2050    #[allow(irrefutable_let_patterns)]
2051    pub fn into_adjust_clock_rate(self) -> Option<(i32, DeviceAdjustClockRateResponder)> {
2052        if let DeviceRequest::AdjustClockRate { ppm_from_monotonic, responder } = self {
2053            Some((ppm_from_monotonic, responder))
2054        } else {
2055            None
2056        }
2057    }
2058
2059    /// Name of the method defined in FIDL
2060    pub fn method_name(&self) -> &'static str {
2061        match *self {
2062            DeviceRequest::GetFormat { .. } => "get_format",
2063            DeviceRequest::GetGain { .. } => "get_gain",
2064            DeviceRequest::GetBuffer { .. } => "get_buffer",
2065            DeviceRequest::SetNotificationFrequency { .. } => "set_notification_frequency",
2066            DeviceRequest::GetPosition { .. } => "get_position",
2067            DeviceRequest::ChangePlugState { .. } => "change_plug_state",
2068            DeviceRequest::AdjustClockRate { .. } => "adjust_clock_rate",
2069        }
2070    }
2071}
2072
2073#[derive(Debug, Clone)]
2074pub struct DeviceControlHandle {
2075    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2076}
2077
2078impl fidl::endpoints::ControlHandle for DeviceControlHandle {
2079    fn shutdown(&self) {
2080        self.inner.shutdown()
2081    }
2082    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2083        self.inner.shutdown_with_epitaph(status)
2084    }
2085
2086    fn is_closed(&self) -> bool {
2087        self.inner.channel().is_closed()
2088    }
2089    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2090        self.inner.channel().on_closed()
2091    }
2092
2093    #[cfg(target_os = "fuchsia")]
2094    fn signal_peer(
2095        &self,
2096        clear_mask: zx::Signals,
2097        set_mask: zx::Signals,
2098    ) -> Result<(), zx_status::Status> {
2099        use fidl::Peered;
2100        self.inner.channel().signal_peer(clear_mask, set_mask)
2101    }
2102}
2103
2104impl DeviceControlHandle {
2105    pub fn send_on_set_format(
2106        &self,
2107        mut frames_per_second: u32,
2108        mut sample_format: u32,
2109        mut num_channels: u32,
2110        mut external_delay: i64,
2111    ) -> Result<(), fidl::Error> {
2112        self.inner.send::<DeviceOnSetFormatRequest>(
2113            (frames_per_second, sample_format, num_channels, external_delay),
2114            0,
2115            0x2a547759ab3678b2,
2116            fidl::encoding::DynamicFlags::empty(),
2117        )
2118    }
2119
2120    pub fn send_on_set_gain(
2121        &self,
2122        mut current_mute: bool,
2123        mut current_agc: bool,
2124        mut current_gain_db: f32,
2125    ) -> Result<(), fidl::Error> {
2126        self.inner.send::<DeviceOnSetGainRequest>(
2127            (current_mute, current_agc, current_gain_db),
2128            0,
2129            0x31fffec81b3a9393,
2130            fidl::encoding::DynamicFlags::empty(),
2131        )
2132    }
2133
2134    pub fn send_on_buffer_created(
2135        &self,
2136        mut ring_buffer: fidl::Vmo,
2137        mut num_ring_buffer_frames: u32,
2138        mut notifications_per_ring: u32,
2139    ) -> Result<(), fidl::Error> {
2140        self.inner.send::<DeviceOnBufferCreatedRequest>(
2141            (ring_buffer, num_ring_buffer_frames, notifications_per_ring),
2142            0,
2143            0x5c2eb72e264afefd,
2144            fidl::encoding::DynamicFlags::empty(),
2145        )
2146    }
2147
2148    pub fn send_on_start(&self, mut start_time: i64) -> Result<(), fidl::Error> {
2149        self.inner.send::<DeviceOnStartRequest>(
2150            (start_time,),
2151            0,
2152            0x498f0b7e64d7ca58,
2153            fidl::encoding::DynamicFlags::empty(),
2154        )
2155    }
2156
2157    pub fn send_on_stop(
2158        &self,
2159        mut stop_time: i64,
2160        mut ring_position: u32,
2161    ) -> Result<(), fidl::Error> {
2162        self.inner.send::<DeviceOnStopRequest>(
2163            (stop_time, ring_position),
2164            0,
2165            0x6f5d4d2fe223ae5b,
2166            fidl::encoding::DynamicFlags::empty(),
2167        )
2168    }
2169
2170    pub fn send_on_position_notify(
2171        &self,
2172        mut monotonic_time: i64,
2173        mut ring_position: u32,
2174    ) -> Result<(), fidl::Error> {
2175        self.inner.send::<DeviceOnPositionNotifyRequest>(
2176            (monotonic_time, ring_position),
2177            0,
2178            0x79274c4de9013585,
2179            fidl::encoding::DynamicFlags::empty(),
2180        )
2181    }
2182}
2183
2184#[must_use = "FIDL methods require a response to be sent"]
2185#[derive(Debug)]
2186pub struct DeviceGetFormatResponder {
2187    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2188    tx_id: u32,
2189}
2190
2191/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2192/// if the responder is dropped without sending a response, so that the client
2193/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2194impl std::ops::Drop for DeviceGetFormatResponder {
2195    fn drop(&mut self) {
2196        self.control_handle.shutdown();
2197        // Safety: drops once, never accessed again
2198        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2199    }
2200}
2201
2202impl fidl::endpoints::Responder for DeviceGetFormatResponder {
2203    type ControlHandle = DeviceControlHandle;
2204
2205    fn control_handle(&self) -> &DeviceControlHandle {
2206        &self.control_handle
2207    }
2208
2209    fn drop_without_shutdown(mut self) {
2210        // Safety: drops once, never accessed again due to mem::forget
2211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2212        // Prevent Drop from running (which would shut down the channel)
2213        std::mem::forget(self);
2214    }
2215}
2216
2217impl DeviceGetFormatResponder {
2218    /// Sends a response to the FIDL transaction.
2219    ///
2220    /// Sets the channel to shutdown if an error occurs.
2221    pub fn send(self, mut result: Result<(u32, u32, u32, i64), Error>) -> Result<(), fidl::Error> {
2222        let _result = self.send_raw(result);
2223        if _result.is_err() {
2224            self.control_handle.shutdown();
2225        }
2226        self.drop_without_shutdown();
2227        _result
2228    }
2229
2230    /// Similar to "send" but does not shutdown the channel if an error occurs.
2231    pub fn send_no_shutdown_on_err(
2232        self,
2233        mut result: Result<(u32, u32, u32, i64), Error>,
2234    ) -> Result<(), fidl::Error> {
2235        let _result = self.send_raw(result);
2236        self.drop_without_shutdown();
2237        _result
2238    }
2239
2240    fn send_raw(&self, mut result: Result<(u32, u32, u32, i64), Error>) -> Result<(), fidl::Error> {
2241        self.control_handle
2242            .inner
2243            .send::<fidl::encoding::ResultType<DeviceGetFormatResponse, Error>>(
2244                result,
2245                self.tx_id,
2246                0x6107d32083bacc1b,
2247                fidl::encoding::DynamicFlags::empty(),
2248            )
2249    }
2250}
2251
2252#[must_use = "FIDL methods require a response to be sent"]
2253#[derive(Debug)]
2254pub struct DeviceGetGainResponder {
2255    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2256    tx_id: u32,
2257}
2258
2259/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2260/// if the responder is dropped without sending a response, so that the client
2261/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2262impl std::ops::Drop for DeviceGetGainResponder {
2263    fn drop(&mut self) {
2264        self.control_handle.shutdown();
2265        // Safety: drops once, never accessed again
2266        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2267    }
2268}
2269
2270impl fidl::endpoints::Responder for DeviceGetGainResponder {
2271    type ControlHandle = DeviceControlHandle;
2272
2273    fn control_handle(&self) -> &DeviceControlHandle {
2274        &self.control_handle
2275    }
2276
2277    fn drop_without_shutdown(mut self) {
2278        // Safety: drops once, never accessed again due to mem::forget
2279        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2280        // Prevent Drop from running (which would shut down the channel)
2281        std::mem::forget(self);
2282    }
2283}
2284
2285impl DeviceGetGainResponder {
2286    /// Sends a response to the FIDL transaction.
2287    ///
2288    /// Sets the channel to shutdown if an error occurs.
2289    pub fn send(self, mut result: Result<(bool, bool, f32), Error>) -> Result<(), fidl::Error> {
2290        let _result = self.send_raw(result);
2291        if _result.is_err() {
2292            self.control_handle.shutdown();
2293        }
2294        self.drop_without_shutdown();
2295        _result
2296    }
2297
2298    /// Similar to "send" but does not shutdown the channel if an error occurs.
2299    pub fn send_no_shutdown_on_err(
2300        self,
2301        mut result: Result<(bool, bool, f32), Error>,
2302    ) -> Result<(), fidl::Error> {
2303        let _result = self.send_raw(result);
2304        self.drop_without_shutdown();
2305        _result
2306    }
2307
2308    fn send_raw(&self, mut result: Result<(bool, bool, f32), Error>) -> Result<(), fidl::Error> {
2309        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetGainResponse, Error>>(
2310            result,
2311            self.tx_id,
2312            0x6d85d82b49fb28e9,
2313            fidl::encoding::DynamicFlags::empty(),
2314        )
2315    }
2316}
2317
2318#[must_use = "FIDL methods require a response to be sent"]
2319#[derive(Debug)]
2320pub struct DeviceGetBufferResponder {
2321    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2322    tx_id: u32,
2323}
2324
2325/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2326/// if the responder is dropped without sending a response, so that the client
2327/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2328impl std::ops::Drop for DeviceGetBufferResponder {
2329    fn drop(&mut self) {
2330        self.control_handle.shutdown();
2331        // Safety: drops once, never accessed again
2332        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2333    }
2334}
2335
2336impl fidl::endpoints::Responder for DeviceGetBufferResponder {
2337    type ControlHandle = DeviceControlHandle;
2338
2339    fn control_handle(&self) -> &DeviceControlHandle {
2340        &self.control_handle
2341    }
2342
2343    fn drop_without_shutdown(mut self) {
2344        // Safety: drops once, never accessed again due to mem::forget
2345        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2346        // Prevent Drop from running (which would shut down the channel)
2347        std::mem::forget(self);
2348    }
2349}
2350
2351impl DeviceGetBufferResponder {
2352    /// Sends a response to the FIDL transaction.
2353    ///
2354    /// Sets the channel to shutdown if an error occurs.
2355    pub fn send(self, mut result: Result<(fidl::Vmo, u32, u32), Error>) -> Result<(), fidl::Error> {
2356        let _result = self.send_raw(result);
2357        if _result.is_err() {
2358            self.control_handle.shutdown();
2359        }
2360        self.drop_without_shutdown();
2361        _result
2362    }
2363
2364    /// Similar to "send" but does not shutdown the channel if an error occurs.
2365    pub fn send_no_shutdown_on_err(
2366        self,
2367        mut result: Result<(fidl::Vmo, u32, u32), Error>,
2368    ) -> Result<(), fidl::Error> {
2369        let _result = self.send_raw(result);
2370        self.drop_without_shutdown();
2371        _result
2372    }
2373
2374    fn send_raw(
2375        &self,
2376        mut result: Result<(fidl::Vmo, u32, u32), Error>,
2377    ) -> Result<(), fidl::Error> {
2378        self.control_handle
2379            .inner
2380            .send::<fidl::encoding::ResultType<DeviceGetBufferResponse, Error>>(
2381                result,
2382                self.tx_id,
2383                0x38e202be0db060d0,
2384                fidl::encoding::DynamicFlags::empty(),
2385            )
2386    }
2387}
2388
2389#[must_use = "FIDL methods require a response to be sent"]
2390#[derive(Debug)]
2391pub struct DeviceSetNotificationFrequencyResponder {
2392    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2393    tx_id: u32,
2394}
2395
2396/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2397/// if the responder is dropped without sending a response, so that the client
2398/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2399impl std::ops::Drop for DeviceSetNotificationFrequencyResponder {
2400    fn drop(&mut self) {
2401        self.control_handle.shutdown();
2402        // Safety: drops once, never accessed again
2403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2404    }
2405}
2406
2407impl fidl::endpoints::Responder for DeviceSetNotificationFrequencyResponder {
2408    type ControlHandle = DeviceControlHandle;
2409
2410    fn control_handle(&self) -> &DeviceControlHandle {
2411        &self.control_handle
2412    }
2413
2414    fn drop_without_shutdown(mut self) {
2415        // Safety: drops once, never accessed again due to mem::forget
2416        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2417        // Prevent Drop from running (which would shut down the channel)
2418        std::mem::forget(self);
2419    }
2420}
2421
2422impl DeviceSetNotificationFrequencyResponder {
2423    /// Sends a response to the FIDL transaction.
2424    ///
2425    /// Sets the channel to shutdown if an error occurs.
2426    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2427        let _result = self.send_raw(result);
2428        if _result.is_err() {
2429            self.control_handle.shutdown();
2430        }
2431        self.drop_without_shutdown();
2432        _result
2433    }
2434
2435    /// Similar to "send" but does not shutdown the channel if an error occurs.
2436    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2437        let _result = self.send_raw(result);
2438        self.drop_without_shutdown();
2439        _result
2440    }
2441
2442    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2443        self.control_handle
2444            .inner
2445            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2446                result,
2447                self.tx_id,
2448                0x45789b88ca9185b8,
2449                fidl::encoding::DynamicFlags::empty(),
2450            )
2451    }
2452}
2453
2454#[must_use = "FIDL methods require a response to be sent"]
2455#[derive(Debug)]
2456pub struct DeviceGetPositionResponder {
2457    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2458    tx_id: u32,
2459}
2460
2461/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2462/// if the responder is dropped without sending a response, so that the client
2463/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2464impl std::ops::Drop for DeviceGetPositionResponder {
2465    fn drop(&mut self) {
2466        self.control_handle.shutdown();
2467        // Safety: drops once, never accessed again
2468        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2469    }
2470}
2471
2472impl fidl::endpoints::Responder for DeviceGetPositionResponder {
2473    type ControlHandle = DeviceControlHandle;
2474
2475    fn control_handle(&self) -> &DeviceControlHandle {
2476        &self.control_handle
2477    }
2478
2479    fn drop_without_shutdown(mut self) {
2480        // Safety: drops once, never accessed again due to mem::forget
2481        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2482        // Prevent Drop from running (which would shut down the channel)
2483        std::mem::forget(self);
2484    }
2485}
2486
2487impl DeviceGetPositionResponder {
2488    /// Sends a response to the FIDL transaction.
2489    ///
2490    /// Sets the channel to shutdown if an error occurs.
2491    pub fn send(self, mut result: Result<(i64, u32), Error>) -> Result<(), fidl::Error> {
2492        let _result = self.send_raw(result);
2493        if _result.is_err() {
2494            self.control_handle.shutdown();
2495        }
2496        self.drop_without_shutdown();
2497        _result
2498    }
2499
2500    /// Similar to "send" but does not shutdown the channel if an error occurs.
2501    pub fn send_no_shutdown_on_err(
2502        self,
2503        mut result: Result<(i64, u32), Error>,
2504    ) -> Result<(), fidl::Error> {
2505        let _result = self.send_raw(result);
2506        self.drop_without_shutdown();
2507        _result
2508    }
2509
2510    fn send_raw(&self, mut result: Result<(i64, u32), Error>) -> Result<(), fidl::Error> {
2511        self.control_handle
2512            .inner
2513            .send::<fidl::encoding::ResultType<DeviceGetPositionResponse, Error>>(
2514                result,
2515                self.tx_id,
2516                0x6fe5bbf9065258e8,
2517                fidl::encoding::DynamicFlags::empty(),
2518            )
2519    }
2520}
2521
2522#[must_use = "FIDL methods require a response to be sent"]
2523#[derive(Debug)]
2524pub struct DeviceChangePlugStateResponder {
2525    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2526    tx_id: u32,
2527}
2528
2529/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2530/// if the responder is dropped without sending a response, so that the client
2531/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2532impl std::ops::Drop for DeviceChangePlugStateResponder {
2533    fn drop(&mut self) {
2534        self.control_handle.shutdown();
2535        // Safety: drops once, never accessed again
2536        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2537    }
2538}
2539
2540impl fidl::endpoints::Responder for DeviceChangePlugStateResponder {
2541    type ControlHandle = DeviceControlHandle;
2542
2543    fn control_handle(&self) -> &DeviceControlHandle {
2544        &self.control_handle
2545    }
2546
2547    fn drop_without_shutdown(mut self) {
2548        // Safety: drops once, never accessed again due to mem::forget
2549        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2550        // Prevent Drop from running (which would shut down the channel)
2551        std::mem::forget(self);
2552    }
2553}
2554
2555impl DeviceChangePlugStateResponder {
2556    /// Sends a response to the FIDL transaction.
2557    ///
2558    /// Sets the channel to shutdown if an error occurs.
2559    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2560        let _result = self.send_raw(result);
2561        if _result.is_err() {
2562            self.control_handle.shutdown();
2563        }
2564        self.drop_without_shutdown();
2565        _result
2566    }
2567
2568    /// Similar to "send" but does not shutdown the channel if an error occurs.
2569    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2570        let _result = self.send_raw(result);
2571        self.drop_without_shutdown();
2572        _result
2573    }
2574
2575    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2576        self.control_handle
2577            .inner
2578            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2579                result,
2580                self.tx_id,
2581                0x61aa2d370caaf8f0,
2582                fidl::encoding::DynamicFlags::empty(),
2583            )
2584    }
2585}
2586
2587#[must_use = "FIDL methods require a response to be sent"]
2588#[derive(Debug)]
2589pub struct DeviceAdjustClockRateResponder {
2590    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2591    tx_id: u32,
2592}
2593
2594/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2595/// if the responder is dropped without sending a response, so that the client
2596/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2597impl std::ops::Drop for DeviceAdjustClockRateResponder {
2598    fn drop(&mut self) {
2599        self.control_handle.shutdown();
2600        // Safety: drops once, never accessed again
2601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2602    }
2603}
2604
2605impl fidl::endpoints::Responder for DeviceAdjustClockRateResponder {
2606    type ControlHandle = DeviceControlHandle;
2607
2608    fn control_handle(&self) -> &DeviceControlHandle {
2609        &self.control_handle
2610    }
2611
2612    fn drop_without_shutdown(mut self) {
2613        // Safety: drops once, never accessed again due to mem::forget
2614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2615        // Prevent Drop from running (which would shut down the channel)
2616        std::mem::forget(self);
2617    }
2618}
2619
2620impl DeviceAdjustClockRateResponder {
2621    /// Sends a response to the FIDL transaction.
2622    ///
2623    /// Sets the channel to shutdown if an error occurs.
2624    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2625        let _result = self.send_raw(result);
2626        if _result.is_err() {
2627            self.control_handle.shutdown();
2628        }
2629        self.drop_without_shutdown();
2630        _result
2631    }
2632
2633    /// Similar to "send" but does not shutdown the channel if an error occurs.
2634    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2635        let _result = self.send_raw(result);
2636        self.drop_without_shutdown();
2637        _result
2638    }
2639
2640    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2641        self.control_handle
2642            .inner
2643            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2644                result,
2645                self.tx_id,
2646                0x754661f655350134,
2647                fidl::encoding::DynamicFlags::empty(),
2648            )
2649    }
2650}
2651
2652mod internal {
2653    use super::*;
2654
2655    impl fidl::encoding::ResourceTypeMarker for ControlAddDeviceRequest {
2656        type Borrowed<'a> = &'a mut Self;
2657        fn take_or_borrow<'a>(
2658            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2659        ) -> Self::Borrowed<'a> {
2660            value
2661        }
2662    }
2663
2664    unsafe impl fidl::encoding::TypeMarker for ControlAddDeviceRequest {
2665        type Owned = Self;
2666
2667        #[inline(always)]
2668        fn inline_align(_context: fidl::encoding::Context) -> usize {
2669            8
2670        }
2671
2672        #[inline(always)]
2673        fn inline_size(_context: fidl::encoding::Context) -> usize {
2674            24
2675        }
2676    }
2677
2678    unsafe impl
2679        fidl::encoding::Encode<
2680            ControlAddDeviceRequest,
2681            fidl::encoding::DefaultFuchsiaResourceDialect,
2682        > for &mut ControlAddDeviceRequest
2683    {
2684        #[inline]
2685        unsafe fn encode(
2686            self,
2687            encoder: &mut fidl::encoding::Encoder<
2688                '_,
2689                fidl::encoding::DefaultFuchsiaResourceDialect,
2690            >,
2691            offset: usize,
2692            _depth: fidl::encoding::Depth,
2693        ) -> fidl::Result<()> {
2694            encoder.debug_check_bounds::<ControlAddDeviceRequest>(offset);
2695            // Delegate to tuple encoding.
2696            fidl::encoding::Encode::<ControlAddDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2697                (
2698                    <Configuration as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
2699                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
2700                ),
2701                encoder, offset, _depth
2702            )
2703        }
2704    }
2705    unsafe impl<
2706            T0: fidl::encoding::Encode<Configuration, fidl::encoding::DefaultFuchsiaResourceDialect>,
2707            T1: fidl::encoding::Encode<
2708                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2709                fidl::encoding::DefaultFuchsiaResourceDialect,
2710            >,
2711        >
2712        fidl::encoding::Encode<
2713            ControlAddDeviceRequest,
2714            fidl::encoding::DefaultFuchsiaResourceDialect,
2715        > for (T0, T1)
2716    {
2717        #[inline]
2718        unsafe fn encode(
2719            self,
2720            encoder: &mut fidl::encoding::Encoder<
2721                '_,
2722                fidl::encoding::DefaultFuchsiaResourceDialect,
2723            >,
2724            offset: usize,
2725            depth: fidl::encoding::Depth,
2726        ) -> fidl::Result<()> {
2727            encoder.debug_check_bounds::<ControlAddDeviceRequest>(offset);
2728            // Zero out padding regions. There's no need to apply masks
2729            // because the unmasked parts will be overwritten by fields.
2730            unsafe {
2731                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2732                (ptr as *mut u64).write_unaligned(0);
2733            }
2734            // Write the fields.
2735            self.0.encode(encoder, offset + 0, depth)?;
2736            self.1.encode(encoder, offset + 16, depth)?;
2737            Ok(())
2738        }
2739    }
2740
2741    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2742        for ControlAddDeviceRequest
2743    {
2744        #[inline(always)]
2745        fn new_empty() -> Self {
2746            Self {
2747                config: fidl::new_empty!(
2748                    Configuration,
2749                    fidl::encoding::DefaultFuchsiaResourceDialect
2750                ),
2751                server: fidl::new_empty!(
2752                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2753                    fidl::encoding::DefaultFuchsiaResourceDialect
2754                ),
2755            }
2756        }
2757
2758        #[inline]
2759        unsafe fn decode(
2760            &mut self,
2761            decoder: &mut fidl::encoding::Decoder<
2762                '_,
2763                fidl::encoding::DefaultFuchsiaResourceDialect,
2764            >,
2765            offset: usize,
2766            _depth: fidl::encoding::Depth,
2767        ) -> fidl::Result<()> {
2768            decoder.debug_check_bounds::<Self>(offset);
2769            // Verify that padding bytes are zero.
2770            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2771            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2772            let mask = 0xffffffff00000000u64;
2773            let maskedval = padval & mask;
2774            if maskedval != 0 {
2775                return Err(fidl::Error::NonZeroPadding {
2776                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2777                });
2778            }
2779            fidl::decode!(
2780                Configuration,
2781                fidl::encoding::DefaultFuchsiaResourceDialect,
2782                &mut self.config,
2783                decoder,
2784                offset + 0,
2785                _depth
2786            )?;
2787            fidl::decode!(
2788                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2789                fidl::encoding::DefaultFuchsiaResourceDialect,
2790                &mut self.server,
2791                decoder,
2792                offset + 16,
2793                _depth
2794            )?;
2795            Ok(())
2796        }
2797    }
2798
2799    impl fidl::encoding::ResourceTypeMarker for DeviceOnBufferCreatedRequest {
2800        type Borrowed<'a> = &'a mut Self;
2801        fn take_or_borrow<'a>(
2802            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2803        ) -> Self::Borrowed<'a> {
2804            value
2805        }
2806    }
2807
2808    unsafe impl fidl::encoding::TypeMarker for DeviceOnBufferCreatedRequest {
2809        type Owned = Self;
2810
2811        #[inline(always)]
2812        fn inline_align(_context: fidl::encoding::Context) -> usize {
2813            4
2814        }
2815
2816        #[inline(always)]
2817        fn inline_size(_context: fidl::encoding::Context) -> usize {
2818            12
2819        }
2820    }
2821
2822    unsafe impl
2823        fidl::encoding::Encode<
2824            DeviceOnBufferCreatedRequest,
2825            fidl::encoding::DefaultFuchsiaResourceDialect,
2826        > for &mut DeviceOnBufferCreatedRequest
2827    {
2828        #[inline]
2829        unsafe fn encode(
2830            self,
2831            encoder: &mut fidl::encoding::Encoder<
2832                '_,
2833                fidl::encoding::DefaultFuchsiaResourceDialect,
2834            >,
2835            offset: usize,
2836            _depth: fidl::encoding::Depth,
2837        ) -> fidl::Result<()> {
2838            encoder.debug_check_bounds::<DeviceOnBufferCreatedRequest>(offset);
2839            // Delegate to tuple encoding.
2840            fidl::encoding::Encode::<
2841                DeviceOnBufferCreatedRequest,
2842                fidl::encoding::DefaultFuchsiaResourceDialect,
2843            >::encode(
2844                (
2845                    <fidl::encoding::HandleType<
2846                        fidl::Vmo,
2847                        { fidl::ObjectType::VMO.into_raw() },
2848                        2147483648,
2849                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2850                        &mut self.ring_buffer
2851                    ),
2852                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_ring_buffer_frames),
2853                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.notifications_per_ring),
2854                ),
2855                encoder,
2856                offset,
2857                _depth,
2858            )
2859        }
2860    }
2861    unsafe impl<
2862            T0: fidl::encoding::Encode<
2863                fidl::encoding::HandleType<
2864                    fidl::Vmo,
2865                    { fidl::ObjectType::VMO.into_raw() },
2866                    2147483648,
2867                >,
2868                fidl::encoding::DefaultFuchsiaResourceDialect,
2869            >,
2870            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2871            T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2872        >
2873        fidl::encoding::Encode<
2874            DeviceOnBufferCreatedRequest,
2875            fidl::encoding::DefaultFuchsiaResourceDialect,
2876        > for (T0, T1, T2)
2877    {
2878        #[inline]
2879        unsafe fn encode(
2880            self,
2881            encoder: &mut fidl::encoding::Encoder<
2882                '_,
2883                fidl::encoding::DefaultFuchsiaResourceDialect,
2884            >,
2885            offset: usize,
2886            depth: fidl::encoding::Depth,
2887        ) -> fidl::Result<()> {
2888            encoder.debug_check_bounds::<DeviceOnBufferCreatedRequest>(offset);
2889            // Zero out padding regions. There's no need to apply masks
2890            // because the unmasked parts will be overwritten by fields.
2891            // Write the fields.
2892            self.0.encode(encoder, offset + 0, depth)?;
2893            self.1.encode(encoder, offset + 4, depth)?;
2894            self.2.encode(encoder, offset + 8, depth)?;
2895            Ok(())
2896        }
2897    }
2898
2899    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2900        for DeviceOnBufferCreatedRequest
2901    {
2902        #[inline(always)]
2903        fn new_empty() -> Self {
2904            Self {
2905                ring_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2906                num_ring_buffer_frames: fidl::new_empty!(
2907                    u32,
2908                    fidl::encoding::DefaultFuchsiaResourceDialect
2909                ),
2910                notifications_per_ring: fidl::new_empty!(
2911                    u32,
2912                    fidl::encoding::DefaultFuchsiaResourceDialect
2913                ),
2914            }
2915        }
2916
2917        #[inline]
2918        unsafe fn decode(
2919            &mut self,
2920            decoder: &mut fidl::encoding::Decoder<
2921                '_,
2922                fidl::encoding::DefaultFuchsiaResourceDialect,
2923            >,
2924            offset: usize,
2925            _depth: fidl::encoding::Depth,
2926        ) -> fidl::Result<()> {
2927            decoder.debug_check_bounds::<Self>(offset);
2928            // Verify that padding bytes are zero.
2929            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ring_buffer, decoder, offset + 0, _depth)?;
2930            fidl::decode!(
2931                u32,
2932                fidl::encoding::DefaultFuchsiaResourceDialect,
2933                &mut self.num_ring_buffer_frames,
2934                decoder,
2935                offset + 4,
2936                _depth
2937            )?;
2938            fidl::decode!(
2939                u32,
2940                fidl::encoding::DefaultFuchsiaResourceDialect,
2941                &mut self.notifications_per_ring,
2942                decoder,
2943                offset + 8,
2944                _depth
2945            )?;
2946            Ok(())
2947        }
2948    }
2949
2950    impl fidl::encoding::ResourceTypeMarker for DeviceGetBufferResponse {
2951        type Borrowed<'a> = &'a mut Self;
2952        fn take_or_borrow<'a>(
2953            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2954        ) -> Self::Borrowed<'a> {
2955            value
2956        }
2957    }
2958
2959    unsafe impl fidl::encoding::TypeMarker for DeviceGetBufferResponse {
2960        type Owned = Self;
2961
2962        #[inline(always)]
2963        fn inline_align(_context: fidl::encoding::Context) -> usize {
2964            4
2965        }
2966
2967        #[inline(always)]
2968        fn inline_size(_context: fidl::encoding::Context) -> usize {
2969            12
2970        }
2971    }
2972
2973    unsafe impl
2974        fidl::encoding::Encode<
2975            DeviceGetBufferResponse,
2976            fidl::encoding::DefaultFuchsiaResourceDialect,
2977        > for &mut DeviceGetBufferResponse
2978    {
2979        #[inline]
2980        unsafe fn encode(
2981            self,
2982            encoder: &mut fidl::encoding::Encoder<
2983                '_,
2984                fidl::encoding::DefaultFuchsiaResourceDialect,
2985            >,
2986            offset: usize,
2987            _depth: fidl::encoding::Depth,
2988        ) -> fidl::Result<()> {
2989            encoder.debug_check_bounds::<DeviceGetBufferResponse>(offset);
2990            // Delegate to tuple encoding.
2991            fidl::encoding::Encode::<
2992                DeviceGetBufferResponse,
2993                fidl::encoding::DefaultFuchsiaResourceDialect,
2994            >::encode(
2995                (
2996                    <fidl::encoding::HandleType<
2997                        fidl::Vmo,
2998                        { fidl::ObjectType::VMO.into_raw() },
2999                        2147483648,
3000                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3001                        &mut self.ring_buffer
3002                    ),
3003                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_ring_buffer_frames),
3004                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.notifications_per_ring),
3005                ),
3006                encoder,
3007                offset,
3008                _depth,
3009            )
3010        }
3011    }
3012    unsafe impl<
3013            T0: fidl::encoding::Encode<
3014                fidl::encoding::HandleType<
3015                    fidl::Vmo,
3016                    { fidl::ObjectType::VMO.into_raw() },
3017                    2147483648,
3018                >,
3019                fidl::encoding::DefaultFuchsiaResourceDialect,
3020            >,
3021            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3022            T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3023        >
3024        fidl::encoding::Encode<
3025            DeviceGetBufferResponse,
3026            fidl::encoding::DefaultFuchsiaResourceDialect,
3027        > for (T0, T1, T2)
3028    {
3029        #[inline]
3030        unsafe fn encode(
3031            self,
3032            encoder: &mut fidl::encoding::Encoder<
3033                '_,
3034                fidl::encoding::DefaultFuchsiaResourceDialect,
3035            >,
3036            offset: usize,
3037            depth: fidl::encoding::Depth,
3038        ) -> fidl::Result<()> {
3039            encoder.debug_check_bounds::<DeviceGetBufferResponse>(offset);
3040            // Zero out padding regions. There's no need to apply masks
3041            // because the unmasked parts will be overwritten by fields.
3042            // Write the fields.
3043            self.0.encode(encoder, offset + 0, depth)?;
3044            self.1.encode(encoder, offset + 4, depth)?;
3045            self.2.encode(encoder, offset + 8, depth)?;
3046            Ok(())
3047        }
3048    }
3049
3050    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3051        for DeviceGetBufferResponse
3052    {
3053        #[inline(always)]
3054        fn new_empty() -> Self {
3055            Self {
3056                ring_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3057                num_ring_buffer_frames: fidl::new_empty!(
3058                    u32,
3059                    fidl::encoding::DefaultFuchsiaResourceDialect
3060                ),
3061                notifications_per_ring: fidl::new_empty!(
3062                    u32,
3063                    fidl::encoding::DefaultFuchsiaResourceDialect
3064                ),
3065            }
3066        }
3067
3068        #[inline]
3069        unsafe fn decode(
3070            &mut self,
3071            decoder: &mut fidl::encoding::Decoder<
3072                '_,
3073                fidl::encoding::DefaultFuchsiaResourceDialect,
3074            >,
3075            offset: usize,
3076            _depth: fidl::encoding::Depth,
3077        ) -> fidl::Result<()> {
3078            decoder.debug_check_bounds::<Self>(offset);
3079            // Verify that padding bytes are zero.
3080            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ring_buffer, decoder, offset + 0, _depth)?;
3081            fidl::decode!(
3082                u32,
3083                fidl::encoding::DefaultFuchsiaResourceDialect,
3084                &mut self.num_ring_buffer_frames,
3085                decoder,
3086                offset + 4,
3087                _depth
3088            )?;
3089            fidl::decode!(
3090                u32,
3091                fidl::encoding::DefaultFuchsiaResourceDialect,
3092                &mut self.notifications_per_ring,
3093                decoder,
3094                offset + 8,
3095                _depth
3096            )?;
3097            Ok(())
3098        }
3099    }
3100}