Skip to main content

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