fidl_fuchsia_hardware_audio_signalprocessing/
fidl_fuchsia_hardware_audio_signalprocessing.rs

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