Skip to main content

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