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