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