Skip to main content

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