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 {
1097            Some((responder))
1098        } else {
1099            None
1100        }
1101    }
1102
1103    #[allow(irrefutable_let_patterns)]
1104    pub fn into_watch_element_state(self) -> Option<(u64, ReaderWatchElementStateResponder)> {
1105        if let ReaderRequest::WatchElementState { processing_element_id, responder } = self {
1106            Some((processing_element_id, responder))
1107        } else {
1108            None
1109        }
1110    }
1111
1112    #[allow(irrefutable_let_patterns)]
1113    pub fn into_get_topologies(self) -> Option<(ReaderGetTopologiesResponder)> {
1114        if let ReaderRequest::GetTopologies { responder } = self {
1115            Some((responder))
1116        } else {
1117            None
1118        }
1119    }
1120
1121    #[allow(irrefutable_let_patterns)]
1122    pub fn into_watch_topology(self) -> Option<(ReaderWatchTopologyResponder)> {
1123        if let ReaderRequest::WatchTopology { responder } = self {
1124            Some((responder))
1125        } else {
1126            None
1127        }
1128    }
1129
1130    /// Name of the method defined in FIDL
1131    pub fn method_name(&self) -> &'static str {
1132        match *self {
1133            ReaderRequest::GetElements { .. } => "get_elements",
1134            ReaderRequest::WatchElementState { .. } => "watch_element_state",
1135            ReaderRequest::GetTopologies { .. } => "get_topologies",
1136            ReaderRequest::WatchTopology { .. } => "watch_topology",
1137            ReaderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1138                "unknown one-way method"
1139            }
1140            ReaderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1141                "unknown two-way method"
1142            }
1143        }
1144    }
1145}
1146
1147#[derive(Debug, Clone)]
1148pub struct ReaderControlHandle {
1149    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1150}
1151
1152impl fidl::endpoints::ControlHandle for ReaderControlHandle {
1153    fn shutdown(&self) {
1154        self.inner.shutdown()
1155    }
1156    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1157        self.inner.shutdown_with_epitaph(status)
1158    }
1159
1160    fn is_closed(&self) -> bool {
1161        self.inner.channel().is_closed()
1162    }
1163    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1164        self.inner.channel().on_closed()
1165    }
1166
1167    #[cfg(target_os = "fuchsia")]
1168    fn signal_peer(
1169        &self,
1170        clear_mask: zx::Signals,
1171        set_mask: zx::Signals,
1172    ) -> Result<(), zx_status::Status> {
1173        use fidl::Peered;
1174        self.inner.channel().signal_peer(clear_mask, set_mask)
1175    }
1176}
1177
1178impl ReaderControlHandle {}
1179
1180#[must_use = "FIDL methods require a response to be sent"]
1181#[derive(Debug)]
1182pub struct ReaderGetElementsResponder {
1183    control_handle: std::mem::ManuallyDrop<ReaderControlHandle>,
1184    tx_id: u32,
1185}
1186
1187/// Set the the channel to be shutdown (see [`ReaderControlHandle::shutdown`])
1188/// if the responder is dropped without sending a response, so that the client
1189/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1190impl std::ops::Drop for ReaderGetElementsResponder {
1191    fn drop(&mut self) {
1192        self.control_handle.shutdown();
1193        // Safety: drops once, never accessed again
1194        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1195    }
1196}
1197
1198impl fidl::endpoints::Responder for ReaderGetElementsResponder {
1199    type ControlHandle = ReaderControlHandle;
1200
1201    fn control_handle(&self) -> &ReaderControlHandle {
1202        &self.control_handle
1203    }
1204
1205    fn drop_without_shutdown(mut self) {
1206        // Safety: drops once, never accessed again due to mem::forget
1207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1208        // Prevent Drop from running (which would shut down the channel)
1209        std::mem::forget(self);
1210    }
1211}
1212
1213impl ReaderGetElementsResponder {
1214    /// Sends a response to the FIDL transaction.
1215    ///
1216    /// Sets the channel to shutdown if an error occurs.
1217    pub fn send(self, mut result: Result<&[Element], i32>) -> Result<(), fidl::Error> {
1218        let _result = self.send_raw(result);
1219        if _result.is_err() {
1220            self.control_handle.shutdown();
1221        }
1222        self.drop_without_shutdown();
1223        _result
1224    }
1225
1226    /// Similar to "send" but does not shutdown the channel if an error occurs.
1227    pub fn send_no_shutdown_on_err(
1228        self,
1229        mut result: Result<&[Element], i32>,
1230    ) -> Result<(), fidl::Error> {
1231        let _result = self.send_raw(result);
1232        self.drop_without_shutdown();
1233        _result
1234    }
1235
1236    fn send_raw(&self, mut result: Result<&[Element], i32>) -> Result<(), fidl::Error> {
1237        self.control_handle
1238            .inner
1239            .send::<fidl::encoding::ResultType<ReaderGetElementsResponse, i32>>(
1240                result.map(|processing_elements| (processing_elements,)),
1241                self.tx_id,
1242                0x1b14ff4adf5dc6f8,
1243                fidl::encoding::DynamicFlags::empty(),
1244            )
1245    }
1246}
1247
1248#[must_use = "FIDL methods require a response to be sent"]
1249#[derive(Debug)]
1250pub struct ReaderWatchElementStateResponder {
1251    control_handle: std::mem::ManuallyDrop<ReaderControlHandle>,
1252    tx_id: u32,
1253}
1254
1255/// Set the the channel to be shutdown (see [`ReaderControlHandle::shutdown`])
1256/// if the responder is dropped without sending a response, so that the client
1257/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1258impl std::ops::Drop for ReaderWatchElementStateResponder {
1259    fn drop(&mut self) {
1260        self.control_handle.shutdown();
1261        // Safety: drops once, never accessed again
1262        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1263    }
1264}
1265
1266impl fidl::endpoints::Responder for ReaderWatchElementStateResponder {
1267    type ControlHandle = ReaderControlHandle;
1268
1269    fn control_handle(&self) -> &ReaderControlHandle {
1270        &self.control_handle
1271    }
1272
1273    fn drop_without_shutdown(mut self) {
1274        // Safety: drops once, never accessed again due to mem::forget
1275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1276        // Prevent Drop from running (which would shut down the channel)
1277        std::mem::forget(self);
1278    }
1279}
1280
1281impl ReaderWatchElementStateResponder {
1282    /// Sends a response to the FIDL transaction.
1283    ///
1284    /// Sets the channel to shutdown if an error occurs.
1285    pub fn send(self, mut state: &ElementState) -> Result<(), fidl::Error> {
1286        let _result = self.send_raw(state);
1287        if _result.is_err() {
1288            self.control_handle.shutdown();
1289        }
1290        self.drop_without_shutdown();
1291        _result
1292    }
1293
1294    /// Similar to "send" but does not shutdown the channel if an error occurs.
1295    pub fn send_no_shutdown_on_err(self, mut state: &ElementState) -> Result<(), fidl::Error> {
1296        let _result = self.send_raw(state);
1297        self.drop_without_shutdown();
1298        _result
1299    }
1300
1301    fn send_raw(&self, mut state: &ElementState) -> Result<(), fidl::Error> {
1302        self.control_handle.inner.send::<ReaderWatchElementStateResponse>(
1303            (state,),
1304            self.tx_id,
1305            0x524da8772a69056f,
1306            fidl::encoding::DynamicFlags::empty(),
1307        )
1308    }
1309}
1310
1311#[must_use = "FIDL methods require a response to be sent"]
1312#[derive(Debug)]
1313pub struct ReaderGetTopologiesResponder {
1314    control_handle: std::mem::ManuallyDrop<ReaderControlHandle>,
1315    tx_id: u32,
1316}
1317
1318/// Set the the channel to be shutdown (see [`ReaderControlHandle::shutdown`])
1319/// if the responder is dropped without sending a response, so that the client
1320/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1321impl std::ops::Drop for ReaderGetTopologiesResponder {
1322    fn drop(&mut self) {
1323        self.control_handle.shutdown();
1324        // Safety: drops once, never accessed again
1325        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1326    }
1327}
1328
1329impl fidl::endpoints::Responder for ReaderGetTopologiesResponder {
1330    type ControlHandle = ReaderControlHandle;
1331
1332    fn control_handle(&self) -> &ReaderControlHandle {
1333        &self.control_handle
1334    }
1335
1336    fn drop_without_shutdown(mut self) {
1337        // Safety: drops once, never accessed again due to mem::forget
1338        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1339        // Prevent Drop from running (which would shut down the channel)
1340        std::mem::forget(self);
1341    }
1342}
1343
1344impl ReaderGetTopologiesResponder {
1345    /// Sends a response to the FIDL transaction.
1346    ///
1347    /// Sets the channel to shutdown if an error occurs.
1348    pub fn send(self, mut result: Result<&[Topology], i32>) -> Result<(), fidl::Error> {
1349        let _result = self.send_raw(result);
1350        if _result.is_err() {
1351            self.control_handle.shutdown();
1352        }
1353        self.drop_without_shutdown();
1354        _result
1355    }
1356
1357    /// Similar to "send" but does not shutdown the channel if an error occurs.
1358    pub fn send_no_shutdown_on_err(
1359        self,
1360        mut result: Result<&[Topology], i32>,
1361    ) -> Result<(), fidl::Error> {
1362        let _result = self.send_raw(result);
1363        self.drop_without_shutdown();
1364        _result
1365    }
1366
1367    fn send_raw(&self, mut result: Result<&[Topology], i32>) -> Result<(), fidl::Error> {
1368        self.control_handle
1369            .inner
1370            .send::<fidl::encoding::ResultType<ReaderGetTopologiesResponse, i32>>(
1371                result.map(|topologies| (topologies,)),
1372                self.tx_id,
1373                0x73ffb73af24d30b6,
1374                fidl::encoding::DynamicFlags::empty(),
1375            )
1376    }
1377}
1378
1379#[must_use = "FIDL methods require a response to be sent"]
1380#[derive(Debug)]
1381pub struct ReaderWatchTopologyResponder {
1382    control_handle: std::mem::ManuallyDrop<ReaderControlHandle>,
1383    tx_id: u32,
1384}
1385
1386/// Set the the channel to be shutdown (see [`ReaderControlHandle::shutdown`])
1387/// if the responder is dropped without sending a response, so that the client
1388/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1389impl std::ops::Drop for ReaderWatchTopologyResponder {
1390    fn drop(&mut self) {
1391        self.control_handle.shutdown();
1392        // Safety: drops once, never accessed again
1393        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1394    }
1395}
1396
1397impl fidl::endpoints::Responder for ReaderWatchTopologyResponder {
1398    type ControlHandle = ReaderControlHandle;
1399
1400    fn control_handle(&self) -> &ReaderControlHandle {
1401        &self.control_handle
1402    }
1403
1404    fn drop_without_shutdown(mut self) {
1405        // Safety: drops once, never accessed again due to mem::forget
1406        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1407        // Prevent Drop from running (which would shut down the channel)
1408        std::mem::forget(self);
1409    }
1410}
1411
1412impl ReaderWatchTopologyResponder {
1413    /// Sends a response to the FIDL transaction.
1414    ///
1415    /// Sets the channel to shutdown if an error occurs.
1416    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
1417        let _result = self.send_raw(topology_id);
1418        if _result.is_err() {
1419            self.control_handle.shutdown();
1420        }
1421        self.drop_without_shutdown();
1422        _result
1423    }
1424
1425    /// Similar to "send" but does not shutdown the channel if an error occurs.
1426    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
1427        let _result = self.send_raw(topology_id);
1428        self.drop_without_shutdown();
1429        _result
1430    }
1431
1432    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
1433        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ReaderWatchTopologyResponse>>(
1434            fidl::encoding::Flexible::new((topology_id,)),
1435            self.tx_id,
1436            0x66d172acdb36a729,
1437            fidl::encoding::DynamicFlags::FLEXIBLE,
1438        )
1439    }
1440}
1441
1442#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1443pub struct SignalProcessingMarker;
1444
1445impl fidl::endpoints::ProtocolMarker for SignalProcessingMarker {
1446    type Proxy = SignalProcessingProxy;
1447    type RequestStream = SignalProcessingRequestStream;
1448    #[cfg(target_os = "fuchsia")]
1449    type SynchronousProxy = SignalProcessingSynchronousProxy;
1450
1451    const DEBUG_NAME: &'static str = "(anonymous) SignalProcessing";
1452}
1453pub type SignalProcessingSetTopologyResult = Result<(), i32>;
1454pub type SignalProcessingSetElementStateResult = Result<(), i32>;
1455
1456pub trait SignalProcessingProxyInterface: Send + Sync {
1457    type GetElementsResponseFut: std::future::Future<Output = Result<ReaderGetElementsResult, fidl::Error>>
1458        + Send;
1459    fn r#get_elements(&self) -> Self::GetElementsResponseFut;
1460    type WatchElementStateResponseFut: std::future::Future<Output = Result<ElementState, fidl::Error>>
1461        + Send;
1462    fn r#watch_element_state(
1463        &self,
1464        processing_element_id: u64,
1465    ) -> Self::WatchElementStateResponseFut;
1466    type GetTopologiesResponseFut: std::future::Future<Output = Result<ReaderGetTopologiesResult, fidl::Error>>
1467        + Send;
1468    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut;
1469    type WatchTopologyResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
1470    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut;
1471    type SetTopologyResponseFut: std::future::Future<Output = Result<SignalProcessingSetTopologyResult, fidl::Error>>
1472        + Send;
1473    fn r#set_topology(&self, topology_id: u64) -> Self::SetTopologyResponseFut;
1474    type SetElementStateResponseFut: std::future::Future<Output = Result<SignalProcessingSetElementStateResult, fidl::Error>>
1475        + Send;
1476    fn r#set_element_state(
1477        &self,
1478        processing_element_id: u64,
1479        state: &SettableElementState,
1480    ) -> Self::SetElementStateResponseFut;
1481}
1482#[derive(Debug)]
1483#[cfg(target_os = "fuchsia")]
1484pub struct SignalProcessingSynchronousProxy {
1485    client: fidl::client::sync::Client,
1486}
1487
1488#[cfg(target_os = "fuchsia")]
1489impl fidl::endpoints::SynchronousProxy for SignalProcessingSynchronousProxy {
1490    type Proxy = SignalProcessingProxy;
1491    type Protocol = SignalProcessingMarker;
1492
1493    fn from_channel(inner: fidl::Channel) -> Self {
1494        Self::new(inner)
1495    }
1496
1497    fn into_channel(self) -> fidl::Channel {
1498        self.client.into_channel()
1499    }
1500
1501    fn as_channel(&self) -> &fidl::Channel {
1502        self.client.as_channel()
1503    }
1504}
1505
1506#[cfg(target_os = "fuchsia")]
1507impl SignalProcessingSynchronousProxy {
1508    pub fn new(channel: fidl::Channel) -> Self {
1509        let protocol_name = <SignalProcessingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1510        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1511    }
1512
1513    pub fn into_channel(self) -> fidl::Channel {
1514        self.client.into_channel()
1515    }
1516
1517    /// Waits until an event arrives and returns it. It is safe for other
1518    /// threads to make concurrent requests while waiting for an event.
1519    pub fn wait_for_event(
1520        &self,
1521        deadline: zx::MonotonicInstant,
1522    ) -> Result<SignalProcessingEvent, fidl::Error> {
1523        SignalProcessingEvent::decode(self.client.wait_for_event(deadline)?)
1524    }
1525
1526    /// Returns a vector of supported processing elements.
1527    /// This vector must include one or more processing elements.
1528    pub fn r#get_elements(
1529        &self,
1530        ___deadline: zx::MonotonicInstant,
1531    ) -> Result<ReaderGetElementsResult, fidl::Error> {
1532        let _response = self.client.send_query::<
1533            fidl::encoding::EmptyPayload,
1534            fidl::encoding::ResultType<ReaderGetElementsResponse, i32>,
1535        >(
1536            (),
1537            0x1b14ff4adf5dc6f8,
1538            fidl::encoding::DynamicFlags::empty(),
1539            ___deadline,
1540        )?;
1541        Ok(_response.map(|x| x.processing_elements))
1542    }
1543
1544    /// Get the processing element state via a hanging get.
1545    /// For a given `processing_element_id`, the driver will immediately reply to the first
1546    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
1547    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
1548    /// `ElementState` has changed from what was most recently reported for that element.
1549    ///
1550    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
1551    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
1552    ///
1553    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1554    /// method is called again while there is already a pending `WatchElementState` for this client
1555    /// and `processing_element_id`.
1556    pub fn r#watch_element_state(
1557        &self,
1558        mut processing_element_id: u64,
1559        ___deadline: zx::MonotonicInstant,
1560    ) -> Result<ElementState, fidl::Error> {
1561        let _response = self
1562            .client
1563            .send_query::<ReaderWatchElementStateRequest, ReaderWatchElementStateResponse>(
1564                (processing_element_id,),
1565                0x524da8772a69056f,
1566                fidl::encoding::DynamicFlags::empty(),
1567                ___deadline,
1568            )?;
1569        Ok(_response.state)
1570    }
1571
1572    /// Returns a vector of supported topologies.
1573    /// This vector must include one or more topologies.
1574    /// If more than one topology is returned, then the client may select any topology from the
1575    /// list by calling `SetTopology`.
1576    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
1577    ///
1578    /// Each Element must be included in at least one Topology, but need not be included in every
1579    /// Topology.
1580    pub fn r#get_topologies(
1581        &self,
1582        ___deadline: zx::MonotonicInstant,
1583    ) -> Result<ReaderGetTopologiesResult, fidl::Error> {
1584        let _response = self.client.send_query::<
1585            fidl::encoding::EmptyPayload,
1586            fidl::encoding::ResultType<ReaderGetTopologiesResponse, i32>,
1587        >(
1588            (),
1589            0x73ffb73af24d30b6,
1590            fidl::encoding::DynamicFlags::empty(),
1591            ___deadline,
1592        )?;
1593        Ok(_response.map(|x| x.topologies))
1594    }
1595
1596    /// Get the current topology via a hanging get.
1597    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
1598    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
1599    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
1600    ///
1601    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1602    /// method is called again while there is already a pending `WatchTopology` for this client.
1603    pub fn r#watch_topology(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
1604        let _response = self.client.send_query::<
1605            fidl::encoding::EmptyPayload,
1606            fidl::encoding::FlexibleType<ReaderWatchTopologyResponse>,
1607        >(
1608            (),
1609            0x66d172acdb36a729,
1610            fidl::encoding::DynamicFlags::FLEXIBLE,
1611            ___deadline,
1612        )?
1613        .into_result::<SignalProcessingMarker>("watch_topology")?;
1614        Ok(_response.topology_id)
1615    }
1616
1617    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
1618    /// in the vector returned by `GetTopologies`.
1619    /// The currently active topology is communicated by `WatchTopology` responses. To change which
1620    /// topology is active, a client uses `SetTopology`.
1621    ///
1622    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
1623    ///
1624    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
1625    /// found within the`topologies` returned by `GetTopologies`.
1626    ///
1627    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
1628    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
1629    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
1630    /// the driver state. See `SetElementState` for further discussion.
1631    pub fn r#set_topology(
1632        &self,
1633        mut topology_id: u64,
1634        ___deadline: zx::MonotonicInstant,
1635    ) -> Result<SignalProcessingSetTopologyResult, fidl::Error> {
1636        let _response = self.client.send_query::<
1637            SignalProcessingSetTopologyRequest,
1638            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1639        >(
1640            (topology_id,),
1641            0x1d9a7f9b8fee790c,
1642            fidl::encoding::DynamicFlags::empty(),
1643            ___deadline,
1644        )?;
1645        Ok(_response.map(|x| x))
1646    }
1647
1648    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1649    /// returned by `GetElements`.
1650    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1651    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1652    /// or `plug_state`) can only be observed (not set) by the client.
1653    ///
1654    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1655    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1656    /// violation of the rules specified in this protocol.
1657    ///
1658    /// Examples:
1659    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1660    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1661    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1662    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1663    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1664    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1665    ///     in its `supported_controls`.
1666    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1667    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1668    ///
1669    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1670    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1671    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1672    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1673    /// parameters may not require renegotiation of driver state because changing gain parameters
1674    /// usually does not change the set of supported audio formats.
1675    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1676    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1677    /// format change may invalidate the set of supported formats returned in a previous
1678    /// `GetDaiFormats` protocol call for another part of the Topology.
1679    ///
1680    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1681    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1682    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1683    /// The client then must re-invoke the `SetElementState` call that returned
1684    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1685    pub fn r#set_element_state(
1686        &self,
1687        mut processing_element_id: u64,
1688        mut state: &SettableElementState,
1689        ___deadline: zx::MonotonicInstant,
1690    ) -> Result<SignalProcessingSetElementStateResult, fidl::Error> {
1691        let _response = self.client.send_query::<
1692            SignalProcessingSetElementStateRequest,
1693            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1694        >(
1695            (processing_element_id, state,),
1696            0x38c3b2d4bae698f4,
1697            fidl::encoding::DynamicFlags::empty(),
1698            ___deadline,
1699        )?;
1700        Ok(_response.map(|x| x))
1701    }
1702}
1703
1704#[cfg(target_os = "fuchsia")]
1705impl From<SignalProcessingSynchronousProxy> for zx::Handle {
1706    fn from(value: SignalProcessingSynchronousProxy) -> Self {
1707        value.into_channel().into()
1708    }
1709}
1710
1711#[cfg(target_os = "fuchsia")]
1712impl From<fidl::Channel> for SignalProcessingSynchronousProxy {
1713    fn from(value: fidl::Channel) -> Self {
1714        Self::new(value)
1715    }
1716}
1717
1718#[cfg(target_os = "fuchsia")]
1719impl fidl::endpoints::FromClient for SignalProcessingSynchronousProxy {
1720    type Protocol = SignalProcessingMarker;
1721
1722    fn from_client(value: fidl::endpoints::ClientEnd<SignalProcessingMarker>) -> Self {
1723        Self::new(value.into_channel())
1724    }
1725}
1726
1727#[derive(Debug, Clone)]
1728pub struct SignalProcessingProxy {
1729    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1730}
1731
1732impl fidl::endpoints::Proxy for SignalProcessingProxy {
1733    type Protocol = SignalProcessingMarker;
1734
1735    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1736        Self::new(inner)
1737    }
1738
1739    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1740        self.client.into_channel().map_err(|client| Self { client })
1741    }
1742
1743    fn as_channel(&self) -> &::fidl::AsyncChannel {
1744        self.client.as_channel()
1745    }
1746}
1747
1748impl SignalProcessingProxy {
1749    /// Create a new Proxy for fuchsia.hardware.audio.signalprocessing/SignalProcessing.
1750    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1751        let protocol_name = <SignalProcessingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1752        Self { client: fidl::client::Client::new(channel, protocol_name) }
1753    }
1754
1755    /// Get a Stream of events from the remote end of the protocol.
1756    ///
1757    /// # Panics
1758    ///
1759    /// Panics if the event stream was already taken.
1760    pub fn take_event_stream(&self) -> SignalProcessingEventStream {
1761        SignalProcessingEventStream { event_receiver: self.client.take_event_receiver() }
1762    }
1763
1764    /// Returns a vector of supported processing elements.
1765    /// This vector must include one or more processing elements.
1766    pub fn r#get_elements(
1767        &self,
1768    ) -> fidl::client::QueryResponseFut<
1769        ReaderGetElementsResult,
1770        fidl::encoding::DefaultFuchsiaResourceDialect,
1771    > {
1772        SignalProcessingProxyInterface::r#get_elements(self)
1773    }
1774
1775    /// Get the processing element state via a hanging get.
1776    /// For a given `processing_element_id`, the driver will immediately reply to the first
1777    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
1778    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
1779    /// `ElementState` has changed from what was most recently reported for that element.
1780    ///
1781    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
1782    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
1783    ///
1784    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1785    /// method is called again while there is already a pending `WatchElementState` for this client
1786    /// and `processing_element_id`.
1787    pub fn r#watch_element_state(
1788        &self,
1789        mut processing_element_id: u64,
1790    ) -> fidl::client::QueryResponseFut<ElementState, fidl::encoding::DefaultFuchsiaResourceDialect>
1791    {
1792        SignalProcessingProxyInterface::r#watch_element_state(self, processing_element_id)
1793    }
1794
1795    /// Returns a vector of supported topologies.
1796    /// This vector must include one or more topologies.
1797    /// If more than one topology is returned, then the client may select any topology from the
1798    /// list by calling `SetTopology`.
1799    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
1800    ///
1801    /// Each Element must be included in at least one Topology, but need not be included in every
1802    /// Topology.
1803    pub fn r#get_topologies(
1804        &self,
1805    ) -> fidl::client::QueryResponseFut<
1806        ReaderGetTopologiesResult,
1807        fidl::encoding::DefaultFuchsiaResourceDialect,
1808    > {
1809        SignalProcessingProxyInterface::r#get_topologies(self)
1810    }
1811
1812    /// Get the current topology via a hanging get.
1813    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
1814    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
1815    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
1816    ///
1817    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
1818    /// method is called again while there is already a pending `WatchTopology` for this client.
1819    pub fn r#watch_topology(
1820        &self,
1821    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
1822        SignalProcessingProxyInterface::r#watch_topology(self)
1823    }
1824
1825    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
1826    /// in the vector returned by `GetTopologies`.
1827    /// The currently active topology is communicated by `WatchTopology` responses. To change which
1828    /// topology is active, a client uses `SetTopology`.
1829    ///
1830    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
1831    ///
1832    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
1833    /// found within the`topologies` returned by `GetTopologies`.
1834    ///
1835    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
1836    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
1837    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
1838    /// the driver state. See `SetElementState` for further discussion.
1839    pub fn r#set_topology(
1840        &self,
1841        mut topology_id: u64,
1842    ) -> fidl::client::QueryResponseFut<
1843        SignalProcessingSetTopologyResult,
1844        fidl::encoding::DefaultFuchsiaResourceDialect,
1845    > {
1846        SignalProcessingProxyInterface::r#set_topology(self, topology_id)
1847    }
1848
1849    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
1850    /// returned by `GetElements`.
1851    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
1852    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
1853    /// or `plug_state`) can only be observed (not set) by the client.
1854    ///
1855    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
1856    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
1857    /// violation of the rules specified in this protocol.
1858    ///
1859    /// Examples:
1860    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
1861    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
1862    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
1863    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
1864    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
1865    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
1866    ///     in its `supported_controls`.
1867    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
1868    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
1869    ///
1870    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
1871    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
1872    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
1873    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
1874    /// parameters may not require renegotiation of driver state because changing gain parameters
1875    /// usually does not change the set of supported audio formats.
1876    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
1877    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
1878    /// format change may invalidate the set of supported formats returned in a previous
1879    /// `GetDaiFormats` protocol call for another part of the Topology.
1880    ///
1881    /// It is the driver's job to determine when renegotiation is required. When this is needed,
1882    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
1883    /// close the protocol channel entirely, such that the protocol negotiations are started over.
1884    /// The client then must re-invoke the `SetElementState` call that returned
1885    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
1886    pub fn r#set_element_state(
1887        &self,
1888        mut processing_element_id: u64,
1889        mut state: &SettableElementState,
1890    ) -> fidl::client::QueryResponseFut<
1891        SignalProcessingSetElementStateResult,
1892        fidl::encoding::DefaultFuchsiaResourceDialect,
1893    > {
1894        SignalProcessingProxyInterface::r#set_element_state(self, processing_element_id, state)
1895    }
1896}
1897
1898impl SignalProcessingProxyInterface for SignalProcessingProxy {
1899    type GetElementsResponseFut = fidl::client::QueryResponseFut<
1900        ReaderGetElementsResult,
1901        fidl::encoding::DefaultFuchsiaResourceDialect,
1902    >;
1903    fn r#get_elements(&self) -> Self::GetElementsResponseFut {
1904        fn _decode(
1905            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1906        ) -> Result<ReaderGetElementsResult, fidl::Error> {
1907            let _response = fidl::client::decode_transaction_body::<
1908                fidl::encoding::ResultType<ReaderGetElementsResponse, i32>,
1909                fidl::encoding::DefaultFuchsiaResourceDialect,
1910                0x1b14ff4adf5dc6f8,
1911            >(_buf?)?;
1912            Ok(_response.map(|x| x.processing_elements))
1913        }
1914        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ReaderGetElementsResult>(
1915            (),
1916            0x1b14ff4adf5dc6f8,
1917            fidl::encoding::DynamicFlags::empty(),
1918            _decode,
1919        )
1920    }
1921
1922    type WatchElementStateResponseFut =
1923        fidl::client::QueryResponseFut<ElementState, fidl::encoding::DefaultFuchsiaResourceDialect>;
1924    fn r#watch_element_state(
1925        &self,
1926        mut processing_element_id: u64,
1927    ) -> Self::WatchElementStateResponseFut {
1928        fn _decode(
1929            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1930        ) -> Result<ElementState, fidl::Error> {
1931            let _response = fidl::client::decode_transaction_body::<
1932                ReaderWatchElementStateResponse,
1933                fidl::encoding::DefaultFuchsiaResourceDialect,
1934                0x524da8772a69056f,
1935            >(_buf?)?;
1936            Ok(_response.state)
1937        }
1938        self.client.send_query_and_decode::<ReaderWatchElementStateRequest, ElementState>(
1939            (processing_element_id,),
1940            0x524da8772a69056f,
1941            fidl::encoding::DynamicFlags::empty(),
1942            _decode,
1943        )
1944    }
1945
1946    type GetTopologiesResponseFut = fidl::client::QueryResponseFut<
1947        ReaderGetTopologiesResult,
1948        fidl::encoding::DefaultFuchsiaResourceDialect,
1949    >;
1950    fn r#get_topologies(&self) -> Self::GetTopologiesResponseFut {
1951        fn _decode(
1952            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1953        ) -> Result<ReaderGetTopologiesResult, fidl::Error> {
1954            let _response = fidl::client::decode_transaction_body::<
1955                fidl::encoding::ResultType<ReaderGetTopologiesResponse, i32>,
1956                fidl::encoding::DefaultFuchsiaResourceDialect,
1957                0x73ffb73af24d30b6,
1958            >(_buf?)?;
1959            Ok(_response.map(|x| x.topologies))
1960        }
1961        self.client
1962            .send_query_and_decode::<fidl::encoding::EmptyPayload, ReaderGetTopologiesResult>(
1963                (),
1964                0x73ffb73af24d30b6,
1965                fidl::encoding::DynamicFlags::empty(),
1966                _decode,
1967            )
1968    }
1969
1970    type WatchTopologyResponseFut =
1971        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
1972    fn r#watch_topology(&self) -> Self::WatchTopologyResponseFut {
1973        fn _decode(
1974            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1975        ) -> Result<u64, fidl::Error> {
1976            let _response = fidl::client::decode_transaction_body::<
1977                fidl::encoding::FlexibleType<ReaderWatchTopologyResponse>,
1978                fidl::encoding::DefaultFuchsiaResourceDialect,
1979                0x66d172acdb36a729,
1980            >(_buf?)?
1981            .into_result::<SignalProcessingMarker>("watch_topology")?;
1982            Ok(_response.topology_id)
1983        }
1984        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
1985            (),
1986            0x66d172acdb36a729,
1987            fidl::encoding::DynamicFlags::FLEXIBLE,
1988            _decode,
1989        )
1990    }
1991
1992    type SetTopologyResponseFut = fidl::client::QueryResponseFut<
1993        SignalProcessingSetTopologyResult,
1994        fidl::encoding::DefaultFuchsiaResourceDialect,
1995    >;
1996    fn r#set_topology(&self, mut topology_id: u64) -> Self::SetTopologyResponseFut {
1997        fn _decode(
1998            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1999        ) -> Result<SignalProcessingSetTopologyResult, fidl::Error> {
2000            let _response = fidl::client::decode_transaction_body::<
2001                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2002                fidl::encoding::DefaultFuchsiaResourceDialect,
2003                0x1d9a7f9b8fee790c,
2004            >(_buf?)?;
2005            Ok(_response.map(|x| x))
2006        }
2007        self.client.send_query_and_decode::<
2008            SignalProcessingSetTopologyRequest,
2009            SignalProcessingSetTopologyResult,
2010        >(
2011            (topology_id,),
2012            0x1d9a7f9b8fee790c,
2013            fidl::encoding::DynamicFlags::empty(),
2014            _decode,
2015        )
2016    }
2017
2018    type SetElementStateResponseFut = fidl::client::QueryResponseFut<
2019        SignalProcessingSetElementStateResult,
2020        fidl::encoding::DefaultFuchsiaResourceDialect,
2021    >;
2022    fn r#set_element_state(
2023        &self,
2024        mut processing_element_id: u64,
2025        mut state: &SettableElementState,
2026    ) -> Self::SetElementStateResponseFut {
2027        fn _decode(
2028            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2029        ) -> Result<SignalProcessingSetElementStateResult, fidl::Error> {
2030            let _response = fidl::client::decode_transaction_body::<
2031                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2032                fidl::encoding::DefaultFuchsiaResourceDialect,
2033                0x38c3b2d4bae698f4,
2034            >(_buf?)?;
2035            Ok(_response.map(|x| x))
2036        }
2037        self.client.send_query_and_decode::<
2038            SignalProcessingSetElementStateRequest,
2039            SignalProcessingSetElementStateResult,
2040        >(
2041            (processing_element_id, state,),
2042            0x38c3b2d4bae698f4,
2043            fidl::encoding::DynamicFlags::empty(),
2044            _decode,
2045        )
2046    }
2047}
2048
2049pub struct SignalProcessingEventStream {
2050    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2051}
2052
2053impl std::marker::Unpin for SignalProcessingEventStream {}
2054
2055impl futures::stream::FusedStream for SignalProcessingEventStream {
2056    fn is_terminated(&self) -> bool {
2057        self.event_receiver.is_terminated()
2058    }
2059}
2060
2061impl futures::Stream for SignalProcessingEventStream {
2062    type Item = Result<SignalProcessingEvent, fidl::Error>;
2063
2064    fn poll_next(
2065        mut self: std::pin::Pin<&mut Self>,
2066        cx: &mut std::task::Context<'_>,
2067    ) -> std::task::Poll<Option<Self::Item>> {
2068        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2069            &mut self.event_receiver,
2070            cx
2071        )?) {
2072            Some(buf) => std::task::Poll::Ready(Some(SignalProcessingEvent::decode(buf))),
2073            None => std::task::Poll::Ready(None),
2074        }
2075    }
2076}
2077
2078#[derive(Debug)]
2079pub enum SignalProcessingEvent {
2080    #[non_exhaustive]
2081    _UnknownEvent {
2082        /// Ordinal of the event that was sent.
2083        ordinal: u64,
2084    },
2085}
2086
2087impl SignalProcessingEvent {
2088    /// Decodes a message buffer as a [`SignalProcessingEvent`].
2089    fn decode(
2090        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2091    ) -> Result<SignalProcessingEvent, fidl::Error> {
2092        let (bytes, _handles) = buf.split_mut();
2093        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2094        debug_assert_eq!(tx_header.tx_id, 0);
2095        match tx_header.ordinal {
2096            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2097                Ok(SignalProcessingEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2098            }
2099            _ => Err(fidl::Error::UnknownOrdinal {
2100                ordinal: tx_header.ordinal,
2101                protocol_name:
2102                    <SignalProcessingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2103            }),
2104        }
2105    }
2106}
2107
2108/// A Stream of incoming requests for fuchsia.hardware.audio.signalprocessing/SignalProcessing.
2109pub struct SignalProcessingRequestStream {
2110    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2111    is_terminated: bool,
2112}
2113
2114impl std::marker::Unpin for SignalProcessingRequestStream {}
2115
2116impl futures::stream::FusedStream for SignalProcessingRequestStream {
2117    fn is_terminated(&self) -> bool {
2118        self.is_terminated
2119    }
2120}
2121
2122impl fidl::endpoints::RequestStream for SignalProcessingRequestStream {
2123    type Protocol = SignalProcessingMarker;
2124    type ControlHandle = SignalProcessingControlHandle;
2125
2126    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2127        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2128    }
2129
2130    fn control_handle(&self) -> Self::ControlHandle {
2131        SignalProcessingControlHandle { inner: self.inner.clone() }
2132    }
2133
2134    fn into_inner(
2135        self,
2136    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2137    {
2138        (self.inner, self.is_terminated)
2139    }
2140
2141    fn from_inner(
2142        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2143        is_terminated: bool,
2144    ) -> Self {
2145        Self { inner, is_terminated }
2146    }
2147}
2148
2149impl futures::Stream for SignalProcessingRequestStream {
2150    type Item = Result<SignalProcessingRequest, fidl::Error>;
2151
2152    fn poll_next(
2153        mut self: std::pin::Pin<&mut Self>,
2154        cx: &mut std::task::Context<'_>,
2155    ) -> std::task::Poll<Option<Self::Item>> {
2156        let this = &mut *self;
2157        if this.inner.check_shutdown(cx) {
2158            this.is_terminated = true;
2159            return std::task::Poll::Ready(None);
2160        }
2161        if this.is_terminated {
2162            panic!("polled SignalProcessingRequestStream after completion");
2163        }
2164        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2165            |bytes, handles| {
2166                match this.inner.channel().read_etc(cx, bytes, handles) {
2167                    std::task::Poll::Ready(Ok(())) => {}
2168                    std::task::Poll::Pending => return std::task::Poll::Pending,
2169                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2170                        this.is_terminated = true;
2171                        return std::task::Poll::Ready(None);
2172                    }
2173                    std::task::Poll::Ready(Err(e)) => {
2174                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2175                            e.into(),
2176                        ))))
2177                    }
2178                }
2179
2180                // A message has been received from the channel
2181                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2182
2183                std::task::Poll::Ready(Some(match header.ordinal {
2184                    0x1b14ff4adf5dc6f8 => {
2185                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2186                        let mut req = fidl::new_empty!(
2187                            fidl::encoding::EmptyPayload,
2188                            fidl::encoding::DefaultFuchsiaResourceDialect
2189                        );
2190                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2191                        let control_handle =
2192                            SignalProcessingControlHandle { inner: this.inner.clone() };
2193                        Ok(SignalProcessingRequest::GetElements {
2194                            responder: SignalProcessingGetElementsResponder {
2195                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2196                                tx_id: header.tx_id,
2197                            },
2198                        })
2199                    }
2200                    0x524da8772a69056f => {
2201                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2202                        let mut req = fidl::new_empty!(
2203                            ReaderWatchElementStateRequest,
2204                            fidl::encoding::DefaultFuchsiaResourceDialect
2205                        );
2206                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReaderWatchElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
2207                        let control_handle =
2208                            SignalProcessingControlHandle { inner: this.inner.clone() };
2209                        Ok(SignalProcessingRequest::WatchElementState {
2210                            processing_element_id: req.processing_element_id,
2211
2212                            responder: SignalProcessingWatchElementStateResponder {
2213                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2214                                tx_id: header.tx_id,
2215                            },
2216                        })
2217                    }
2218                    0x73ffb73af24d30b6 => {
2219                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2220                        let mut req = fidl::new_empty!(
2221                            fidl::encoding::EmptyPayload,
2222                            fidl::encoding::DefaultFuchsiaResourceDialect
2223                        );
2224                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2225                        let control_handle =
2226                            SignalProcessingControlHandle { inner: this.inner.clone() };
2227                        Ok(SignalProcessingRequest::GetTopologies {
2228                            responder: SignalProcessingGetTopologiesResponder {
2229                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2230                                tx_id: header.tx_id,
2231                            },
2232                        })
2233                    }
2234                    0x66d172acdb36a729 => {
2235                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2236                        let mut req = fidl::new_empty!(
2237                            fidl::encoding::EmptyPayload,
2238                            fidl::encoding::DefaultFuchsiaResourceDialect
2239                        );
2240                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2241                        let control_handle =
2242                            SignalProcessingControlHandle { inner: this.inner.clone() };
2243                        Ok(SignalProcessingRequest::WatchTopology {
2244                            responder: SignalProcessingWatchTopologyResponder {
2245                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2246                                tx_id: header.tx_id,
2247                            },
2248                        })
2249                    }
2250                    0x1d9a7f9b8fee790c => {
2251                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2252                        let mut req = fidl::new_empty!(
2253                            SignalProcessingSetTopologyRequest,
2254                            fidl::encoding::DefaultFuchsiaResourceDialect
2255                        );
2256                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SignalProcessingSetTopologyRequest>(&header, _body_bytes, handles, &mut req)?;
2257                        let control_handle =
2258                            SignalProcessingControlHandle { inner: this.inner.clone() };
2259                        Ok(SignalProcessingRequest::SetTopology {
2260                            topology_id: req.topology_id,
2261
2262                            responder: SignalProcessingSetTopologyResponder {
2263                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2264                                tx_id: header.tx_id,
2265                            },
2266                        })
2267                    }
2268                    0x38c3b2d4bae698f4 => {
2269                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2270                        let mut req = fidl::new_empty!(
2271                            SignalProcessingSetElementStateRequest,
2272                            fidl::encoding::DefaultFuchsiaResourceDialect
2273                        );
2274                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SignalProcessingSetElementStateRequest>(&header, _body_bytes, handles, &mut req)?;
2275                        let control_handle =
2276                            SignalProcessingControlHandle { inner: this.inner.clone() };
2277                        Ok(SignalProcessingRequest::SetElementState {
2278                            processing_element_id: req.processing_element_id,
2279                            state: req.state,
2280
2281                            responder: SignalProcessingSetElementStateResponder {
2282                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2283                                tx_id: header.tx_id,
2284                            },
2285                        })
2286                    }
2287                    _ if header.tx_id == 0
2288                        && header
2289                            .dynamic_flags()
2290                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2291                    {
2292                        Ok(SignalProcessingRequest::_UnknownMethod {
2293                            ordinal: header.ordinal,
2294                            control_handle: SignalProcessingControlHandle {
2295                                inner: this.inner.clone(),
2296                            },
2297                            method_type: fidl::MethodType::OneWay,
2298                        })
2299                    }
2300                    _ if header
2301                        .dynamic_flags()
2302                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2303                    {
2304                        this.inner.send_framework_err(
2305                            fidl::encoding::FrameworkErr::UnknownMethod,
2306                            header.tx_id,
2307                            header.ordinal,
2308                            header.dynamic_flags(),
2309                            (bytes, handles),
2310                        )?;
2311                        Ok(SignalProcessingRequest::_UnknownMethod {
2312                            ordinal: header.ordinal,
2313                            control_handle: SignalProcessingControlHandle {
2314                                inner: this.inner.clone(),
2315                            },
2316                            method_type: fidl::MethodType::TwoWay,
2317                        })
2318                    }
2319                    _ => Err(fidl::Error::UnknownOrdinal {
2320                        ordinal: header.ordinal,
2321                        protocol_name:
2322                            <SignalProcessingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2323                    }),
2324                }))
2325            },
2326        )
2327    }
2328}
2329
2330/// This protocol is required for Composite audio drivers, and unsupported for other audio driver
2331/// types (Codec, Dai, StreamConfig).
2332///
2333/// For an overview see
2334/// [[Signal Processing Interface]](https://fuchsia.dev/fuchsia-src/concepts/drivers/driver_architectures/audio_drivers/audio_signal_processing).
2335#[derive(Debug)]
2336pub enum SignalProcessingRequest {
2337    /// Returns a vector of supported processing elements.
2338    /// This vector must include one or more processing elements.
2339    GetElements { responder: SignalProcessingGetElementsResponder },
2340    /// Get the processing element state via a hanging get.
2341    /// For a given `processing_element_id`, the driver will immediately reply to the first
2342    /// `WatchElementState` sent by the client. The driver will not respond to subsequent client
2343    /// `WatchElementState` calls for that `processing_element_id` until any portion of the
2344    /// `ElementState` has changed from what was most recently reported for that element.
2345    ///
2346    /// The driver will close the protocol channel with an error of `ZX_ERR_INVALID_ARGS`, if
2347    /// `processing_element_id` does not match an ElementId returned by `GetElements`.
2348    ///
2349    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
2350    /// method is called again while there is already a pending `WatchElementState` for this client
2351    /// and `processing_element_id`.
2352    WatchElementState {
2353        processing_element_id: u64,
2354        responder: SignalProcessingWatchElementStateResponder,
2355    },
2356    /// Returns a vector of supported topologies.
2357    /// This vector must include one or more topologies.
2358    /// If more than one topology is returned, then the client may select any topology from the
2359    /// list by calling `SetTopology`.
2360    /// If only one topology is returned, `SetTopology` can still be called but causes no change.
2361    ///
2362    /// Each Element must be included in at least one Topology, but need not be included in every
2363    /// Topology.
2364    GetTopologies { responder: SignalProcessingGetTopologiesResponder },
2365    /// Get the current topology via a hanging get.
2366    /// The driver will immediately reply to the first `WatchTopology` sent by each client.
2367    /// The driver will not respond to subsequent `WatchTopology` calls from that client until the
2368    /// signal processing topology changes; this occurs as a result of a `SetTopology` call.
2369    ///
2370    /// The driver will close the protocol channel with an error of `ZX_ERR_BAD_STATE`, if this
2371    /// method is called again while there is already a pending `WatchTopology` for this client.
2372    WatchTopology { responder: SignalProcessingWatchTopologyResponder },
2373    /// Sets the currently active topology by specifying a `topology_id`, which matches to an entry
2374    /// in the vector returned by `GetTopologies`.
2375    /// The currently active topology is communicated by `WatchTopology` responses. To change which
2376    /// topology is active, a client uses `SetTopology`.
2377    ///
2378    /// If `GetTopologies` returns only one `Topology`, `SetTopology` is optional and has no effect.
2379    ///
2380    /// This call will fail and return `ZX_ERR_INVALID_ARGS` if the specified `topology_id` is not
2381    /// found within the`topologies` returned by `GetTopologies`.
2382    ///
2383    /// `SetTopology` may be called before or after non-`SignalProcessing` protocol calls.
2384    /// If called after non-`SignalProcessing` protocol calls, then `SetTopology` may return
2385    /// `ZX_ERR_BAD_STATE` to indicate that the operation can not proceed without renegotiation of
2386    /// the driver state. See `SetElementState` for further discussion.
2387    SetTopology { topology_id: u64, responder: SignalProcessingSetTopologyResponder },
2388    /// Controls the processing element specified by `processing_element_id`, a unique ElementId
2389    /// returned by `GetElements`.
2390    /// The `state` specified in calls to `SetElementState` is a `SettableElementState`. This is a
2391    /// subset of `ElementState` because some fields returned by `WatchElementState` (e.g. `latency`
2392    /// or `plug_state`) can only be observed (not set) by the client.
2393    ///
2394    /// Returns `ZX_ERR_INVALID_ARGS` if `processing_element_id` does not match a known ElementId
2395    /// returned by `GetElements`, or if `state` is not valid for the element. This entails any
2396    /// violation of the rules specified in this protocol.
2397    ///
2398    /// Examples:
2399    /// `state` specifies that an element should be stopped or bypassed, but the corresponding
2400    ///     element does not specify (or explicitly set to false) `can_stop` or `can_bypass`.
2401    /// `state` includes a `type_specific` entry, but that `SettableTypeSpecificElementState` does
2402    ///     not match the `ElementType` of the element corresponding to `processing_element_id`.
2403    /// `state` changes an `EqualizerBandState` for an `EQUALIZER` element (so far so good), but
2404    ///     specifies a change to `frequency` when this element did not set `CAN_CONTROL_FREQUENCY`
2405    ///     in its `supported_controls`.
2406    /// `state` specifies a `GainElementState` for a `GAIN` element with a `gain` value that is
2407    ///     -infinity, NAN, or outside the Element's stated [`min_gain`, `max_gain`] range.
2408    ///
2409    /// Callers may intersperse method calls to the `SignalProcessing` protocol with calls to other
2410    /// driver protocols. Some non-`SignalProcessing` configuration changes may require a
2411    /// renegotiation of the driver state before certain elements can receive a `SetElementState`.
2412    /// For example, if a `DaiFormat` is changed, then `SetElementState` changing an `AGL` element's
2413    /// parameters may not require renegotiation of driver state because changing gain parameters
2414    /// usually does not change the set of supported audio formats.
2415    /// By contrast, following the same `DaiFormat` change, before `SetElementState` can be called
2416    /// on a `CONNECTION_POINT` element, the driver state may need to be reestablished because the
2417    /// format change may invalidate the set of supported formats returned in a previous
2418    /// `GetDaiFormats` protocol call for another part of the Topology.
2419    ///
2420    /// It is the driver's job to determine when renegotiation is required. When this is needed,
2421    /// the related `SetElementState` call must return `ZX_ERR_BAD_STATE` and the client must
2422    /// close the protocol channel entirely, such that the protocol negotiations are started over.
2423    /// The client then must re-invoke the `SetElementState` call that returned
2424    /// `ZX_ERR_BAD_STATE` before any non-`SignalProcessing` protocol calls.
2425    SetElementState {
2426        processing_element_id: u64,
2427        state: SettableElementState,
2428        responder: SignalProcessingSetElementStateResponder,
2429    },
2430    /// An interaction was received which does not match any known method.
2431    #[non_exhaustive]
2432    _UnknownMethod {
2433        /// Ordinal of the method that was called.
2434        ordinal: u64,
2435        control_handle: SignalProcessingControlHandle,
2436        method_type: fidl::MethodType,
2437    },
2438}
2439
2440impl SignalProcessingRequest {
2441    #[allow(irrefutable_let_patterns)]
2442    pub fn into_get_elements(self) -> Option<(SignalProcessingGetElementsResponder)> {
2443        if let SignalProcessingRequest::GetElements { responder } = self {
2444            Some((responder))
2445        } else {
2446            None
2447        }
2448    }
2449
2450    #[allow(irrefutable_let_patterns)]
2451    pub fn into_watch_element_state(
2452        self,
2453    ) -> Option<(u64, SignalProcessingWatchElementStateResponder)> {
2454        if let SignalProcessingRequest::WatchElementState { processing_element_id, responder } =
2455            self
2456        {
2457            Some((processing_element_id, responder))
2458        } else {
2459            None
2460        }
2461    }
2462
2463    #[allow(irrefutable_let_patterns)]
2464    pub fn into_get_topologies(self) -> Option<(SignalProcessingGetTopologiesResponder)> {
2465        if let SignalProcessingRequest::GetTopologies { responder } = self {
2466            Some((responder))
2467        } else {
2468            None
2469        }
2470    }
2471
2472    #[allow(irrefutable_let_patterns)]
2473    pub fn into_watch_topology(self) -> Option<(SignalProcessingWatchTopologyResponder)> {
2474        if let SignalProcessingRequest::WatchTopology { responder } = self {
2475            Some((responder))
2476        } else {
2477            None
2478        }
2479    }
2480
2481    #[allow(irrefutable_let_patterns)]
2482    pub fn into_set_topology(self) -> Option<(u64, SignalProcessingSetTopologyResponder)> {
2483        if let SignalProcessingRequest::SetTopology { topology_id, responder } = self {
2484            Some((topology_id, responder))
2485        } else {
2486            None
2487        }
2488    }
2489
2490    #[allow(irrefutable_let_patterns)]
2491    pub fn into_set_element_state(
2492        self,
2493    ) -> Option<(u64, SettableElementState, SignalProcessingSetElementStateResponder)> {
2494        if let SignalProcessingRequest::SetElementState {
2495            processing_element_id,
2496            state,
2497            responder,
2498        } = self
2499        {
2500            Some((processing_element_id, state, responder))
2501        } else {
2502            None
2503        }
2504    }
2505
2506    /// Name of the method defined in FIDL
2507    pub fn method_name(&self) -> &'static str {
2508        match *self {
2509            SignalProcessingRequest::GetElements { .. } => "get_elements",
2510            SignalProcessingRequest::WatchElementState { .. } => "watch_element_state",
2511            SignalProcessingRequest::GetTopologies { .. } => "get_topologies",
2512            SignalProcessingRequest::WatchTopology { .. } => "watch_topology",
2513            SignalProcessingRequest::SetTopology { .. } => "set_topology",
2514            SignalProcessingRequest::SetElementState { .. } => "set_element_state",
2515            SignalProcessingRequest::_UnknownMethod {
2516                method_type: fidl::MethodType::OneWay,
2517                ..
2518            } => "unknown one-way method",
2519            SignalProcessingRequest::_UnknownMethod {
2520                method_type: fidl::MethodType::TwoWay,
2521                ..
2522            } => "unknown two-way method",
2523        }
2524    }
2525}
2526
2527#[derive(Debug, Clone)]
2528pub struct SignalProcessingControlHandle {
2529    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2530}
2531
2532impl fidl::endpoints::ControlHandle for SignalProcessingControlHandle {
2533    fn shutdown(&self) {
2534        self.inner.shutdown()
2535    }
2536    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2537        self.inner.shutdown_with_epitaph(status)
2538    }
2539
2540    fn is_closed(&self) -> bool {
2541        self.inner.channel().is_closed()
2542    }
2543    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2544        self.inner.channel().on_closed()
2545    }
2546
2547    #[cfg(target_os = "fuchsia")]
2548    fn signal_peer(
2549        &self,
2550        clear_mask: zx::Signals,
2551        set_mask: zx::Signals,
2552    ) -> Result<(), zx_status::Status> {
2553        use fidl::Peered;
2554        self.inner.channel().signal_peer(clear_mask, set_mask)
2555    }
2556}
2557
2558impl SignalProcessingControlHandle {}
2559
2560#[must_use = "FIDL methods require a response to be sent"]
2561#[derive(Debug)]
2562pub struct SignalProcessingGetElementsResponder {
2563    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2564    tx_id: u32,
2565}
2566
2567/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2568/// if the responder is dropped without sending a response, so that the client
2569/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2570impl std::ops::Drop for SignalProcessingGetElementsResponder {
2571    fn drop(&mut self) {
2572        self.control_handle.shutdown();
2573        // Safety: drops once, never accessed again
2574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2575    }
2576}
2577
2578impl fidl::endpoints::Responder for SignalProcessingGetElementsResponder {
2579    type ControlHandle = SignalProcessingControlHandle;
2580
2581    fn control_handle(&self) -> &SignalProcessingControlHandle {
2582        &self.control_handle
2583    }
2584
2585    fn drop_without_shutdown(mut self) {
2586        // Safety: drops once, never accessed again due to mem::forget
2587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2588        // Prevent Drop from running (which would shut down the channel)
2589        std::mem::forget(self);
2590    }
2591}
2592
2593impl SignalProcessingGetElementsResponder {
2594    /// Sends a response to the FIDL transaction.
2595    ///
2596    /// Sets the channel to shutdown if an error occurs.
2597    pub fn send(self, mut result: Result<&[Element], i32>) -> Result<(), fidl::Error> {
2598        let _result = self.send_raw(result);
2599        if _result.is_err() {
2600            self.control_handle.shutdown();
2601        }
2602        self.drop_without_shutdown();
2603        _result
2604    }
2605
2606    /// Similar to "send" but does not shutdown the channel if an error occurs.
2607    pub fn send_no_shutdown_on_err(
2608        self,
2609        mut result: Result<&[Element], i32>,
2610    ) -> Result<(), fidl::Error> {
2611        let _result = self.send_raw(result);
2612        self.drop_without_shutdown();
2613        _result
2614    }
2615
2616    fn send_raw(&self, mut result: Result<&[Element], i32>) -> Result<(), fidl::Error> {
2617        self.control_handle
2618            .inner
2619            .send::<fidl::encoding::ResultType<ReaderGetElementsResponse, i32>>(
2620                result.map(|processing_elements| (processing_elements,)),
2621                self.tx_id,
2622                0x1b14ff4adf5dc6f8,
2623                fidl::encoding::DynamicFlags::empty(),
2624            )
2625    }
2626}
2627
2628#[must_use = "FIDL methods require a response to be sent"]
2629#[derive(Debug)]
2630pub struct SignalProcessingWatchElementStateResponder {
2631    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2632    tx_id: u32,
2633}
2634
2635/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2636/// if the responder is dropped without sending a response, so that the client
2637/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2638impl std::ops::Drop for SignalProcessingWatchElementStateResponder {
2639    fn drop(&mut self) {
2640        self.control_handle.shutdown();
2641        // Safety: drops once, never accessed again
2642        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2643    }
2644}
2645
2646impl fidl::endpoints::Responder for SignalProcessingWatchElementStateResponder {
2647    type ControlHandle = SignalProcessingControlHandle;
2648
2649    fn control_handle(&self) -> &SignalProcessingControlHandle {
2650        &self.control_handle
2651    }
2652
2653    fn drop_without_shutdown(mut self) {
2654        // Safety: drops once, never accessed again due to mem::forget
2655        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2656        // Prevent Drop from running (which would shut down the channel)
2657        std::mem::forget(self);
2658    }
2659}
2660
2661impl SignalProcessingWatchElementStateResponder {
2662    /// Sends a response to the FIDL transaction.
2663    ///
2664    /// Sets the channel to shutdown if an error occurs.
2665    pub fn send(self, mut state: &ElementState) -> Result<(), fidl::Error> {
2666        let _result = self.send_raw(state);
2667        if _result.is_err() {
2668            self.control_handle.shutdown();
2669        }
2670        self.drop_without_shutdown();
2671        _result
2672    }
2673
2674    /// Similar to "send" but does not shutdown the channel if an error occurs.
2675    pub fn send_no_shutdown_on_err(self, mut state: &ElementState) -> Result<(), fidl::Error> {
2676        let _result = self.send_raw(state);
2677        self.drop_without_shutdown();
2678        _result
2679    }
2680
2681    fn send_raw(&self, mut state: &ElementState) -> Result<(), fidl::Error> {
2682        self.control_handle.inner.send::<ReaderWatchElementStateResponse>(
2683            (state,),
2684            self.tx_id,
2685            0x524da8772a69056f,
2686            fidl::encoding::DynamicFlags::empty(),
2687        )
2688    }
2689}
2690
2691#[must_use = "FIDL methods require a response to be sent"]
2692#[derive(Debug)]
2693pub struct SignalProcessingGetTopologiesResponder {
2694    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2695    tx_id: u32,
2696}
2697
2698/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2699/// if the responder is dropped without sending a response, so that the client
2700/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2701impl std::ops::Drop for SignalProcessingGetTopologiesResponder {
2702    fn drop(&mut self) {
2703        self.control_handle.shutdown();
2704        // Safety: drops once, never accessed again
2705        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2706    }
2707}
2708
2709impl fidl::endpoints::Responder for SignalProcessingGetTopologiesResponder {
2710    type ControlHandle = SignalProcessingControlHandle;
2711
2712    fn control_handle(&self) -> &SignalProcessingControlHandle {
2713        &self.control_handle
2714    }
2715
2716    fn drop_without_shutdown(mut self) {
2717        // Safety: drops once, never accessed again due to mem::forget
2718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2719        // Prevent Drop from running (which would shut down the channel)
2720        std::mem::forget(self);
2721    }
2722}
2723
2724impl SignalProcessingGetTopologiesResponder {
2725    /// Sends a response to the FIDL transaction.
2726    ///
2727    /// Sets the channel to shutdown if an error occurs.
2728    pub fn send(self, mut result: Result<&[Topology], i32>) -> Result<(), fidl::Error> {
2729        let _result = self.send_raw(result);
2730        if _result.is_err() {
2731            self.control_handle.shutdown();
2732        }
2733        self.drop_without_shutdown();
2734        _result
2735    }
2736
2737    /// Similar to "send" but does not shutdown the channel if an error occurs.
2738    pub fn send_no_shutdown_on_err(
2739        self,
2740        mut result: Result<&[Topology], i32>,
2741    ) -> Result<(), fidl::Error> {
2742        let _result = self.send_raw(result);
2743        self.drop_without_shutdown();
2744        _result
2745    }
2746
2747    fn send_raw(&self, mut result: Result<&[Topology], i32>) -> Result<(), fidl::Error> {
2748        self.control_handle
2749            .inner
2750            .send::<fidl::encoding::ResultType<ReaderGetTopologiesResponse, i32>>(
2751                result.map(|topologies| (topologies,)),
2752                self.tx_id,
2753                0x73ffb73af24d30b6,
2754                fidl::encoding::DynamicFlags::empty(),
2755            )
2756    }
2757}
2758
2759#[must_use = "FIDL methods require a response to be sent"]
2760#[derive(Debug)]
2761pub struct SignalProcessingWatchTopologyResponder {
2762    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2763    tx_id: u32,
2764}
2765
2766/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2767/// if the responder is dropped without sending a response, so that the client
2768/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2769impl std::ops::Drop for SignalProcessingWatchTopologyResponder {
2770    fn drop(&mut self) {
2771        self.control_handle.shutdown();
2772        // Safety: drops once, never accessed again
2773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2774    }
2775}
2776
2777impl fidl::endpoints::Responder for SignalProcessingWatchTopologyResponder {
2778    type ControlHandle = SignalProcessingControlHandle;
2779
2780    fn control_handle(&self) -> &SignalProcessingControlHandle {
2781        &self.control_handle
2782    }
2783
2784    fn drop_without_shutdown(mut self) {
2785        // Safety: drops once, never accessed again due to mem::forget
2786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2787        // Prevent Drop from running (which would shut down the channel)
2788        std::mem::forget(self);
2789    }
2790}
2791
2792impl SignalProcessingWatchTopologyResponder {
2793    /// Sends a response to the FIDL transaction.
2794    ///
2795    /// Sets the channel to shutdown if an error occurs.
2796    pub fn send(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2797        let _result = self.send_raw(topology_id);
2798        if _result.is_err() {
2799            self.control_handle.shutdown();
2800        }
2801        self.drop_without_shutdown();
2802        _result
2803    }
2804
2805    /// Similar to "send" but does not shutdown the channel if an error occurs.
2806    pub fn send_no_shutdown_on_err(self, mut topology_id: u64) -> Result<(), fidl::Error> {
2807        let _result = self.send_raw(topology_id);
2808        self.drop_without_shutdown();
2809        _result
2810    }
2811
2812    fn send_raw(&self, mut topology_id: u64) -> Result<(), fidl::Error> {
2813        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ReaderWatchTopologyResponse>>(
2814            fidl::encoding::Flexible::new((topology_id,)),
2815            self.tx_id,
2816            0x66d172acdb36a729,
2817            fidl::encoding::DynamicFlags::FLEXIBLE,
2818        )
2819    }
2820}
2821
2822#[must_use = "FIDL methods require a response to be sent"]
2823#[derive(Debug)]
2824pub struct SignalProcessingSetTopologyResponder {
2825    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2826    tx_id: u32,
2827}
2828
2829/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2830/// if the responder is dropped without sending a response, so that the client
2831/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2832impl std::ops::Drop for SignalProcessingSetTopologyResponder {
2833    fn drop(&mut self) {
2834        self.control_handle.shutdown();
2835        // Safety: drops once, never accessed again
2836        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2837    }
2838}
2839
2840impl fidl::endpoints::Responder for SignalProcessingSetTopologyResponder {
2841    type ControlHandle = SignalProcessingControlHandle;
2842
2843    fn control_handle(&self) -> &SignalProcessingControlHandle {
2844        &self.control_handle
2845    }
2846
2847    fn drop_without_shutdown(mut self) {
2848        // Safety: drops once, never accessed again due to mem::forget
2849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2850        // Prevent Drop from running (which would shut down the channel)
2851        std::mem::forget(self);
2852    }
2853}
2854
2855impl SignalProcessingSetTopologyResponder {
2856    /// Sends a response to the FIDL transaction.
2857    ///
2858    /// Sets the channel to shutdown if an error occurs.
2859    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2860        let _result = self.send_raw(result);
2861        if _result.is_err() {
2862            self.control_handle.shutdown();
2863        }
2864        self.drop_without_shutdown();
2865        _result
2866    }
2867
2868    /// Similar to "send" but does not shutdown the channel if an error occurs.
2869    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2870        let _result = self.send_raw(result);
2871        self.drop_without_shutdown();
2872        _result
2873    }
2874
2875    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2876        self.control_handle
2877            .inner
2878            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2879                result,
2880                self.tx_id,
2881                0x1d9a7f9b8fee790c,
2882                fidl::encoding::DynamicFlags::empty(),
2883            )
2884    }
2885}
2886
2887#[must_use = "FIDL methods require a response to be sent"]
2888#[derive(Debug)]
2889pub struct SignalProcessingSetElementStateResponder {
2890    control_handle: std::mem::ManuallyDrop<SignalProcessingControlHandle>,
2891    tx_id: u32,
2892}
2893
2894/// Set the the channel to be shutdown (see [`SignalProcessingControlHandle::shutdown`])
2895/// if the responder is dropped without sending a response, so that the client
2896/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2897impl std::ops::Drop for SignalProcessingSetElementStateResponder {
2898    fn drop(&mut self) {
2899        self.control_handle.shutdown();
2900        // Safety: drops once, never accessed again
2901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2902    }
2903}
2904
2905impl fidl::endpoints::Responder for SignalProcessingSetElementStateResponder {
2906    type ControlHandle = SignalProcessingControlHandle;
2907
2908    fn control_handle(&self) -> &SignalProcessingControlHandle {
2909        &self.control_handle
2910    }
2911
2912    fn drop_without_shutdown(mut self) {
2913        // Safety: drops once, never accessed again due to mem::forget
2914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2915        // Prevent Drop from running (which would shut down the channel)
2916        std::mem::forget(self);
2917    }
2918}
2919
2920impl SignalProcessingSetElementStateResponder {
2921    /// Sends a response to the FIDL transaction.
2922    ///
2923    /// Sets the channel to shutdown if an error occurs.
2924    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2925        let _result = self.send_raw(result);
2926        if _result.is_err() {
2927            self.control_handle.shutdown();
2928        }
2929        self.drop_without_shutdown();
2930        _result
2931    }
2932
2933    /// Similar to "send" but does not shutdown the channel if an error occurs.
2934    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2935        let _result = self.send_raw(result);
2936        self.drop_without_shutdown();
2937        _result
2938    }
2939
2940    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2941        self.control_handle
2942            .inner
2943            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2944                result,
2945                self.tx_id,
2946                0x38c3b2d4bae698f4,
2947                fidl::encoding::DynamicFlags::empty(),
2948            )
2949    }
2950}
2951
2952#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2953pub struct ConnectorServiceMarker;
2954
2955#[cfg(target_os = "fuchsia")]
2956impl fidl::endpoints::ServiceMarker for ConnectorServiceMarker {
2957    type Proxy = ConnectorServiceProxy;
2958    type Request = ConnectorServiceRequest;
2959    const SERVICE_NAME: &'static str = "fuchsia.hardware.audio.signalprocessing.ConnectorService";
2960}
2961
2962/// A request for one of the member protocols of ConnectorService.
2963///
2964#[cfg(target_os = "fuchsia")]
2965pub enum ConnectorServiceRequest {
2966    Connector(ConnectorRequestStream),
2967}
2968
2969#[cfg(target_os = "fuchsia")]
2970impl fidl::endpoints::ServiceRequest for ConnectorServiceRequest {
2971    type Service = ConnectorServiceMarker;
2972
2973    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2974        match name {
2975            "connector" => Self::Connector(
2976                <ConnectorRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2977            ),
2978            _ => panic!("no such member protocol name for service ConnectorService"),
2979        }
2980    }
2981
2982    fn member_names() -> &'static [&'static str] {
2983        &["connector"]
2984    }
2985}
2986#[cfg(target_os = "fuchsia")]
2987pub struct ConnectorServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2988
2989#[cfg(target_os = "fuchsia")]
2990impl fidl::endpoints::ServiceProxy for ConnectorServiceProxy {
2991    type Service = ConnectorServiceMarker;
2992
2993    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2994        Self(opener)
2995    }
2996}
2997
2998#[cfg(target_os = "fuchsia")]
2999impl ConnectorServiceProxy {
3000    pub fn connect_to_connector(&self) -> Result<ConnectorProxy, fidl::Error> {
3001        let (proxy, server_end) = fidl::endpoints::create_proxy::<ConnectorMarker>();
3002        self.connect_channel_to_connector(server_end)?;
3003        Ok(proxy)
3004    }
3005
3006    /// Like `connect_to_connector`, but returns a sync proxy.
3007    /// See [`Self::connect_to_connector`] for more details.
3008    pub fn connect_to_connector_sync(&self) -> Result<ConnectorSynchronousProxy, fidl::Error> {
3009        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ConnectorMarker>();
3010        self.connect_channel_to_connector(server_end)?;
3011        Ok(proxy)
3012    }
3013
3014    /// Like `connect_to_connector`, but accepts a server end.
3015    /// See [`Self::connect_to_connector`] for more details.
3016    pub fn connect_channel_to_connector(
3017        &self,
3018        server_end: fidl::endpoints::ServerEnd<ConnectorMarker>,
3019    ) -> Result<(), fidl::Error> {
3020        self.0.open_member("connector", server_end.into_channel())
3021    }
3022
3023    pub fn instance_name(&self) -> &str {
3024        self.0.instance_name()
3025    }
3026}
3027
3028mod internal {
3029    use super::*;
3030
3031    impl fidl::encoding::ResourceTypeMarker for ConnectorSignalProcessingConnectRequest {
3032        type Borrowed<'a> = &'a mut Self;
3033        fn take_or_borrow<'a>(
3034            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3035        ) -> Self::Borrowed<'a> {
3036            value
3037        }
3038    }
3039
3040    unsafe impl fidl::encoding::TypeMarker for ConnectorSignalProcessingConnectRequest {
3041        type Owned = Self;
3042
3043        #[inline(always)]
3044        fn inline_align(_context: fidl::encoding::Context) -> usize {
3045            4
3046        }
3047
3048        #[inline(always)]
3049        fn inline_size(_context: fidl::encoding::Context) -> usize {
3050            4
3051        }
3052    }
3053
3054    unsafe impl
3055        fidl::encoding::Encode<
3056            ConnectorSignalProcessingConnectRequest,
3057            fidl::encoding::DefaultFuchsiaResourceDialect,
3058        > for &mut ConnectorSignalProcessingConnectRequest
3059    {
3060        #[inline]
3061        unsafe fn encode(
3062            self,
3063            encoder: &mut fidl::encoding::Encoder<
3064                '_,
3065                fidl::encoding::DefaultFuchsiaResourceDialect,
3066            >,
3067            offset: usize,
3068            _depth: fidl::encoding::Depth,
3069        ) -> fidl::Result<()> {
3070            encoder.debug_check_bounds::<ConnectorSignalProcessingConnectRequest>(offset);
3071            // Delegate to tuple encoding.
3072            fidl::encoding::Encode::<ConnectorSignalProcessingConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3073                (
3074                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SignalProcessingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.protocol),
3075                ),
3076                encoder, offset, _depth
3077            )
3078        }
3079    }
3080    unsafe impl<
3081            T0: fidl::encoding::Encode<
3082                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SignalProcessingMarker>>,
3083                fidl::encoding::DefaultFuchsiaResourceDialect,
3084            >,
3085        >
3086        fidl::encoding::Encode<
3087            ConnectorSignalProcessingConnectRequest,
3088            fidl::encoding::DefaultFuchsiaResourceDialect,
3089        > for (T0,)
3090    {
3091        #[inline]
3092        unsafe fn encode(
3093            self,
3094            encoder: &mut fidl::encoding::Encoder<
3095                '_,
3096                fidl::encoding::DefaultFuchsiaResourceDialect,
3097            >,
3098            offset: usize,
3099            depth: fidl::encoding::Depth,
3100        ) -> fidl::Result<()> {
3101            encoder.debug_check_bounds::<ConnectorSignalProcessingConnectRequest>(offset);
3102            // Zero out padding regions. There's no need to apply masks
3103            // because the unmasked parts will be overwritten by fields.
3104            // Write the fields.
3105            self.0.encode(encoder, offset + 0, depth)?;
3106            Ok(())
3107        }
3108    }
3109
3110    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3111        for ConnectorSignalProcessingConnectRequest
3112    {
3113        #[inline(always)]
3114        fn new_empty() -> Self {
3115            Self {
3116                protocol: fidl::new_empty!(
3117                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SignalProcessingMarker>>,
3118                    fidl::encoding::DefaultFuchsiaResourceDialect
3119                ),
3120            }
3121        }
3122
3123        #[inline]
3124        unsafe fn decode(
3125            &mut self,
3126            decoder: &mut fidl::encoding::Decoder<
3127                '_,
3128                fidl::encoding::DefaultFuchsiaResourceDialect,
3129            >,
3130            offset: usize,
3131            _depth: fidl::encoding::Depth,
3132        ) -> fidl::Result<()> {
3133            decoder.debug_check_bounds::<Self>(offset);
3134            // Verify that padding bytes are zero.
3135            fidl::decode!(
3136                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SignalProcessingMarker>>,
3137                fidl::encoding::DefaultFuchsiaResourceDialect,
3138                &mut self.protocol,
3139                decoder,
3140                offset + 0,
3141                _depth
3142            )?;
3143            Ok(())
3144        }
3145    }
3146}