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