fidl_fuchsia_hardware_audio_signalprocessing/
fidl_fuchsia_hardware_audio_signalprocessing.rs

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