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