fidl_fuchsia_hardware_audio_signalprocessing/
fidl_fuchsia_hardware_audio_signalprocessing.rs

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