Skip to main content

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