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