fidl_fuchsia_hardware_qcom_hvdcpopti/
fidl_fuchsia_hardware_qcom_hvdcpopti.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_qcom_hvdcpopti__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct BatteryMarker;
16
17impl fidl::endpoints::ProtocolMarker for BatteryMarker {
18    type Proxy = BatteryProxy;
19    type RequestStream = BatteryRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = BatterySynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Battery";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for BatteryMarker {}
26pub type BatteryGetBatteryProfileResult = Result<[u8; 596], i32>;
27
28pub trait BatteryProxyInterface: Send + Sync {
29    type GetBatteryConfigResponseFut: std::future::Future<Output = Result<[u8; 304], fidl::Error>>
30        + Send;
31    fn r#get_battery_config(&self) -> Self::GetBatteryConfigResponseFut;
32    type GetBatteryProfileResponseFut: std::future::Future<Output = Result<BatteryGetBatteryProfileResult, fidl::Error>>
33        + Send;
34    fn r#get_battery_profile(&self, request: &[u8; 8]) -> Self::GetBatteryProfileResponseFut;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct BatterySynchronousProxy {
39    client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for BatterySynchronousProxy {
44    type Proxy = BatteryProxy;
45    type Protocol = BatteryMarker;
46
47    fn from_channel(inner: fidl::Channel) -> Self {
48        Self::new(inner)
49    }
50
51    fn into_channel(self) -> fidl::Channel {
52        self.client.into_channel()
53    }
54
55    fn as_channel(&self) -> &fidl::Channel {
56        self.client.as_channel()
57    }
58}
59
60#[cfg(target_os = "fuchsia")]
61impl BatterySynchronousProxy {
62    pub fn new(channel: fidl::Channel) -> Self {
63        let protocol_name = <BatteryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
64        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
65    }
66
67    pub fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    /// Waits until an event arrives and returns it. It is safe for other
72    /// threads to make concurrent requests while waiting for an event.
73    pub fn wait_for_event(
74        &self,
75        deadline: zx::MonotonicInstant,
76    ) -> Result<BatteryEvent, fidl::Error> {
77        BatteryEvent::decode(self.client.wait_for_event(deadline)?)
78    }
79
80    pub fn r#get_battery_config(
81        &self,
82        ___deadline: zx::MonotonicInstant,
83    ) -> Result<[u8; 304], fidl::Error> {
84        let _response = self
85            .client
86            .send_query::<fidl::encoding::EmptyPayload, BatteryGetBatteryConfigResponse>(
87                (),
88                0x393e949a2c548044,
89                fidl::encoding::DynamicFlags::empty(),
90                ___deadline,
91            )?;
92        Ok(_response.config)
93    }
94
95    pub fn r#get_battery_profile(
96        &self,
97        mut request: &[u8; 8],
98        ___deadline: zx::MonotonicInstant,
99    ) -> Result<BatteryGetBatteryProfileResult, fidl::Error> {
100        let _response = self.client.send_query::<
101            BatteryGetBatteryProfileRequest,
102            fidl::encoding::ResultType<BatteryGetBatteryProfileResponse, i32>,
103        >(
104            (request,),
105            0x48ee727ade37c43b,
106            fidl::encoding::DynamicFlags::empty(),
107            ___deadline,
108        )?;
109        Ok(_response.map(|x| x.profile))
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl From<BatterySynchronousProxy> for zx::Handle {
115    fn from(value: BatterySynchronousProxy) -> Self {
116        value.into_channel().into()
117    }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl From<fidl::Channel> for BatterySynchronousProxy {
122    fn from(value: fidl::Channel) -> Self {
123        Self::new(value)
124    }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl fidl::endpoints::FromClient for BatterySynchronousProxy {
129    type Protocol = BatteryMarker;
130
131    fn from_client(value: fidl::endpoints::ClientEnd<BatteryMarker>) -> Self {
132        Self::new(value.into_channel())
133    }
134}
135
136#[derive(Debug, Clone)]
137pub struct BatteryProxy {
138    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
139}
140
141impl fidl::endpoints::Proxy for BatteryProxy {
142    type Protocol = BatteryMarker;
143
144    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
145        Self::new(inner)
146    }
147
148    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
149        self.client.into_channel().map_err(|client| Self { client })
150    }
151
152    fn as_channel(&self) -> &::fidl::AsyncChannel {
153        self.client.as_channel()
154    }
155}
156
157impl BatteryProxy {
158    /// Create a new Proxy for fuchsia.hardware.qcom.hvdcpopti/Battery.
159    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
160        let protocol_name = <BatteryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
161        Self { client: fidl::client::Client::new(channel, protocol_name) }
162    }
163
164    /// Get a Stream of events from the remote end of the protocol.
165    ///
166    /// # Panics
167    ///
168    /// Panics if the event stream was already taken.
169    pub fn take_event_stream(&self) -> BatteryEventStream {
170        BatteryEventStream { event_receiver: self.client.take_event_receiver() }
171    }
172
173    pub fn r#get_battery_config(
174        &self,
175    ) -> fidl::client::QueryResponseFut<[u8; 304], fidl::encoding::DefaultFuchsiaResourceDialect>
176    {
177        BatteryProxyInterface::r#get_battery_config(self)
178    }
179
180    pub fn r#get_battery_profile(
181        &self,
182        mut request: &[u8; 8],
183    ) -> fidl::client::QueryResponseFut<
184        BatteryGetBatteryProfileResult,
185        fidl::encoding::DefaultFuchsiaResourceDialect,
186    > {
187        BatteryProxyInterface::r#get_battery_profile(self, request)
188    }
189}
190
191impl BatteryProxyInterface for BatteryProxy {
192    type GetBatteryConfigResponseFut =
193        fidl::client::QueryResponseFut<[u8; 304], fidl::encoding::DefaultFuchsiaResourceDialect>;
194    fn r#get_battery_config(&self) -> Self::GetBatteryConfigResponseFut {
195        fn _decode(
196            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
197        ) -> Result<[u8; 304], fidl::Error> {
198            let _response = fidl::client::decode_transaction_body::<
199                BatteryGetBatteryConfigResponse,
200                fidl::encoding::DefaultFuchsiaResourceDialect,
201                0x393e949a2c548044,
202            >(_buf?)?;
203            Ok(_response.config)
204        }
205        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 304]>(
206            (),
207            0x393e949a2c548044,
208            fidl::encoding::DynamicFlags::empty(),
209            _decode,
210        )
211    }
212
213    type GetBatteryProfileResponseFut = fidl::client::QueryResponseFut<
214        BatteryGetBatteryProfileResult,
215        fidl::encoding::DefaultFuchsiaResourceDialect,
216    >;
217    fn r#get_battery_profile(&self, mut request: &[u8; 8]) -> Self::GetBatteryProfileResponseFut {
218        fn _decode(
219            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
220        ) -> Result<BatteryGetBatteryProfileResult, fidl::Error> {
221            let _response = fidl::client::decode_transaction_body::<
222                fidl::encoding::ResultType<BatteryGetBatteryProfileResponse, i32>,
223                fidl::encoding::DefaultFuchsiaResourceDialect,
224                0x48ee727ade37c43b,
225            >(_buf?)?;
226            Ok(_response.map(|x| x.profile))
227        }
228        self.client.send_query_and_decode::<
229            BatteryGetBatteryProfileRequest,
230            BatteryGetBatteryProfileResult,
231        >(
232            (request,),
233            0x48ee727ade37c43b,
234            fidl::encoding::DynamicFlags::empty(),
235            _decode,
236        )
237    }
238}
239
240pub struct BatteryEventStream {
241    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
242}
243
244impl std::marker::Unpin for BatteryEventStream {}
245
246impl futures::stream::FusedStream for BatteryEventStream {
247    fn is_terminated(&self) -> bool {
248        self.event_receiver.is_terminated()
249    }
250}
251
252impl futures::Stream for BatteryEventStream {
253    type Item = Result<BatteryEvent, fidl::Error>;
254
255    fn poll_next(
256        mut self: std::pin::Pin<&mut Self>,
257        cx: &mut std::task::Context<'_>,
258    ) -> std::task::Poll<Option<Self::Item>> {
259        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
260            &mut self.event_receiver,
261            cx
262        )?) {
263            Some(buf) => std::task::Poll::Ready(Some(BatteryEvent::decode(buf))),
264            None => std::task::Poll::Ready(None),
265        }
266    }
267}
268
269#[derive(Debug)]
270pub enum BatteryEvent {}
271
272impl BatteryEvent {
273    /// Decodes a message buffer as a [`BatteryEvent`].
274    fn decode(
275        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
276    ) -> Result<BatteryEvent, fidl::Error> {
277        let (bytes, _handles) = buf.split_mut();
278        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
279        debug_assert_eq!(tx_header.tx_id, 0);
280        match tx_header.ordinal {
281            _ => Err(fidl::Error::UnknownOrdinal {
282                ordinal: tx_header.ordinal,
283                protocol_name: <BatteryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
284            }),
285        }
286    }
287}
288
289/// A Stream of incoming requests for fuchsia.hardware.qcom.hvdcpopti/Battery.
290pub struct BatteryRequestStream {
291    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
292    is_terminated: bool,
293}
294
295impl std::marker::Unpin for BatteryRequestStream {}
296
297impl futures::stream::FusedStream for BatteryRequestStream {
298    fn is_terminated(&self) -> bool {
299        self.is_terminated
300    }
301}
302
303impl fidl::endpoints::RequestStream for BatteryRequestStream {
304    type Protocol = BatteryMarker;
305    type ControlHandle = BatteryControlHandle;
306
307    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
308        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
309    }
310
311    fn control_handle(&self) -> Self::ControlHandle {
312        BatteryControlHandle { inner: self.inner.clone() }
313    }
314
315    fn into_inner(
316        self,
317    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
318    {
319        (self.inner, self.is_terminated)
320    }
321
322    fn from_inner(
323        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
324        is_terminated: bool,
325    ) -> Self {
326        Self { inner, is_terminated }
327    }
328}
329
330impl futures::Stream for BatteryRequestStream {
331    type Item = Result<BatteryRequest, fidl::Error>;
332
333    fn poll_next(
334        mut self: std::pin::Pin<&mut Self>,
335        cx: &mut std::task::Context<'_>,
336    ) -> std::task::Poll<Option<Self::Item>> {
337        let this = &mut *self;
338        if this.inner.check_shutdown(cx) {
339            this.is_terminated = true;
340            return std::task::Poll::Ready(None);
341        }
342        if this.is_terminated {
343            panic!("polled BatteryRequestStream after completion");
344        }
345        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
346            |bytes, handles| {
347                match this.inner.channel().read_etc(cx, bytes, handles) {
348                    std::task::Poll::Ready(Ok(())) => {}
349                    std::task::Poll::Pending => return std::task::Poll::Pending,
350                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
351                        this.is_terminated = true;
352                        return std::task::Poll::Ready(None);
353                    }
354                    std::task::Poll::Ready(Err(e)) => {
355                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
356                            e.into(),
357                        ))));
358                    }
359                }
360
361                // A message has been received from the channel
362                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
363
364                std::task::Poll::Ready(Some(match header.ordinal {
365                    0x393e949a2c548044 => {
366                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
367                        let mut req = fidl::new_empty!(
368                            fidl::encoding::EmptyPayload,
369                            fidl::encoding::DefaultFuchsiaResourceDialect
370                        );
371                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
372                        let control_handle = BatteryControlHandle { inner: this.inner.clone() };
373                        Ok(BatteryRequest::GetBatteryConfig {
374                            responder: BatteryGetBatteryConfigResponder {
375                                control_handle: std::mem::ManuallyDrop::new(control_handle),
376                                tx_id: header.tx_id,
377                            },
378                        })
379                    }
380                    0x48ee727ade37c43b => {
381                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
382                        let mut req = fidl::new_empty!(
383                            BatteryGetBatteryProfileRequest,
384                            fidl::encoding::DefaultFuchsiaResourceDialect
385                        );
386                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryGetBatteryProfileRequest>(&header, _body_bytes, handles, &mut req)?;
387                        let control_handle = BatteryControlHandle { inner: this.inner.clone() };
388                        Ok(BatteryRequest::GetBatteryProfile {
389                            request: req.request,
390
391                            responder: BatteryGetBatteryProfileResponder {
392                                control_handle: std::mem::ManuallyDrop::new(control_handle),
393                                tx_id: header.tx_id,
394                            },
395                        })
396                    }
397                    _ => Err(fidl::Error::UnknownOrdinal {
398                        ordinal: header.ordinal,
399                        protocol_name:
400                            <BatteryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
401                    }),
402                }))
403            },
404        )
405    }
406}
407
408#[derive(Debug)]
409pub enum BatteryRequest {
410    GetBatteryConfig { responder: BatteryGetBatteryConfigResponder },
411    GetBatteryProfile { request: [u8; 8], responder: BatteryGetBatteryProfileResponder },
412}
413
414impl BatteryRequest {
415    #[allow(irrefutable_let_patterns)]
416    pub fn into_get_battery_config(self) -> Option<(BatteryGetBatteryConfigResponder)> {
417        if let BatteryRequest::GetBatteryConfig { responder } = self {
418            Some((responder))
419        } else {
420            None
421        }
422    }
423
424    #[allow(irrefutable_let_patterns)]
425    pub fn into_get_battery_profile(self) -> Option<([u8; 8], BatteryGetBatteryProfileResponder)> {
426        if let BatteryRequest::GetBatteryProfile { request, responder } = self {
427            Some((request, responder))
428        } else {
429            None
430        }
431    }
432
433    /// Name of the method defined in FIDL
434    pub fn method_name(&self) -> &'static str {
435        match *self {
436            BatteryRequest::GetBatteryConfig { .. } => "get_battery_config",
437            BatteryRequest::GetBatteryProfile { .. } => "get_battery_profile",
438        }
439    }
440}
441
442#[derive(Debug, Clone)]
443pub struct BatteryControlHandle {
444    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
445}
446
447impl fidl::endpoints::ControlHandle for BatteryControlHandle {
448    fn shutdown(&self) {
449        self.inner.shutdown()
450    }
451    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
452        self.inner.shutdown_with_epitaph(status)
453    }
454
455    fn is_closed(&self) -> bool {
456        self.inner.channel().is_closed()
457    }
458    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
459        self.inner.channel().on_closed()
460    }
461
462    #[cfg(target_os = "fuchsia")]
463    fn signal_peer(
464        &self,
465        clear_mask: zx::Signals,
466        set_mask: zx::Signals,
467    ) -> Result<(), zx_status::Status> {
468        use fidl::Peered;
469        self.inner.channel().signal_peer(clear_mask, set_mask)
470    }
471}
472
473impl BatteryControlHandle {}
474
475#[must_use = "FIDL methods require a response to be sent"]
476#[derive(Debug)]
477pub struct BatteryGetBatteryConfigResponder {
478    control_handle: std::mem::ManuallyDrop<BatteryControlHandle>,
479    tx_id: u32,
480}
481
482/// Set the the channel to be shutdown (see [`BatteryControlHandle::shutdown`])
483/// if the responder is dropped without sending a response, so that the client
484/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
485impl std::ops::Drop for BatteryGetBatteryConfigResponder {
486    fn drop(&mut self) {
487        self.control_handle.shutdown();
488        // Safety: drops once, never accessed again
489        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
490    }
491}
492
493impl fidl::endpoints::Responder for BatteryGetBatteryConfigResponder {
494    type ControlHandle = BatteryControlHandle;
495
496    fn control_handle(&self) -> &BatteryControlHandle {
497        &self.control_handle
498    }
499
500    fn drop_without_shutdown(mut self) {
501        // Safety: drops once, never accessed again due to mem::forget
502        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
503        // Prevent Drop from running (which would shut down the channel)
504        std::mem::forget(self);
505    }
506}
507
508impl BatteryGetBatteryConfigResponder {
509    /// Sends a response to the FIDL transaction.
510    ///
511    /// Sets the channel to shutdown if an error occurs.
512    pub fn send(self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
513        let _result = self.send_raw(config);
514        if _result.is_err() {
515            self.control_handle.shutdown();
516        }
517        self.drop_without_shutdown();
518        _result
519    }
520
521    /// Similar to "send" but does not shutdown the channel if an error occurs.
522    pub fn send_no_shutdown_on_err(self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
523        let _result = self.send_raw(config);
524        self.drop_without_shutdown();
525        _result
526    }
527
528    fn send_raw(&self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
529        self.control_handle.inner.send::<BatteryGetBatteryConfigResponse>(
530            (config,),
531            self.tx_id,
532            0x393e949a2c548044,
533            fidl::encoding::DynamicFlags::empty(),
534        )
535    }
536}
537
538#[must_use = "FIDL methods require a response to be sent"]
539#[derive(Debug)]
540pub struct BatteryGetBatteryProfileResponder {
541    control_handle: std::mem::ManuallyDrop<BatteryControlHandle>,
542    tx_id: u32,
543}
544
545/// Set the the channel to be shutdown (see [`BatteryControlHandle::shutdown`])
546/// if the responder is dropped without sending a response, so that the client
547/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
548impl std::ops::Drop for BatteryGetBatteryProfileResponder {
549    fn drop(&mut self) {
550        self.control_handle.shutdown();
551        // Safety: drops once, never accessed again
552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553    }
554}
555
556impl fidl::endpoints::Responder for BatteryGetBatteryProfileResponder {
557    type ControlHandle = BatteryControlHandle;
558
559    fn control_handle(&self) -> &BatteryControlHandle {
560        &self.control_handle
561    }
562
563    fn drop_without_shutdown(mut self) {
564        // Safety: drops once, never accessed again due to mem::forget
565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566        // Prevent Drop from running (which would shut down the channel)
567        std::mem::forget(self);
568    }
569}
570
571impl BatteryGetBatteryProfileResponder {
572    /// Sends a response to the FIDL transaction.
573    ///
574    /// Sets the channel to shutdown if an error occurs.
575    pub fn send(self, mut result: Result<&[u8; 596], i32>) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(result);
577        if _result.is_err() {
578            self.control_handle.shutdown();
579        }
580        self.drop_without_shutdown();
581        _result
582    }
583
584    /// Similar to "send" but does not shutdown the channel if an error occurs.
585    pub fn send_no_shutdown_on_err(
586        self,
587        mut result: Result<&[u8; 596], i32>,
588    ) -> Result<(), fidl::Error> {
589        let _result = self.send_raw(result);
590        self.drop_without_shutdown();
591        _result
592    }
593
594    fn send_raw(&self, mut result: Result<&[u8; 596], i32>) -> Result<(), fidl::Error> {
595        self.control_handle
596            .inner
597            .send::<fidl::encoding::ResultType<BatteryGetBatteryProfileResponse, i32>>(
598                result.map(|profile| (profile,)),
599                self.tx_id,
600                0x48ee727ade37c43b,
601                fidl::encoding::DynamicFlags::empty(),
602            )
603    }
604}
605
606#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
607pub struct DeviceMarker;
608
609impl fidl::endpoints::ProtocolMarker for DeviceMarker {
610    type Proxy = DeviceProxy;
611    type RequestStream = DeviceRequestStream;
612    #[cfg(target_os = "fuchsia")]
613    type SynchronousProxy = DeviceSynchronousProxy;
614
615    const DEBUG_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Device";
616}
617impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
618pub type DeviceGetEssentialParamsResult = Result<[u8; 48], i32>;
619pub type DeviceSetEssentialParamsResult = Result<(), i32>;
620
621pub trait DeviceProxyInterface: Send + Sync {
622    type GetEssentialParamsResponseFut: std::future::Future<Output = Result<DeviceGetEssentialParamsResult, fidl::Error>>
623        + Send;
624    fn r#get_essential_params(&self) -> Self::GetEssentialParamsResponseFut;
625    type SetEssentialParamsResponseFut: std::future::Future<Output = Result<DeviceSetEssentialParamsResult, fidl::Error>>
626        + Send;
627    fn r#set_essential_params(&self, params: &[u8; 48]) -> Self::SetEssentialParamsResponseFut;
628    type GetConfigResponseFut: std::future::Future<Output = Result<[u8; 104], fidl::Error>> + Send;
629    fn r#get_config(&self) -> Self::GetConfigResponseFut;
630    type SetProcessedFifoDataResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
631        + Send;
632    fn r#set_processed_fifo_data(&self, data: &[u8; 152]) -> Self::SetProcessedFifoDataResponseFut;
633    type GetStepAndJeitaParamsResponseFut: std::future::Future<Output = Result<[u8; 247], fidl::Error>>
634        + Send;
635    fn r#get_step_and_jeita_params(&self) -> Self::GetStepAndJeitaParamsResponseFut;
636}
637#[derive(Debug)]
638#[cfg(target_os = "fuchsia")]
639pub struct DeviceSynchronousProxy {
640    client: fidl::client::sync::Client,
641}
642
643#[cfg(target_os = "fuchsia")]
644impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
645    type Proxy = DeviceProxy;
646    type Protocol = DeviceMarker;
647
648    fn from_channel(inner: fidl::Channel) -> Self {
649        Self::new(inner)
650    }
651
652    fn into_channel(self) -> fidl::Channel {
653        self.client.into_channel()
654    }
655
656    fn as_channel(&self) -> &fidl::Channel {
657        self.client.as_channel()
658    }
659}
660
661#[cfg(target_os = "fuchsia")]
662impl DeviceSynchronousProxy {
663    pub fn new(channel: fidl::Channel) -> Self {
664        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
665        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
666    }
667
668    pub fn into_channel(self) -> fidl::Channel {
669        self.client.into_channel()
670    }
671
672    /// Waits until an event arrives and returns it. It is safe for other
673    /// threads to make concurrent requests while waiting for an event.
674    pub fn wait_for_event(
675        &self,
676        deadline: zx::MonotonicInstant,
677    ) -> Result<DeviceEvent, fidl::Error> {
678        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
679    }
680
681    pub fn r#get_essential_params(
682        &self,
683        ___deadline: zx::MonotonicInstant,
684    ) -> Result<DeviceGetEssentialParamsResult, fidl::Error> {
685        let _response = self.client.send_query::<
686            fidl::encoding::EmptyPayload,
687            fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>,
688        >(
689            (),
690            0x2093fd296e2d8996,
691            fidl::encoding::DynamicFlags::empty(),
692            ___deadline,
693        )?;
694        Ok(_response.map(|x| x.params))
695    }
696
697    pub fn r#set_essential_params(
698        &self,
699        mut params: &[u8; 48],
700        ___deadline: zx::MonotonicInstant,
701    ) -> Result<DeviceSetEssentialParamsResult, fidl::Error> {
702        let _response = self.client.send_query::<
703            DeviceSetEssentialParamsRequest,
704            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
705        >(
706            (params,),
707            0x55b14f267312168c,
708            fidl::encoding::DynamicFlags::empty(),
709            ___deadline,
710        )?;
711        Ok(_response.map(|x| x))
712    }
713
714    pub fn r#get_config(
715        &self,
716        ___deadline: zx::MonotonicInstant,
717    ) -> Result<[u8; 104], fidl::Error> {
718        let _response =
719            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetConfigResponse>(
720                (),
721                0x41a72f916b11e11f,
722                fidl::encoding::DynamicFlags::empty(),
723                ___deadline,
724            )?;
725        Ok(_response.config)
726    }
727
728    pub fn r#set_processed_fifo_data(
729        &self,
730        mut data: &[u8; 152],
731        ___deadline: zx::MonotonicInstant,
732    ) -> Result<(), fidl::Error> {
733        let _response = self
734            .client
735            .send_query::<DeviceSetProcessedFifoDataRequest, fidl::encoding::EmptyPayload>(
736                (data,),
737                0x4689e121bf9e884,
738                fidl::encoding::DynamicFlags::empty(),
739                ___deadline,
740            )?;
741        Ok(_response)
742    }
743
744    pub fn r#get_step_and_jeita_params(
745        &self,
746        ___deadline: zx::MonotonicInstant,
747    ) -> Result<[u8; 247], fidl::Error> {
748        let _response = self
749            .client
750            .send_query::<fidl::encoding::EmptyPayload, DeviceGetStepAndJeitaParamsResponse>(
751                (),
752                0x1c7ba411ae13b250,
753                fidl::encoding::DynamicFlags::empty(),
754                ___deadline,
755            )?;
756        Ok(_response.params)
757    }
758}
759
760#[cfg(target_os = "fuchsia")]
761impl From<DeviceSynchronousProxy> for zx::Handle {
762    fn from(value: DeviceSynchronousProxy) -> Self {
763        value.into_channel().into()
764    }
765}
766
767#[cfg(target_os = "fuchsia")]
768impl From<fidl::Channel> for DeviceSynchronousProxy {
769    fn from(value: fidl::Channel) -> Self {
770        Self::new(value)
771    }
772}
773
774#[cfg(target_os = "fuchsia")]
775impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
776    type Protocol = DeviceMarker;
777
778    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
779        Self::new(value.into_channel())
780    }
781}
782
783#[derive(Debug, Clone)]
784pub struct DeviceProxy {
785    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
786}
787
788impl fidl::endpoints::Proxy for DeviceProxy {
789    type Protocol = DeviceMarker;
790
791    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
792        Self::new(inner)
793    }
794
795    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
796        self.client.into_channel().map_err(|client| Self { client })
797    }
798
799    fn as_channel(&self) -> &::fidl::AsyncChannel {
800        self.client.as_channel()
801    }
802}
803
804impl DeviceProxy {
805    /// Create a new Proxy for fuchsia.hardware.qcom.hvdcpopti/Device.
806    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
807        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
808        Self { client: fidl::client::Client::new(channel, protocol_name) }
809    }
810
811    /// Get a Stream of events from the remote end of the protocol.
812    ///
813    /// # Panics
814    ///
815    /// Panics if the event stream was already taken.
816    pub fn take_event_stream(&self) -> DeviceEventStream {
817        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
818    }
819
820    pub fn r#get_essential_params(
821        &self,
822    ) -> fidl::client::QueryResponseFut<
823        DeviceGetEssentialParamsResult,
824        fidl::encoding::DefaultFuchsiaResourceDialect,
825    > {
826        DeviceProxyInterface::r#get_essential_params(self)
827    }
828
829    pub fn r#set_essential_params(
830        &self,
831        mut params: &[u8; 48],
832    ) -> fidl::client::QueryResponseFut<
833        DeviceSetEssentialParamsResult,
834        fidl::encoding::DefaultFuchsiaResourceDialect,
835    > {
836        DeviceProxyInterface::r#set_essential_params(self, params)
837    }
838
839    pub fn r#get_config(
840        &self,
841    ) -> fidl::client::QueryResponseFut<[u8; 104], fidl::encoding::DefaultFuchsiaResourceDialect>
842    {
843        DeviceProxyInterface::r#get_config(self)
844    }
845
846    pub fn r#set_processed_fifo_data(
847        &self,
848        mut data: &[u8; 152],
849    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
850        DeviceProxyInterface::r#set_processed_fifo_data(self, data)
851    }
852
853    pub fn r#get_step_and_jeita_params(
854        &self,
855    ) -> fidl::client::QueryResponseFut<[u8; 247], fidl::encoding::DefaultFuchsiaResourceDialect>
856    {
857        DeviceProxyInterface::r#get_step_and_jeita_params(self)
858    }
859}
860
861impl DeviceProxyInterface for DeviceProxy {
862    type GetEssentialParamsResponseFut = fidl::client::QueryResponseFut<
863        DeviceGetEssentialParamsResult,
864        fidl::encoding::DefaultFuchsiaResourceDialect,
865    >;
866    fn r#get_essential_params(&self) -> Self::GetEssentialParamsResponseFut {
867        fn _decode(
868            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
869        ) -> Result<DeviceGetEssentialParamsResult, fidl::Error> {
870            let _response = fidl::client::decode_transaction_body::<
871                fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>,
872                fidl::encoding::DefaultFuchsiaResourceDialect,
873                0x2093fd296e2d8996,
874            >(_buf?)?;
875            Ok(_response.map(|x| x.params))
876        }
877        self.client
878            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetEssentialParamsResult>(
879                (),
880                0x2093fd296e2d8996,
881                fidl::encoding::DynamicFlags::empty(),
882                _decode,
883            )
884    }
885
886    type SetEssentialParamsResponseFut = fidl::client::QueryResponseFut<
887        DeviceSetEssentialParamsResult,
888        fidl::encoding::DefaultFuchsiaResourceDialect,
889    >;
890    fn r#set_essential_params(&self, mut params: &[u8; 48]) -> Self::SetEssentialParamsResponseFut {
891        fn _decode(
892            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
893        ) -> Result<DeviceSetEssentialParamsResult, fidl::Error> {
894            let _response = fidl::client::decode_transaction_body::<
895                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
896                fidl::encoding::DefaultFuchsiaResourceDialect,
897                0x55b14f267312168c,
898            >(_buf?)?;
899            Ok(_response.map(|x| x))
900        }
901        self.client.send_query_and_decode::<
902            DeviceSetEssentialParamsRequest,
903            DeviceSetEssentialParamsResult,
904        >(
905            (params,),
906            0x55b14f267312168c,
907            fidl::encoding::DynamicFlags::empty(),
908            _decode,
909        )
910    }
911
912    type GetConfigResponseFut =
913        fidl::client::QueryResponseFut<[u8; 104], fidl::encoding::DefaultFuchsiaResourceDialect>;
914    fn r#get_config(&self) -> Self::GetConfigResponseFut {
915        fn _decode(
916            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
917        ) -> Result<[u8; 104], fidl::Error> {
918            let _response = fidl::client::decode_transaction_body::<
919                DeviceGetConfigResponse,
920                fidl::encoding::DefaultFuchsiaResourceDialect,
921                0x41a72f916b11e11f,
922            >(_buf?)?;
923            Ok(_response.config)
924        }
925        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 104]>(
926            (),
927            0x41a72f916b11e11f,
928            fidl::encoding::DynamicFlags::empty(),
929            _decode,
930        )
931    }
932
933    type SetProcessedFifoDataResponseFut =
934        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
935    fn r#set_processed_fifo_data(
936        &self,
937        mut data: &[u8; 152],
938    ) -> Self::SetProcessedFifoDataResponseFut {
939        fn _decode(
940            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
941        ) -> Result<(), fidl::Error> {
942            let _response = fidl::client::decode_transaction_body::<
943                fidl::encoding::EmptyPayload,
944                fidl::encoding::DefaultFuchsiaResourceDialect,
945                0x4689e121bf9e884,
946            >(_buf?)?;
947            Ok(_response)
948        }
949        self.client.send_query_and_decode::<DeviceSetProcessedFifoDataRequest, ()>(
950            (data,),
951            0x4689e121bf9e884,
952            fidl::encoding::DynamicFlags::empty(),
953            _decode,
954        )
955    }
956
957    type GetStepAndJeitaParamsResponseFut =
958        fidl::client::QueryResponseFut<[u8; 247], fidl::encoding::DefaultFuchsiaResourceDialect>;
959    fn r#get_step_and_jeita_params(&self) -> Self::GetStepAndJeitaParamsResponseFut {
960        fn _decode(
961            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
962        ) -> Result<[u8; 247], fidl::Error> {
963            let _response = fidl::client::decode_transaction_body::<
964                DeviceGetStepAndJeitaParamsResponse,
965                fidl::encoding::DefaultFuchsiaResourceDialect,
966                0x1c7ba411ae13b250,
967            >(_buf?)?;
968            Ok(_response.params)
969        }
970        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 247]>(
971            (),
972            0x1c7ba411ae13b250,
973            fidl::encoding::DynamicFlags::empty(),
974            _decode,
975        )
976    }
977}
978
979pub struct DeviceEventStream {
980    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
981}
982
983impl std::marker::Unpin for DeviceEventStream {}
984
985impl futures::stream::FusedStream for DeviceEventStream {
986    fn is_terminated(&self) -> bool {
987        self.event_receiver.is_terminated()
988    }
989}
990
991impl futures::Stream for DeviceEventStream {
992    type Item = Result<DeviceEvent, fidl::Error>;
993
994    fn poll_next(
995        mut self: std::pin::Pin<&mut Self>,
996        cx: &mut std::task::Context<'_>,
997    ) -> std::task::Poll<Option<Self::Item>> {
998        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
999            &mut self.event_receiver,
1000            cx
1001        )?) {
1002            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1003            None => std::task::Poll::Ready(None),
1004        }
1005    }
1006}
1007
1008#[derive(Debug)]
1009pub enum DeviceEvent {
1010    OnFifoData { data: Vec<u8> },
1011}
1012
1013impl DeviceEvent {
1014    #[allow(irrefutable_let_patterns)]
1015    pub fn into_on_fifo_data(self) -> Option<Vec<u8>> {
1016        if let DeviceEvent::OnFifoData { data } = self { Some((data)) } else { None }
1017    }
1018
1019    /// Decodes a message buffer as a [`DeviceEvent`].
1020    fn decode(
1021        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1022    ) -> Result<DeviceEvent, fidl::Error> {
1023        let (bytes, _handles) = buf.split_mut();
1024        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1025        debug_assert_eq!(tx_header.tx_id, 0);
1026        match tx_header.ordinal {
1027            0x79aa05363cb0b4c7 => {
1028                let mut out = fidl::new_empty!(
1029                    DeviceOnFifoDataRequest,
1030                    fidl::encoding::DefaultFuchsiaResourceDialect
1031                );
1032                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnFifoDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1033                Ok((DeviceEvent::OnFifoData { data: out.data }))
1034            }
1035            _ => Err(fidl::Error::UnknownOrdinal {
1036                ordinal: tx_header.ordinal,
1037                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1038            }),
1039        }
1040    }
1041}
1042
1043/// A Stream of incoming requests for fuchsia.hardware.qcom.hvdcpopti/Device.
1044pub struct DeviceRequestStream {
1045    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1046    is_terminated: bool,
1047}
1048
1049impl std::marker::Unpin for DeviceRequestStream {}
1050
1051impl futures::stream::FusedStream for DeviceRequestStream {
1052    fn is_terminated(&self) -> bool {
1053        self.is_terminated
1054    }
1055}
1056
1057impl fidl::endpoints::RequestStream for DeviceRequestStream {
1058    type Protocol = DeviceMarker;
1059    type ControlHandle = DeviceControlHandle;
1060
1061    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1062        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1063    }
1064
1065    fn control_handle(&self) -> Self::ControlHandle {
1066        DeviceControlHandle { inner: self.inner.clone() }
1067    }
1068
1069    fn into_inner(
1070        self,
1071    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1072    {
1073        (self.inner, self.is_terminated)
1074    }
1075
1076    fn from_inner(
1077        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1078        is_terminated: bool,
1079    ) -> Self {
1080        Self { inner, is_terminated }
1081    }
1082}
1083
1084impl futures::Stream for DeviceRequestStream {
1085    type Item = Result<DeviceRequest, fidl::Error>;
1086
1087    fn poll_next(
1088        mut self: std::pin::Pin<&mut Self>,
1089        cx: &mut std::task::Context<'_>,
1090    ) -> std::task::Poll<Option<Self::Item>> {
1091        let this = &mut *self;
1092        if this.inner.check_shutdown(cx) {
1093            this.is_terminated = true;
1094            return std::task::Poll::Ready(None);
1095        }
1096        if this.is_terminated {
1097            panic!("polled DeviceRequestStream after completion");
1098        }
1099        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1100            |bytes, handles| {
1101                match this.inner.channel().read_etc(cx, bytes, handles) {
1102                    std::task::Poll::Ready(Ok(())) => {}
1103                    std::task::Poll::Pending => return std::task::Poll::Pending,
1104                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1105                        this.is_terminated = true;
1106                        return std::task::Poll::Ready(None);
1107                    }
1108                    std::task::Poll::Ready(Err(e)) => {
1109                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1110                            e.into(),
1111                        ))));
1112                    }
1113                }
1114
1115                // A message has been received from the channel
1116                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1117
1118                std::task::Poll::Ready(Some(match header.ordinal {
1119                    0x2093fd296e2d8996 => {
1120                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1121                        let mut req = fidl::new_empty!(
1122                            fidl::encoding::EmptyPayload,
1123                            fidl::encoding::DefaultFuchsiaResourceDialect
1124                        );
1125                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1126                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1127                        Ok(DeviceRequest::GetEssentialParams {
1128                            responder: DeviceGetEssentialParamsResponder {
1129                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1130                                tx_id: header.tx_id,
1131                            },
1132                        })
1133                    }
1134                    0x55b14f267312168c => {
1135                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1136                        let mut req = fidl::new_empty!(
1137                            DeviceSetEssentialParamsRequest,
1138                            fidl::encoding::DefaultFuchsiaResourceDialect
1139                        );
1140                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetEssentialParamsRequest>(&header, _body_bytes, handles, &mut req)?;
1141                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1142                        Ok(DeviceRequest::SetEssentialParams {
1143                            params: req.params,
1144
1145                            responder: DeviceSetEssentialParamsResponder {
1146                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1147                                tx_id: header.tx_id,
1148                            },
1149                        })
1150                    }
1151                    0x41a72f916b11e11f => {
1152                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1153                        let mut req = fidl::new_empty!(
1154                            fidl::encoding::EmptyPayload,
1155                            fidl::encoding::DefaultFuchsiaResourceDialect
1156                        );
1157                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1158                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1159                        Ok(DeviceRequest::GetConfig {
1160                            responder: DeviceGetConfigResponder {
1161                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1162                                tx_id: header.tx_id,
1163                            },
1164                        })
1165                    }
1166                    0x4689e121bf9e884 => {
1167                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1168                        let mut req = fidl::new_empty!(
1169                            DeviceSetProcessedFifoDataRequest,
1170                            fidl::encoding::DefaultFuchsiaResourceDialect
1171                        );
1172                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetProcessedFifoDataRequest>(&header, _body_bytes, handles, &mut req)?;
1173                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1174                        Ok(DeviceRequest::SetProcessedFifoData {
1175                            data: req.data,
1176
1177                            responder: DeviceSetProcessedFifoDataResponder {
1178                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1179                                tx_id: header.tx_id,
1180                            },
1181                        })
1182                    }
1183                    0x1c7ba411ae13b250 => {
1184                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1185                        let mut req = fidl::new_empty!(
1186                            fidl::encoding::EmptyPayload,
1187                            fidl::encoding::DefaultFuchsiaResourceDialect
1188                        );
1189                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1190                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1191                        Ok(DeviceRequest::GetStepAndJeitaParams {
1192                            responder: DeviceGetStepAndJeitaParamsResponder {
1193                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1194                                tx_id: header.tx_id,
1195                            },
1196                        })
1197                    }
1198                    _ => Err(fidl::Error::UnknownOrdinal {
1199                        ordinal: header.ordinal,
1200                        protocol_name:
1201                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1202                    }),
1203                }))
1204            },
1205        )
1206    }
1207}
1208
1209/// Used by driver to interface with Starnix and speak to the hvdcp_opti daemon.
1210#[derive(Debug)]
1211pub enum DeviceRequest {
1212    GetEssentialParams { responder: DeviceGetEssentialParamsResponder },
1213    SetEssentialParams { params: [u8; 48], responder: DeviceSetEssentialParamsResponder },
1214    GetConfig { responder: DeviceGetConfigResponder },
1215    SetProcessedFifoData { data: [u8; 152], responder: DeviceSetProcessedFifoDataResponder },
1216    GetStepAndJeitaParams { responder: DeviceGetStepAndJeitaParamsResponder },
1217}
1218
1219impl DeviceRequest {
1220    #[allow(irrefutable_let_patterns)]
1221    pub fn into_get_essential_params(self) -> Option<(DeviceGetEssentialParamsResponder)> {
1222        if let DeviceRequest::GetEssentialParams { responder } = self {
1223            Some((responder))
1224        } else {
1225            None
1226        }
1227    }
1228
1229    #[allow(irrefutable_let_patterns)]
1230    pub fn into_set_essential_params(
1231        self,
1232    ) -> Option<([u8; 48], DeviceSetEssentialParamsResponder)> {
1233        if let DeviceRequest::SetEssentialParams { params, responder } = self {
1234            Some((params, responder))
1235        } else {
1236            None
1237        }
1238    }
1239
1240    #[allow(irrefutable_let_patterns)]
1241    pub fn into_get_config(self) -> Option<(DeviceGetConfigResponder)> {
1242        if let DeviceRequest::GetConfig { responder } = self { Some((responder)) } else { None }
1243    }
1244
1245    #[allow(irrefutable_let_patterns)]
1246    pub fn into_set_processed_fifo_data(
1247        self,
1248    ) -> Option<([u8; 152], DeviceSetProcessedFifoDataResponder)> {
1249        if let DeviceRequest::SetProcessedFifoData { data, responder } = self {
1250            Some((data, responder))
1251        } else {
1252            None
1253        }
1254    }
1255
1256    #[allow(irrefutable_let_patterns)]
1257    pub fn into_get_step_and_jeita_params(self) -> Option<(DeviceGetStepAndJeitaParamsResponder)> {
1258        if let DeviceRequest::GetStepAndJeitaParams { responder } = self {
1259            Some((responder))
1260        } else {
1261            None
1262        }
1263    }
1264
1265    /// Name of the method defined in FIDL
1266    pub fn method_name(&self) -> &'static str {
1267        match *self {
1268            DeviceRequest::GetEssentialParams { .. } => "get_essential_params",
1269            DeviceRequest::SetEssentialParams { .. } => "set_essential_params",
1270            DeviceRequest::GetConfig { .. } => "get_config",
1271            DeviceRequest::SetProcessedFifoData { .. } => "set_processed_fifo_data",
1272            DeviceRequest::GetStepAndJeitaParams { .. } => "get_step_and_jeita_params",
1273        }
1274    }
1275}
1276
1277#[derive(Debug, Clone)]
1278pub struct DeviceControlHandle {
1279    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1280}
1281
1282impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1283    fn shutdown(&self) {
1284        self.inner.shutdown()
1285    }
1286    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1287        self.inner.shutdown_with_epitaph(status)
1288    }
1289
1290    fn is_closed(&self) -> bool {
1291        self.inner.channel().is_closed()
1292    }
1293    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1294        self.inner.channel().on_closed()
1295    }
1296
1297    #[cfg(target_os = "fuchsia")]
1298    fn signal_peer(
1299        &self,
1300        clear_mask: zx::Signals,
1301        set_mask: zx::Signals,
1302    ) -> Result<(), zx_status::Status> {
1303        use fidl::Peered;
1304        self.inner.channel().signal_peer(clear_mask, set_mask)
1305    }
1306}
1307
1308impl DeviceControlHandle {
1309    pub fn send_on_fifo_data(&self, mut data: &[u8]) -> Result<(), fidl::Error> {
1310        self.inner.send::<DeviceOnFifoDataRequest>(
1311            (data,),
1312            0,
1313            0x79aa05363cb0b4c7,
1314            fidl::encoding::DynamicFlags::empty(),
1315        )
1316    }
1317}
1318
1319#[must_use = "FIDL methods require a response to be sent"]
1320#[derive(Debug)]
1321pub struct DeviceGetEssentialParamsResponder {
1322    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1323    tx_id: u32,
1324}
1325
1326/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1327/// if the responder is dropped without sending a response, so that the client
1328/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1329impl std::ops::Drop for DeviceGetEssentialParamsResponder {
1330    fn drop(&mut self) {
1331        self.control_handle.shutdown();
1332        // Safety: drops once, never accessed again
1333        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1334    }
1335}
1336
1337impl fidl::endpoints::Responder for DeviceGetEssentialParamsResponder {
1338    type ControlHandle = DeviceControlHandle;
1339
1340    fn control_handle(&self) -> &DeviceControlHandle {
1341        &self.control_handle
1342    }
1343
1344    fn drop_without_shutdown(mut self) {
1345        // Safety: drops once, never accessed again due to mem::forget
1346        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1347        // Prevent Drop from running (which would shut down the channel)
1348        std::mem::forget(self);
1349    }
1350}
1351
1352impl DeviceGetEssentialParamsResponder {
1353    /// Sends a response to the FIDL transaction.
1354    ///
1355    /// Sets the channel to shutdown if an error occurs.
1356    pub fn send(self, mut result: Result<&[u8; 48], i32>) -> Result<(), fidl::Error> {
1357        let _result = self.send_raw(result);
1358        if _result.is_err() {
1359            self.control_handle.shutdown();
1360        }
1361        self.drop_without_shutdown();
1362        _result
1363    }
1364
1365    /// Similar to "send" but does not shutdown the channel if an error occurs.
1366    pub fn send_no_shutdown_on_err(
1367        self,
1368        mut result: Result<&[u8; 48], i32>,
1369    ) -> Result<(), fidl::Error> {
1370        let _result = self.send_raw(result);
1371        self.drop_without_shutdown();
1372        _result
1373    }
1374
1375    fn send_raw(&self, mut result: Result<&[u8; 48], i32>) -> Result<(), fidl::Error> {
1376        self.control_handle
1377            .inner
1378            .send::<fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>>(
1379                result.map(|params| (params,)),
1380                self.tx_id,
1381                0x2093fd296e2d8996,
1382                fidl::encoding::DynamicFlags::empty(),
1383            )
1384    }
1385}
1386
1387#[must_use = "FIDL methods require a response to be sent"]
1388#[derive(Debug)]
1389pub struct DeviceSetEssentialParamsResponder {
1390    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1391    tx_id: u32,
1392}
1393
1394/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1395/// if the responder is dropped without sending a response, so that the client
1396/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1397impl std::ops::Drop for DeviceSetEssentialParamsResponder {
1398    fn drop(&mut self) {
1399        self.control_handle.shutdown();
1400        // Safety: drops once, never accessed again
1401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1402    }
1403}
1404
1405impl fidl::endpoints::Responder for DeviceSetEssentialParamsResponder {
1406    type ControlHandle = DeviceControlHandle;
1407
1408    fn control_handle(&self) -> &DeviceControlHandle {
1409        &self.control_handle
1410    }
1411
1412    fn drop_without_shutdown(mut self) {
1413        // Safety: drops once, never accessed again due to mem::forget
1414        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1415        // Prevent Drop from running (which would shut down the channel)
1416        std::mem::forget(self);
1417    }
1418}
1419
1420impl DeviceSetEssentialParamsResponder {
1421    /// Sends a response to the FIDL transaction.
1422    ///
1423    /// Sets the channel to shutdown if an error occurs.
1424    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1425        let _result = self.send_raw(result);
1426        if _result.is_err() {
1427            self.control_handle.shutdown();
1428        }
1429        self.drop_without_shutdown();
1430        _result
1431    }
1432
1433    /// Similar to "send" but does not shutdown the channel if an error occurs.
1434    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1435        let _result = self.send_raw(result);
1436        self.drop_without_shutdown();
1437        _result
1438    }
1439
1440    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1441        self.control_handle
1442            .inner
1443            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1444                result,
1445                self.tx_id,
1446                0x55b14f267312168c,
1447                fidl::encoding::DynamicFlags::empty(),
1448            )
1449    }
1450}
1451
1452#[must_use = "FIDL methods require a response to be sent"]
1453#[derive(Debug)]
1454pub struct DeviceGetConfigResponder {
1455    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1456    tx_id: u32,
1457}
1458
1459/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1460/// if the responder is dropped without sending a response, so that the client
1461/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1462impl std::ops::Drop for DeviceGetConfigResponder {
1463    fn drop(&mut self) {
1464        self.control_handle.shutdown();
1465        // Safety: drops once, never accessed again
1466        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1467    }
1468}
1469
1470impl fidl::endpoints::Responder for DeviceGetConfigResponder {
1471    type ControlHandle = DeviceControlHandle;
1472
1473    fn control_handle(&self) -> &DeviceControlHandle {
1474        &self.control_handle
1475    }
1476
1477    fn drop_without_shutdown(mut self) {
1478        // Safety: drops once, never accessed again due to mem::forget
1479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1480        // Prevent Drop from running (which would shut down the channel)
1481        std::mem::forget(self);
1482    }
1483}
1484
1485impl DeviceGetConfigResponder {
1486    /// Sends a response to the FIDL transaction.
1487    ///
1488    /// Sets the channel to shutdown if an error occurs.
1489    pub fn send(self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1490        let _result = self.send_raw(config);
1491        if _result.is_err() {
1492            self.control_handle.shutdown();
1493        }
1494        self.drop_without_shutdown();
1495        _result
1496    }
1497
1498    /// Similar to "send" but does not shutdown the channel if an error occurs.
1499    pub fn send_no_shutdown_on_err(self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1500        let _result = self.send_raw(config);
1501        self.drop_without_shutdown();
1502        _result
1503    }
1504
1505    fn send_raw(&self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1506        self.control_handle.inner.send::<DeviceGetConfigResponse>(
1507            (config,),
1508            self.tx_id,
1509            0x41a72f916b11e11f,
1510            fidl::encoding::DynamicFlags::empty(),
1511        )
1512    }
1513}
1514
1515#[must_use = "FIDL methods require a response to be sent"]
1516#[derive(Debug)]
1517pub struct DeviceSetProcessedFifoDataResponder {
1518    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1519    tx_id: u32,
1520}
1521
1522/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1523/// if the responder is dropped without sending a response, so that the client
1524/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1525impl std::ops::Drop for DeviceSetProcessedFifoDataResponder {
1526    fn drop(&mut self) {
1527        self.control_handle.shutdown();
1528        // Safety: drops once, never accessed again
1529        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1530    }
1531}
1532
1533impl fidl::endpoints::Responder for DeviceSetProcessedFifoDataResponder {
1534    type ControlHandle = DeviceControlHandle;
1535
1536    fn control_handle(&self) -> &DeviceControlHandle {
1537        &self.control_handle
1538    }
1539
1540    fn drop_without_shutdown(mut self) {
1541        // Safety: drops once, never accessed again due to mem::forget
1542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1543        // Prevent Drop from running (which would shut down the channel)
1544        std::mem::forget(self);
1545    }
1546}
1547
1548impl DeviceSetProcessedFifoDataResponder {
1549    /// Sends a response to the FIDL transaction.
1550    ///
1551    /// Sets the channel to shutdown if an error occurs.
1552    pub fn send(self) -> Result<(), fidl::Error> {
1553        let _result = self.send_raw();
1554        if _result.is_err() {
1555            self.control_handle.shutdown();
1556        }
1557        self.drop_without_shutdown();
1558        _result
1559    }
1560
1561    /// Similar to "send" but does not shutdown the channel if an error occurs.
1562    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1563        let _result = self.send_raw();
1564        self.drop_without_shutdown();
1565        _result
1566    }
1567
1568    fn send_raw(&self) -> Result<(), fidl::Error> {
1569        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1570            (),
1571            self.tx_id,
1572            0x4689e121bf9e884,
1573            fidl::encoding::DynamicFlags::empty(),
1574        )
1575    }
1576}
1577
1578#[must_use = "FIDL methods require a response to be sent"]
1579#[derive(Debug)]
1580pub struct DeviceGetStepAndJeitaParamsResponder {
1581    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1582    tx_id: u32,
1583}
1584
1585/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1586/// if the responder is dropped without sending a response, so that the client
1587/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1588impl std::ops::Drop for DeviceGetStepAndJeitaParamsResponder {
1589    fn drop(&mut self) {
1590        self.control_handle.shutdown();
1591        // Safety: drops once, never accessed again
1592        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1593    }
1594}
1595
1596impl fidl::endpoints::Responder for DeviceGetStepAndJeitaParamsResponder {
1597    type ControlHandle = DeviceControlHandle;
1598
1599    fn control_handle(&self) -> &DeviceControlHandle {
1600        &self.control_handle
1601    }
1602
1603    fn drop_without_shutdown(mut self) {
1604        // Safety: drops once, never accessed again due to mem::forget
1605        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1606        // Prevent Drop from running (which would shut down the channel)
1607        std::mem::forget(self);
1608    }
1609}
1610
1611impl DeviceGetStepAndJeitaParamsResponder {
1612    /// Sends a response to the FIDL transaction.
1613    ///
1614    /// Sets the channel to shutdown if an error occurs.
1615    pub fn send(self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1616        let _result = self.send_raw(params);
1617        if _result.is_err() {
1618            self.control_handle.shutdown();
1619        }
1620        self.drop_without_shutdown();
1621        _result
1622    }
1623
1624    /// Similar to "send" but does not shutdown the channel if an error occurs.
1625    pub fn send_no_shutdown_on_err(self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1626        let _result = self.send_raw(params);
1627        self.drop_without_shutdown();
1628        _result
1629    }
1630
1631    fn send_raw(&self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1632        self.control_handle.inner.send::<DeviceGetStepAndJeitaParamsResponse>(
1633            (params,),
1634            self.tx_id,
1635            0x1c7ba411ae13b250,
1636            fidl::encoding::DynamicFlags::empty(),
1637        )
1638    }
1639}
1640
1641#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1642pub struct IioMarker;
1643
1644impl fidl::endpoints::ProtocolMarker for IioMarker {
1645    type Proxy = IioProxy;
1646    type RequestStream = IioRequestStream;
1647    #[cfg(target_os = "fuchsia")]
1648    type SynchronousProxy = IioSynchronousProxy;
1649
1650    const DEBUG_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Iio";
1651}
1652impl fidl::endpoints::DiscoverableProtocolMarker for IioMarker {}
1653pub type IioGetIioValueResult = Result<i32, i32>;
1654
1655pub trait IioProxyInterface: Send + Sync {
1656    type GetIioValueResponseFut: std::future::Future<Output = Result<IioGetIioValueResult, fidl::Error>>
1657        + Send;
1658    fn r#get_iio_value(&self, label: &str) -> Self::GetIioValueResponseFut;
1659}
1660#[derive(Debug)]
1661#[cfg(target_os = "fuchsia")]
1662pub struct IioSynchronousProxy {
1663    client: fidl::client::sync::Client,
1664}
1665
1666#[cfg(target_os = "fuchsia")]
1667impl fidl::endpoints::SynchronousProxy for IioSynchronousProxy {
1668    type Proxy = IioProxy;
1669    type Protocol = IioMarker;
1670
1671    fn from_channel(inner: fidl::Channel) -> Self {
1672        Self::new(inner)
1673    }
1674
1675    fn into_channel(self) -> fidl::Channel {
1676        self.client.into_channel()
1677    }
1678
1679    fn as_channel(&self) -> &fidl::Channel {
1680        self.client.as_channel()
1681    }
1682}
1683
1684#[cfg(target_os = "fuchsia")]
1685impl IioSynchronousProxy {
1686    pub fn new(channel: fidl::Channel) -> Self {
1687        let protocol_name = <IioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1688        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1689    }
1690
1691    pub fn into_channel(self) -> fidl::Channel {
1692        self.client.into_channel()
1693    }
1694
1695    /// Waits until an event arrives and returns it. It is safe for other
1696    /// threads to make concurrent requests while waiting for an event.
1697    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<IioEvent, fidl::Error> {
1698        IioEvent::decode(self.client.wait_for_event(deadline)?)
1699    }
1700
1701    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
1702    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
1703    /// up with sysfs cleanup.
1704    pub fn r#get_iio_value(
1705        &self,
1706        mut label: &str,
1707        ___deadline: zx::MonotonicInstant,
1708    ) -> Result<IioGetIioValueResult, fidl::Error> {
1709        let _response = self.client.send_query::<
1710            IioGetIioValueRequest,
1711            fidl::encoding::ResultType<IioGetIioValueResponse, i32>,
1712        >(
1713            (label,),
1714            0x6647435fd885de5e,
1715            fidl::encoding::DynamicFlags::empty(),
1716            ___deadline,
1717        )?;
1718        Ok(_response.map(|x| x.value))
1719    }
1720}
1721
1722#[cfg(target_os = "fuchsia")]
1723impl From<IioSynchronousProxy> for zx::Handle {
1724    fn from(value: IioSynchronousProxy) -> Self {
1725        value.into_channel().into()
1726    }
1727}
1728
1729#[cfg(target_os = "fuchsia")]
1730impl From<fidl::Channel> for IioSynchronousProxy {
1731    fn from(value: fidl::Channel) -> Self {
1732        Self::new(value)
1733    }
1734}
1735
1736#[cfg(target_os = "fuchsia")]
1737impl fidl::endpoints::FromClient for IioSynchronousProxy {
1738    type Protocol = IioMarker;
1739
1740    fn from_client(value: fidl::endpoints::ClientEnd<IioMarker>) -> Self {
1741        Self::new(value.into_channel())
1742    }
1743}
1744
1745#[derive(Debug, Clone)]
1746pub struct IioProxy {
1747    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1748}
1749
1750impl fidl::endpoints::Proxy for IioProxy {
1751    type Protocol = IioMarker;
1752
1753    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1754        Self::new(inner)
1755    }
1756
1757    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1758        self.client.into_channel().map_err(|client| Self { client })
1759    }
1760
1761    fn as_channel(&self) -> &::fidl::AsyncChannel {
1762        self.client.as_channel()
1763    }
1764}
1765
1766impl IioProxy {
1767    /// Create a new Proxy for fuchsia.hardware.qcom.hvdcpopti/Iio.
1768    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1769        let protocol_name = <IioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1770        Self { client: fidl::client::Client::new(channel, protocol_name) }
1771    }
1772
1773    /// Get a Stream of events from the remote end of the protocol.
1774    ///
1775    /// # Panics
1776    ///
1777    /// Panics if the event stream was already taken.
1778    pub fn take_event_stream(&self) -> IioEventStream {
1779        IioEventStream { event_receiver: self.client.take_event_receiver() }
1780    }
1781
1782    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
1783    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
1784    /// up with sysfs cleanup.
1785    pub fn r#get_iio_value(
1786        &self,
1787        mut label: &str,
1788    ) -> fidl::client::QueryResponseFut<
1789        IioGetIioValueResult,
1790        fidl::encoding::DefaultFuchsiaResourceDialect,
1791    > {
1792        IioProxyInterface::r#get_iio_value(self, label)
1793    }
1794}
1795
1796impl IioProxyInterface for IioProxy {
1797    type GetIioValueResponseFut = fidl::client::QueryResponseFut<
1798        IioGetIioValueResult,
1799        fidl::encoding::DefaultFuchsiaResourceDialect,
1800    >;
1801    fn r#get_iio_value(&self, mut label: &str) -> Self::GetIioValueResponseFut {
1802        fn _decode(
1803            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1804        ) -> Result<IioGetIioValueResult, fidl::Error> {
1805            let _response = fidl::client::decode_transaction_body::<
1806                fidl::encoding::ResultType<IioGetIioValueResponse, i32>,
1807                fidl::encoding::DefaultFuchsiaResourceDialect,
1808                0x6647435fd885de5e,
1809            >(_buf?)?;
1810            Ok(_response.map(|x| x.value))
1811        }
1812        self.client.send_query_and_decode::<IioGetIioValueRequest, IioGetIioValueResult>(
1813            (label,),
1814            0x6647435fd885de5e,
1815            fidl::encoding::DynamicFlags::empty(),
1816            _decode,
1817        )
1818    }
1819}
1820
1821pub struct IioEventStream {
1822    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1823}
1824
1825impl std::marker::Unpin for IioEventStream {}
1826
1827impl futures::stream::FusedStream for IioEventStream {
1828    fn is_terminated(&self) -> bool {
1829        self.event_receiver.is_terminated()
1830    }
1831}
1832
1833impl futures::Stream for IioEventStream {
1834    type Item = Result<IioEvent, fidl::Error>;
1835
1836    fn poll_next(
1837        mut self: std::pin::Pin<&mut Self>,
1838        cx: &mut std::task::Context<'_>,
1839    ) -> std::task::Poll<Option<Self::Item>> {
1840        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1841            &mut self.event_receiver,
1842            cx
1843        )?) {
1844            Some(buf) => std::task::Poll::Ready(Some(IioEvent::decode(buf))),
1845            None => std::task::Poll::Ready(None),
1846        }
1847    }
1848}
1849
1850#[derive(Debug)]
1851pub enum IioEvent {}
1852
1853impl IioEvent {
1854    /// Decodes a message buffer as a [`IioEvent`].
1855    fn decode(
1856        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1857    ) -> Result<IioEvent, fidl::Error> {
1858        let (bytes, _handles) = buf.split_mut();
1859        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1860        debug_assert_eq!(tx_header.tx_id, 0);
1861        match tx_header.ordinal {
1862            _ => Err(fidl::Error::UnknownOrdinal {
1863                ordinal: tx_header.ordinal,
1864                protocol_name: <IioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1865            }),
1866        }
1867    }
1868}
1869
1870/// A Stream of incoming requests for fuchsia.hardware.qcom.hvdcpopti/Iio.
1871pub struct IioRequestStream {
1872    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1873    is_terminated: bool,
1874}
1875
1876impl std::marker::Unpin for IioRequestStream {}
1877
1878impl futures::stream::FusedStream for IioRequestStream {
1879    fn is_terminated(&self) -> bool {
1880        self.is_terminated
1881    }
1882}
1883
1884impl fidl::endpoints::RequestStream for IioRequestStream {
1885    type Protocol = IioMarker;
1886    type ControlHandle = IioControlHandle;
1887
1888    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1889        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1890    }
1891
1892    fn control_handle(&self) -> Self::ControlHandle {
1893        IioControlHandle { inner: self.inner.clone() }
1894    }
1895
1896    fn into_inner(
1897        self,
1898    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1899    {
1900        (self.inner, self.is_terminated)
1901    }
1902
1903    fn from_inner(
1904        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1905        is_terminated: bool,
1906    ) -> Self {
1907        Self { inner, is_terminated }
1908    }
1909}
1910
1911impl futures::Stream for IioRequestStream {
1912    type Item = Result<IioRequest, fidl::Error>;
1913
1914    fn poll_next(
1915        mut self: std::pin::Pin<&mut Self>,
1916        cx: &mut std::task::Context<'_>,
1917    ) -> std::task::Poll<Option<Self::Item>> {
1918        let this = &mut *self;
1919        if this.inner.check_shutdown(cx) {
1920            this.is_terminated = true;
1921            return std::task::Poll::Ready(None);
1922        }
1923        if this.is_terminated {
1924            panic!("polled IioRequestStream after completion");
1925        }
1926        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1927            |bytes, handles| {
1928                match this.inner.channel().read_etc(cx, bytes, handles) {
1929                    std::task::Poll::Ready(Ok(())) => {}
1930                    std::task::Poll::Pending => return std::task::Poll::Pending,
1931                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1932                        this.is_terminated = true;
1933                        return std::task::Poll::Ready(None);
1934                    }
1935                    std::task::Poll::Ready(Err(e)) => {
1936                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1937                            e.into(),
1938                        ))));
1939                    }
1940                }
1941
1942                // A message has been received from the channel
1943                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1944
1945                std::task::Poll::Ready(Some(match header.ordinal {
1946                    0x6647435fd885de5e => {
1947                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1948                        let mut req = fidl::new_empty!(
1949                            IioGetIioValueRequest,
1950                            fidl::encoding::DefaultFuchsiaResourceDialect
1951                        );
1952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<IioGetIioValueRequest>(&header, _body_bytes, handles, &mut req)?;
1953                        let control_handle = IioControlHandle { inner: this.inner.clone() };
1954                        Ok(IioRequest::GetIioValue {
1955                            label: req.label,
1956
1957                            responder: IioGetIioValueResponder {
1958                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1959                                tx_id: header.tx_id,
1960                            },
1961                        })
1962                    }
1963                    _ => Err(fidl::Error::UnknownOrdinal {
1964                        ordinal: header.ordinal,
1965                        protocol_name: <IioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1966                    }),
1967                }))
1968            },
1969        )
1970    }
1971}
1972
1973#[derive(Debug)]
1974pub enum IioRequest {
1975    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
1976    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
1977    /// up with sysfs cleanup.
1978    GetIioValue { label: String, responder: IioGetIioValueResponder },
1979}
1980
1981impl IioRequest {
1982    #[allow(irrefutable_let_patterns)]
1983    pub fn into_get_iio_value(self) -> Option<(String, IioGetIioValueResponder)> {
1984        if let IioRequest::GetIioValue { label, responder } = self {
1985            Some((label, responder))
1986        } else {
1987            None
1988        }
1989    }
1990
1991    /// Name of the method defined in FIDL
1992    pub fn method_name(&self) -> &'static str {
1993        match *self {
1994            IioRequest::GetIioValue { .. } => "get_iio_value",
1995        }
1996    }
1997}
1998
1999#[derive(Debug, Clone)]
2000pub struct IioControlHandle {
2001    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2002}
2003
2004impl fidl::endpoints::ControlHandle for IioControlHandle {
2005    fn shutdown(&self) {
2006        self.inner.shutdown()
2007    }
2008    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2009        self.inner.shutdown_with_epitaph(status)
2010    }
2011
2012    fn is_closed(&self) -> bool {
2013        self.inner.channel().is_closed()
2014    }
2015    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2016        self.inner.channel().on_closed()
2017    }
2018
2019    #[cfg(target_os = "fuchsia")]
2020    fn signal_peer(
2021        &self,
2022        clear_mask: zx::Signals,
2023        set_mask: zx::Signals,
2024    ) -> Result<(), zx_status::Status> {
2025        use fidl::Peered;
2026        self.inner.channel().signal_peer(clear_mask, set_mask)
2027    }
2028}
2029
2030impl IioControlHandle {}
2031
2032#[must_use = "FIDL methods require a response to be sent"]
2033#[derive(Debug)]
2034pub struct IioGetIioValueResponder {
2035    control_handle: std::mem::ManuallyDrop<IioControlHandle>,
2036    tx_id: u32,
2037}
2038
2039/// Set the the channel to be shutdown (see [`IioControlHandle::shutdown`])
2040/// if the responder is dropped without sending a response, so that the client
2041/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2042impl std::ops::Drop for IioGetIioValueResponder {
2043    fn drop(&mut self) {
2044        self.control_handle.shutdown();
2045        // Safety: drops once, never accessed again
2046        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2047    }
2048}
2049
2050impl fidl::endpoints::Responder for IioGetIioValueResponder {
2051    type ControlHandle = IioControlHandle;
2052
2053    fn control_handle(&self) -> &IioControlHandle {
2054        &self.control_handle
2055    }
2056
2057    fn drop_without_shutdown(mut self) {
2058        // Safety: drops once, never accessed again due to mem::forget
2059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2060        // Prevent Drop from running (which would shut down the channel)
2061        std::mem::forget(self);
2062    }
2063}
2064
2065impl IioGetIioValueResponder {
2066    /// Sends a response to the FIDL transaction.
2067    ///
2068    /// Sets the channel to shutdown if an error occurs.
2069    pub fn send(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
2070        let _result = self.send_raw(result);
2071        if _result.is_err() {
2072            self.control_handle.shutdown();
2073        }
2074        self.drop_without_shutdown();
2075        _result
2076    }
2077
2078    /// Similar to "send" but does not shutdown the channel if an error occurs.
2079    pub fn send_no_shutdown_on_err(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
2080        let _result = self.send_raw(result);
2081        self.drop_without_shutdown();
2082        _result
2083    }
2084
2085    fn send_raw(&self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
2086        self.control_handle.inner.send::<fidl::encoding::ResultType<IioGetIioValueResponse, i32>>(
2087            result.map(|value| (value,)),
2088            self.tx_id,
2089            0x6647435fd885de5e,
2090            fidl::encoding::DynamicFlags::empty(),
2091        )
2092    }
2093}
2094
2095#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2096pub struct ServiceMarker;
2097
2098#[cfg(target_os = "fuchsia")]
2099impl fidl::endpoints::ServiceMarker for ServiceMarker {
2100    type Proxy = ServiceProxy;
2101    type Request = ServiceRequest;
2102    const SERVICE_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Service";
2103}
2104
2105/// A request for one of the member protocols of Service.
2106///
2107#[cfg(target_os = "fuchsia")]
2108pub enum ServiceRequest {
2109    Device(DeviceRequestStream),
2110    Battery(BatteryRequestStream),
2111    Iio(IioRequestStream),
2112}
2113
2114#[cfg(target_os = "fuchsia")]
2115impl fidl::endpoints::ServiceRequest for ServiceRequest {
2116    type Service = ServiceMarker;
2117
2118    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2119        match name {
2120            "device" => Self::Device(
2121                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2122            ),
2123            "battery" => Self::Battery(
2124                <BatteryRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2125            ),
2126            "iio" => Self::Iio(<IioRequestStream as fidl::endpoints::RequestStream>::from_channel(
2127                _channel,
2128            )),
2129            _ => panic!("no such member protocol name for service Service"),
2130        }
2131    }
2132
2133    fn member_names() -> &'static [&'static str] {
2134        &["device", "battery", "iio"]
2135    }
2136}
2137#[cfg(target_os = "fuchsia")]
2138pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2139
2140#[cfg(target_os = "fuchsia")]
2141impl fidl::endpoints::ServiceProxy for ServiceProxy {
2142    type Service = ServiceMarker;
2143
2144    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2145        Self(opener)
2146    }
2147}
2148
2149#[cfg(target_os = "fuchsia")]
2150impl ServiceProxy {
2151    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2152        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2153        self.connect_channel_to_device(server_end)?;
2154        Ok(proxy)
2155    }
2156
2157    /// Like `connect_to_device`, but returns a sync proxy.
2158    /// See [`Self::connect_to_device`] for more details.
2159    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2160        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2161        self.connect_channel_to_device(server_end)?;
2162        Ok(proxy)
2163    }
2164
2165    /// Like `connect_to_device`, but accepts a server end.
2166    /// See [`Self::connect_to_device`] for more details.
2167    pub fn connect_channel_to_device(
2168        &self,
2169        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2170    ) -> Result<(), fidl::Error> {
2171        self.0.open_member("device", server_end.into_channel())
2172    }
2173    pub fn connect_to_battery(&self) -> Result<BatteryProxy, fidl::Error> {
2174        let (proxy, server_end) = fidl::endpoints::create_proxy::<BatteryMarker>();
2175        self.connect_channel_to_battery(server_end)?;
2176        Ok(proxy)
2177    }
2178
2179    /// Like `connect_to_battery`, but returns a sync proxy.
2180    /// See [`Self::connect_to_battery`] for more details.
2181    pub fn connect_to_battery_sync(&self) -> Result<BatterySynchronousProxy, fidl::Error> {
2182        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<BatteryMarker>();
2183        self.connect_channel_to_battery(server_end)?;
2184        Ok(proxy)
2185    }
2186
2187    /// Like `connect_to_battery`, but accepts a server end.
2188    /// See [`Self::connect_to_battery`] for more details.
2189    pub fn connect_channel_to_battery(
2190        &self,
2191        server_end: fidl::endpoints::ServerEnd<BatteryMarker>,
2192    ) -> Result<(), fidl::Error> {
2193        self.0.open_member("battery", server_end.into_channel())
2194    }
2195    pub fn connect_to_iio(&self) -> Result<IioProxy, fidl::Error> {
2196        let (proxy, server_end) = fidl::endpoints::create_proxy::<IioMarker>();
2197        self.connect_channel_to_iio(server_end)?;
2198        Ok(proxy)
2199    }
2200
2201    /// Like `connect_to_iio`, but returns a sync proxy.
2202    /// See [`Self::connect_to_iio`] for more details.
2203    pub fn connect_to_iio_sync(&self) -> Result<IioSynchronousProxy, fidl::Error> {
2204        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<IioMarker>();
2205        self.connect_channel_to_iio(server_end)?;
2206        Ok(proxy)
2207    }
2208
2209    /// Like `connect_to_iio`, but accepts a server end.
2210    /// See [`Self::connect_to_iio`] for more details.
2211    pub fn connect_channel_to_iio(
2212        &self,
2213        server_end: fidl::endpoints::ServerEnd<IioMarker>,
2214    ) -> Result<(), fidl::Error> {
2215        self.0.open_member("iio", server_end.into_channel())
2216    }
2217
2218    pub fn instance_name(&self) -> &str {
2219        self.0.instance_name()
2220    }
2221}
2222
2223mod internal {
2224    use super::*;
2225}