fidl_fuchsia_hardware_qcom_hvdcpopti/
fidl_fuchsia_hardware_qcom_hvdcpopti.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_qcom_hvdcpopti__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceGetEssentialParamsResult = Result<[u8; 48], i32>;
27pub type DeviceSetEssentialParamsResult = Result<(), i32>;
28pub type DeviceGetBatteryProfileResult = Result<[u8; 596], i32>;
29pub type DeviceGetIioValueResult = Result<i32, i32>;
30
31pub trait DeviceProxyInterface: Send + Sync {
32    type GetEssentialParamsResponseFut: std::future::Future<Output = Result<DeviceGetEssentialParamsResult, fidl::Error>>
33        + Send;
34    fn r#get_essential_params(&self) -> Self::GetEssentialParamsResponseFut;
35    type SetEssentialParamsResponseFut: std::future::Future<Output = Result<DeviceSetEssentialParamsResult, fidl::Error>>
36        + Send;
37    fn r#set_essential_params(&self, params: &[u8; 48]) -> Self::SetEssentialParamsResponseFut;
38    type GetConfigResponseFut: std::future::Future<Output = Result<[u8; 104], fidl::Error>> + Send;
39    fn r#get_config(&self) -> Self::GetConfigResponseFut;
40    type SetProcessedFifoDataResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
41        + Send;
42    fn r#set_processed_fifo_data(&self, data: &[u8; 152]) -> Self::SetProcessedFifoDataResponseFut;
43    type GetStepAndJeitaParamsResponseFut: std::future::Future<Output = Result<[u8; 247], fidl::Error>>
44        + Send;
45    fn r#get_step_and_jeita_params(&self) -> Self::GetStepAndJeitaParamsResponseFut;
46    type GetBatteryConfigResponseFut: std::future::Future<Output = Result<[u8; 304], fidl::Error>>
47        + Send;
48    fn r#get_battery_config(&self) -> Self::GetBatteryConfigResponseFut;
49    type GetBatteryProfileResponseFut: std::future::Future<Output = Result<DeviceGetBatteryProfileResult, fidl::Error>>
50        + Send;
51    fn r#get_battery_profile(&self, request: &[u8; 8]) -> Self::GetBatteryProfileResponseFut;
52    type GetIioValueResponseFut: std::future::Future<Output = Result<DeviceGetIioValueResult, fidl::Error>>
53        + Send;
54    fn r#get_iio_value(&self, label: &str) -> Self::GetIioValueResponseFut;
55}
56#[derive(Debug)]
57#[cfg(target_os = "fuchsia")]
58pub struct DeviceSynchronousProxy {
59    client: fidl::client::sync::Client,
60}
61
62#[cfg(target_os = "fuchsia")]
63impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
64    type Proxy = DeviceProxy;
65    type Protocol = DeviceMarker;
66
67    fn from_channel(inner: fidl::Channel) -> Self {
68        Self::new(inner)
69    }
70
71    fn into_channel(self) -> fidl::Channel {
72        self.client.into_channel()
73    }
74
75    fn as_channel(&self) -> &fidl::Channel {
76        self.client.as_channel()
77    }
78}
79
80#[cfg(target_os = "fuchsia")]
81impl DeviceSynchronousProxy {
82    pub fn new(channel: fidl::Channel) -> Self {
83        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
84        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
85    }
86
87    pub fn into_channel(self) -> fidl::Channel {
88        self.client.into_channel()
89    }
90
91    /// Waits until an event arrives and returns it. It is safe for other
92    /// threads to make concurrent requests while waiting for an event.
93    pub fn wait_for_event(
94        &self,
95        deadline: zx::MonotonicInstant,
96    ) -> Result<DeviceEvent, fidl::Error> {
97        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
98    }
99
100    pub fn r#get_essential_params(
101        &self,
102        ___deadline: zx::MonotonicInstant,
103    ) -> Result<DeviceGetEssentialParamsResult, fidl::Error> {
104        let _response = self.client.send_query::<
105            fidl::encoding::EmptyPayload,
106            fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>,
107        >(
108            (),
109            0x2093fd296e2d8996,
110            fidl::encoding::DynamicFlags::empty(),
111            ___deadline,
112        )?;
113        Ok(_response.map(|x| x.params))
114    }
115
116    pub fn r#set_essential_params(
117        &self,
118        mut params: &[u8; 48],
119        ___deadline: zx::MonotonicInstant,
120    ) -> Result<DeviceSetEssentialParamsResult, fidl::Error> {
121        let _response = self.client.send_query::<
122            DeviceSetEssentialParamsRequest,
123            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
124        >(
125            (params,),
126            0x55b14f267312168c,
127            fidl::encoding::DynamicFlags::empty(),
128            ___deadline,
129        )?;
130        Ok(_response.map(|x| x))
131    }
132
133    pub fn r#get_config(
134        &self,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<[u8; 104], fidl::Error> {
137        let _response =
138            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetConfigResponse>(
139                (),
140                0x41a72f916b11e11f,
141                fidl::encoding::DynamicFlags::empty(),
142                ___deadline,
143            )?;
144        Ok(_response.config)
145    }
146
147    pub fn r#set_processed_fifo_data(
148        &self,
149        mut data: &[u8; 152],
150        ___deadline: zx::MonotonicInstant,
151    ) -> Result<(), fidl::Error> {
152        let _response = self
153            .client
154            .send_query::<DeviceSetProcessedFifoDataRequest, fidl::encoding::EmptyPayload>(
155                (data,),
156                0x4689e121bf9e884,
157                fidl::encoding::DynamicFlags::empty(),
158                ___deadline,
159            )?;
160        Ok(_response)
161    }
162
163    pub fn r#get_step_and_jeita_params(
164        &self,
165        ___deadline: zx::MonotonicInstant,
166    ) -> Result<[u8; 247], fidl::Error> {
167        let _response = self
168            .client
169            .send_query::<fidl::encoding::EmptyPayload, DeviceGetStepAndJeitaParamsResponse>(
170                (),
171                0x1c7ba411ae13b250,
172                fidl::encoding::DynamicFlags::empty(),
173                ___deadline,
174            )?;
175        Ok(_response.params)
176    }
177
178    pub fn r#get_battery_config(
179        &self,
180        ___deadline: zx::MonotonicInstant,
181    ) -> Result<[u8; 304], fidl::Error> {
182        let _response = self
183            .client
184            .send_query::<fidl::encoding::EmptyPayload, DeviceGetBatteryConfigResponse>(
185                (),
186                0x1790c60bf5e3dd40,
187                fidl::encoding::DynamicFlags::empty(),
188                ___deadline,
189            )?;
190        Ok(_response.config)
191    }
192
193    pub fn r#get_battery_profile(
194        &self,
195        mut request: &[u8; 8],
196        ___deadline: zx::MonotonicInstant,
197    ) -> Result<DeviceGetBatteryProfileResult, fidl::Error> {
198        let _response = self.client.send_query::<
199            DeviceGetBatteryProfileRequest,
200            fidl::encoding::ResultType<DeviceGetBatteryProfileResponse, i32>,
201        >(
202            (request,),
203            0x35f1cb1630c6079f,
204            fidl::encoding::DynamicFlags::empty(),
205            ___deadline,
206        )?;
207        Ok(_response.map(|x| x.profile))
208    }
209
210    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
211    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
212    /// up with sysfs cleanup.
213    pub fn r#get_iio_value(
214        &self,
215        mut label: &str,
216        ___deadline: zx::MonotonicInstant,
217    ) -> Result<DeviceGetIioValueResult, fidl::Error> {
218        let _response = self.client.send_query::<
219            DeviceGetIioValueRequest,
220            fidl::encoding::ResultType<DeviceGetIioValueResponse, i32>,
221        >(
222            (label,),
223            0x7e59fae7f9193277,
224            fidl::encoding::DynamicFlags::empty(),
225            ___deadline,
226        )?;
227        Ok(_response.map(|x| x.value))
228    }
229}
230
231#[cfg(target_os = "fuchsia")]
232impl From<DeviceSynchronousProxy> for zx::Handle {
233    fn from(value: DeviceSynchronousProxy) -> Self {
234        value.into_channel().into()
235    }
236}
237
238#[cfg(target_os = "fuchsia")]
239impl From<fidl::Channel> for DeviceSynchronousProxy {
240    fn from(value: fidl::Channel) -> Self {
241        Self::new(value)
242    }
243}
244
245#[derive(Debug, Clone)]
246pub struct DeviceProxy {
247    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
248}
249
250impl fidl::endpoints::Proxy for DeviceProxy {
251    type Protocol = DeviceMarker;
252
253    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
254        Self::new(inner)
255    }
256
257    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
258        self.client.into_channel().map_err(|client| Self { client })
259    }
260
261    fn as_channel(&self) -> &::fidl::AsyncChannel {
262        self.client.as_channel()
263    }
264}
265
266impl DeviceProxy {
267    /// Create a new Proxy for fuchsia.hardware.qcom.hvdcpopti/Device.
268    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
269        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
270        Self { client: fidl::client::Client::new(channel, protocol_name) }
271    }
272
273    /// Get a Stream of events from the remote end of the protocol.
274    ///
275    /// # Panics
276    ///
277    /// Panics if the event stream was already taken.
278    pub fn take_event_stream(&self) -> DeviceEventStream {
279        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
280    }
281
282    pub fn r#get_essential_params(
283        &self,
284    ) -> fidl::client::QueryResponseFut<
285        DeviceGetEssentialParamsResult,
286        fidl::encoding::DefaultFuchsiaResourceDialect,
287    > {
288        DeviceProxyInterface::r#get_essential_params(self)
289    }
290
291    pub fn r#set_essential_params(
292        &self,
293        mut params: &[u8; 48],
294    ) -> fidl::client::QueryResponseFut<
295        DeviceSetEssentialParamsResult,
296        fidl::encoding::DefaultFuchsiaResourceDialect,
297    > {
298        DeviceProxyInterface::r#set_essential_params(self, params)
299    }
300
301    pub fn r#get_config(
302        &self,
303    ) -> fidl::client::QueryResponseFut<[u8; 104], fidl::encoding::DefaultFuchsiaResourceDialect>
304    {
305        DeviceProxyInterface::r#get_config(self)
306    }
307
308    pub fn r#set_processed_fifo_data(
309        &self,
310        mut data: &[u8; 152],
311    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
312        DeviceProxyInterface::r#set_processed_fifo_data(self, data)
313    }
314
315    pub fn r#get_step_and_jeita_params(
316        &self,
317    ) -> fidl::client::QueryResponseFut<[u8; 247], fidl::encoding::DefaultFuchsiaResourceDialect>
318    {
319        DeviceProxyInterface::r#get_step_and_jeita_params(self)
320    }
321
322    pub fn r#get_battery_config(
323        &self,
324    ) -> fidl::client::QueryResponseFut<[u8; 304], fidl::encoding::DefaultFuchsiaResourceDialect>
325    {
326        DeviceProxyInterface::r#get_battery_config(self)
327    }
328
329    pub fn r#get_battery_profile(
330        &self,
331        mut request: &[u8; 8],
332    ) -> fidl::client::QueryResponseFut<
333        DeviceGetBatteryProfileResult,
334        fidl::encoding::DefaultFuchsiaResourceDialect,
335    > {
336        DeviceProxyInterface::r#get_battery_profile(self, request)
337    }
338
339    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
340    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
341    /// up with sysfs cleanup.
342    pub fn r#get_iio_value(
343        &self,
344        mut label: &str,
345    ) -> fidl::client::QueryResponseFut<
346        DeviceGetIioValueResult,
347        fidl::encoding::DefaultFuchsiaResourceDialect,
348    > {
349        DeviceProxyInterface::r#get_iio_value(self, label)
350    }
351}
352
353impl DeviceProxyInterface for DeviceProxy {
354    type GetEssentialParamsResponseFut = fidl::client::QueryResponseFut<
355        DeviceGetEssentialParamsResult,
356        fidl::encoding::DefaultFuchsiaResourceDialect,
357    >;
358    fn r#get_essential_params(&self) -> Self::GetEssentialParamsResponseFut {
359        fn _decode(
360            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
361        ) -> Result<DeviceGetEssentialParamsResult, fidl::Error> {
362            let _response = fidl::client::decode_transaction_body::<
363                fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>,
364                fidl::encoding::DefaultFuchsiaResourceDialect,
365                0x2093fd296e2d8996,
366            >(_buf?)?;
367            Ok(_response.map(|x| x.params))
368        }
369        self.client
370            .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetEssentialParamsResult>(
371                (),
372                0x2093fd296e2d8996,
373                fidl::encoding::DynamicFlags::empty(),
374                _decode,
375            )
376    }
377
378    type SetEssentialParamsResponseFut = fidl::client::QueryResponseFut<
379        DeviceSetEssentialParamsResult,
380        fidl::encoding::DefaultFuchsiaResourceDialect,
381    >;
382    fn r#set_essential_params(&self, mut params: &[u8; 48]) -> Self::SetEssentialParamsResponseFut {
383        fn _decode(
384            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
385        ) -> Result<DeviceSetEssentialParamsResult, fidl::Error> {
386            let _response = fidl::client::decode_transaction_body::<
387                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
388                fidl::encoding::DefaultFuchsiaResourceDialect,
389                0x55b14f267312168c,
390            >(_buf?)?;
391            Ok(_response.map(|x| x))
392        }
393        self.client.send_query_and_decode::<
394            DeviceSetEssentialParamsRequest,
395            DeviceSetEssentialParamsResult,
396        >(
397            (params,),
398            0x55b14f267312168c,
399            fidl::encoding::DynamicFlags::empty(),
400            _decode,
401        )
402    }
403
404    type GetConfigResponseFut =
405        fidl::client::QueryResponseFut<[u8; 104], fidl::encoding::DefaultFuchsiaResourceDialect>;
406    fn r#get_config(&self) -> Self::GetConfigResponseFut {
407        fn _decode(
408            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
409        ) -> Result<[u8; 104], fidl::Error> {
410            let _response = fidl::client::decode_transaction_body::<
411                DeviceGetConfigResponse,
412                fidl::encoding::DefaultFuchsiaResourceDialect,
413                0x41a72f916b11e11f,
414            >(_buf?)?;
415            Ok(_response.config)
416        }
417        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 104]>(
418            (),
419            0x41a72f916b11e11f,
420            fidl::encoding::DynamicFlags::empty(),
421            _decode,
422        )
423    }
424
425    type SetProcessedFifoDataResponseFut =
426        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
427    fn r#set_processed_fifo_data(
428        &self,
429        mut data: &[u8; 152],
430    ) -> Self::SetProcessedFifoDataResponseFut {
431        fn _decode(
432            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
433        ) -> Result<(), fidl::Error> {
434            let _response = fidl::client::decode_transaction_body::<
435                fidl::encoding::EmptyPayload,
436                fidl::encoding::DefaultFuchsiaResourceDialect,
437                0x4689e121bf9e884,
438            >(_buf?)?;
439            Ok(_response)
440        }
441        self.client.send_query_and_decode::<DeviceSetProcessedFifoDataRequest, ()>(
442            (data,),
443            0x4689e121bf9e884,
444            fidl::encoding::DynamicFlags::empty(),
445            _decode,
446        )
447    }
448
449    type GetStepAndJeitaParamsResponseFut =
450        fidl::client::QueryResponseFut<[u8; 247], fidl::encoding::DefaultFuchsiaResourceDialect>;
451    fn r#get_step_and_jeita_params(&self) -> Self::GetStepAndJeitaParamsResponseFut {
452        fn _decode(
453            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
454        ) -> Result<[u8; 247], fidl::Error> {
455            let _response = fidl::client::decode_transaction_body::<
456                DeviceGetStepAndJeitaParamsResponse,
457                fidl::encoding::DefaultFuchsiaResourceDialect,
458                0x1c7ba411ae13b250,
459            >(_buf?)?;
460            Ok(_response.params)
461        }
462        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 247]>(
463            (),
464            0x1c7ba411ae13b250,
465            fidl::encoding::DynamicFlags::empty(),
466            _decode,
467        )
468    }
469
470    type GetBatteryConfigResponseFut =
471        fidl::client::QueryResponseFut<[u8; 304], fidl::encoding::DefaultFuchsiaResourceDialect>;
472    fn r#get_battery_config(&self) -> Self::GetBatteryConfigResponseFut {
473        fn _decode(
474            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
475        ) -> Result<[u8; 304], fidl::Error> {
476            let _response = fidl::client::decode_transaction_body::<
477                DeviceGetBatteryConfigResponse,
478                fidl::encoding::DefaultFuchsiaResourceDialect,
479                0x1790c60bf5e3dd40,
480            >(_buf?)?;
481            Ok(_response.config)
482        }
483        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, [u8; 304]>(
484            (),
485            0x1790c60bf5e3dd40,
486            fidl::encoding::DynamicFlags::empty(),
487            _decode,
488        )
489    }
490
491    type GetBatteryProfileResponseFut = fidl::client::QueryResponseFut<
492        DeviceGetBatteryProfileResult,
493        fidl::encoding::DefaultFuchsiaResourceDialect,
494    >;
495    fn r#get_battery_profile(&self, mut request: &[u8; 8]) -> Self::GetBatteryProfileResponseFut {
496        fn _decode(
497            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
498        ) -> Result<DeviceGetBatteryProfileResult, fidl::Error> {
499            let _response = fidl::client::decode_transaction_body::<
500                fidl::encoding::ResultType<DeviceGetBatteryProfileResponse, i32>,
501                fidl::encoding::DefaultFuchsiaResourceDialect,
502                0x35f1cb1630c6079f,
503            >(_buf?)?;
504            Ok(_response.map(|x| x.profile))
505        }
506        self.client
507            .send_query_and_decode::<DeviceGetBatteryProfileRequest, DeviceGetBatteryProfileResult>(
508                (request,),
509                0x35f1cb1630c6079f,
510                fidl::encoding::DynamicFlags::empty(),
511                _decode,
512            )
513    }
514
515    type GetIioValueResponseFut = fidl::client::QueryResponseFut<
516        DeviceGetIioValueResult,
517        fidl::encoding::DefaultFuchsiaResourceDialect,
518    >;
519    fn r#get_iio_value(&self, mut label: &str) -> Self::GetIioValueResponseFut {
520        fn _decode(
521            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
522        ) -> Result<DeviceGetIioValueResult, fidl::Error> {
523            let _response = fidl::client::decode_transaction_body::<
524                fidl::encoding::ResultType<DeviceGetIioValueResponse, i32>,
525                fidl::encoding::DefaultFuchsiaResourceDialect,
526                0x7e59fae7f9193277,
527            >(_buf?)?;
528            Ok(_response.map(|x| x.value))
529        }
530        self.client.send_query_and_decode::<DeviceGetIioValueRequest, DeviceGetIioValueResult>(
531            (label,),
532            0x7e59fae7f9193277,
533            fidl::encoding::DynamicFlags::empty(),
534            _decode,
535        )
536    }
537}
538
539pub struct DeviceEventStream {
540    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
541}
542
543impl std::marker::Unpin for DeviceEventStream {}
544
545impl futures::stream::FusedStream for DeviceEventStream {
546    fn is_terminated(&self) -> bool {
547        self.event_receiver.is_terminated()
548    }
549}
550
551impl futures::Stream for DeviceEventStream {
552    type Item = Result<DeviceEvent, fidl::Error>;
553
554    fn poll_next(
555        mut self: std::pin::Pin<&mut Self>,
556        cx: &mut std::task::Context<'_>,
557    ) -> std::task::Poll<Option<Self::Item>> {
558        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
559            &mut self.event_receiver,
560            cx
561        )?) {
562            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
563            None => std::task::Poll::Ready(None),
564        }
565    }
566}
567
568#[derive(Debug)]
569pub enum DeviceEvent {
570    OnFifoData { data: Vec<u8> },
571}
572
573impl DeviceEvent {
574    #[allow(irrefutable_let_patterns)]
575    pub fn into_on_fifo_data(self) -> Option<Vec<u8>> {
576        if let DeviceEvent::OnFifoData { data } = self {
577            Some((data))
578        } else {
579            None
580        }
581    }
582
583    /// Decodes a message buffer as a [`DeviceEvent`].
584    fn decode(
585        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
586    ) -> Result<DeviceEvent, fidl::Error> {
587        let (bytes, _handles) = buf.split_mut();
588        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
589        debug_assert_eq!(tx_header.tx_id, 0);
590        match tx_header.ordinal {
591            0x79aa05363cb0b4c7 => {
592                let mut out = fidl::new_empty!(
593                    DeviceOnFifoDataRequest,
594                    fidl::encoding::DefaultFuchsiaResourceDialect
595                );
596                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnFifoDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
597                Ok((DeviceEvent::OnFifoData { data: out.data }))
598            }
599            _ => Err(fidl::Error::UnknownOrdinal {
600                ordinal: tx_header.ordinal,
601                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
602            }),
603        }
604    }
605}
606
607/// A Stream of incoming requests for fuchsia.hardware.qcom.hvdcpopti/Device.
608pub struct DeviceRequestStream {
609    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
610    is_terminated: bool,
611}
612
613impl std::marker::Unpin for DeviceRequestStream {}
614
615impl futures::stream::FusedStream for DeviceRequestStream {
616    fn is_terminated(&self) -> bool {
617        self.is_terminated
618    }
619}
620
621impl fidl::endpoints::RequestStream for DeviceRequestStream {
622    type Protocol = DeviceMarker;
623    type ControlHandle = DeviceControlHandle;
624
625    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
626        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
627    }
628
629    fn control_handle(&self) -> Self::ControlHandle {
630        DeviceControlHandle { inner: self.inner.clone() }
631    }
632
633    fn into_inner(
634        self,
635    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
636    {
637        (self.inner, self.is_terminated)
638    }
639
640    fn from_inner(
641        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
642        is_terminated: bool,
643    ) -> Self {
644        Self { inner, is_terminated }
645    }
646}
647
648impl futures::Stream for DeviceRequestStream {
649    type Item = Result<DeviceRequest, fidl::Error>;
650
651    fn poll_next(
652        mut self: std::pin::Pin<&mut Self>,
653        cx: &mut std::task::Context<'_>,
654    ) -> std::task::Poll<Option<Self::Item>> {
655        let this = &mut *self;
656        if this.inner.check_shutdown(cx) {
657            this.is_terminated = true;
658            return std::task::Poll::Ready(None);
659        }
660        if this.is_terminated {
661            panic!("polled DeviceRequestStream after completion");
662        }
663        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
664            |bytes, handles| {
665                match this.inner.channel().read_etc(cx, bytes, handles) {
666                    std::task::Poll::Ready(Ok(())) => {}
667                    std::task::Poll::Pending => return std::task::Poll::Pending,
668                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
669                        this.is_terminated = true;
670                        return std::task::Poll::Ready(None);
671                    }
672                    std::task::Poll::Ready(Err(e)) => {
673                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
674                            e.into(),
675                        ))))
676                    }
677                }
678
679                // A message has been received from the channel
680                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
681
682                std::task::Poll::Ready(Some(match header.ordinal {
683                    0x2093fd296e2d8996 => {
684                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
685                        let mut req = fidl::new_empty!(
686                            fidl::encoding::EmptyPayload,
687                            fidl::encoding::DefaultFuchsiaResourceDialect
688                        );
689                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
690                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
691                        Ok(DeviceRequest::GetEssentialParams {
692                            responder: DeviceGetEssentialParamsResponder {
693                                control_handle: std::mem::ManuallyDrop::new(control_handle),
694                                tx_id: header.tx_id,
695                            },
696                        })
697                    }
698                    0x55b14f267312168c => {
699                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
700                        let mut req = fidl::new_empty!(
701                            DeviceSetEssentialParamsRequest,
702                            fidl::encoding::DefaultFuchsiaResourceDialect
703                        );
704                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetEssentialParamsRequest>(&header, _body_bytes, handles, &mut req)?;
705                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
706                        Ok(DeviceRequest::SetEssentialParams {
707                            params: req.params,
708
709                            responder: DeviceSetEssentialParamsResponder {
710                                control_handle: std::mem::ManuallyDrop::new(control_handle),
711                                tx_id: header.tx_id,
712                            },
713                        })
714                    }
715                    0x41a72f916b11e11f => {
716                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
717                        let mut req = fidl::new_empty!(
718                            fidl::encoding::EmptyPayload,
719                            fidl::encoding::DefaultFuchsiaResourceDialect
720                        );
721                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
722                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
723                        Ok(DeviceRequest::GetConfig {
724                            responder: DeviceGetConfigResponder {
725                                control_handle: std::mem::ManuallyDrop::new(control_handle),
726                                tx_id: header.tx_id,
727                            },
728                        })
729                    }
730                    0x4689e121bf9e884 => {
731                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
732                        let mut req = fidl::new_empty!(
733                            DeviceSetProcessedFifoDataRequest,
734                            fidl::encoding::DefaultFuchsiaResourceDialect
735                        );
736                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetProcessedFifoDataRequest>(&header, _body_bytes, handles, &mut req)?;
737                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
738                        Ok(DeviceRequest::SetProcessedFifoData {
739                            data: req.data,
740
741                            responder: DeviceSetProcessedFifoDataResponder {
742                                control_handle: std::mem::ManuallyDrop::new(control_handle),
743                                tx_id: header.tx_id,
744                            },
745                        })
746                    }
747                    0x1c7ba411ae13b250 => {
748                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
749                        let mut req = fidl::new_empty!(
750                            fidl::encoding::EmptyPayload,
751                            fidl::encoding::DefaultFuchsiaResourceDialect
752                        );
753                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
754                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
755                        Ok(DeviceRequest::GetStepAndJeitaParams {
756                            responder: DeviceGetStepAndJeitaParamsResponder {
757                                control_handle: std::mem::ManuallyDrop::new(control_handle),
758                                tx_id: header.tx_id,
759                            },
760                        })
761                    }
762                    0x1790c60bf5e3dd40 => {
763                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
764                        let mut req = fidl::new_empty!(
765                            fidl::encoding::EmptyPayload,
766                            fidl::encoding::DefaultFuchsiaResourceDialect
767                        );
768                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
769                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
770                        Ok(DeviceRequest::GetBatteryConfig {
771                            responder: DeviceGetBatteryConfigResponder {
772                                control_handle: std::mem::ManuallyDrop::new(control_handle),
773                                tx_id: header.tx_id,
774                            },
775                        })
776                    }
777                    0x35f1cb1630c6079f => {
778                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
779                        let mut req = fidl::new_empty!(
780                            DeviceGetBatteryProfileRequest,
781                            fidl::encoding::DefaultFuchsiaResourceDialect
782                        );
783                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetBatteryProfileRequest>(&header, _body_bytes, handles, &mut req)?;
784                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
785                        Ok(DeviceRequest::GetBatteryProfile {
786                            request: req.request,
787
788                            responder: DeviceGetBatteryProfileResponder {
789                                control_handle: std::mem::ManuallyDrop::new(control_handle),
790                                tx_id: header.tx_id,
791                            },
792                        })
793                    }
794                    0x7e59fae7f9193277 => {
795                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
796                        let mut req = fidl::new_empty!(
797                            DeviceGetIioValueRequest,
798                            fidl::encoding::DefaultFuchsiaResourceDialect
799                        );
800                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetIioValueRequest>(&header, _body_bytes, handles, &mut req)?;
801                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
802                        Ok(DeviceRequest::GetIioValue {
803                            label: req.label,
804
805                            responder: DeviceGetIioValueResponder {
806                                control_handle: std::mem::ManuallyDrop::new(control_handle),
807                                tx_id: header.tx_id,
808                            },
809                        })
810                    }
811                    _ => Err(fidl::Error::UnknownOrdinal {
812                        ordinal: header.ordinal,
813                        protocol_name:
814                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
815                    }),
816                }))
817            },
818        )
819    }
820}
821
822/// Used by driver to interface with Starnix and speak to the hvdcp_opti daemon.
823#[derive(Debug)]
824pub enum DeviceRequest {
825    GetEssentialParams {
826        responder: DeviceGetEssentialParamsResponder,
827    },
828    SetEssentialParams {
829        params: [u8; 48],
830        responder: DeviceSetEssentialParamsResponder,
831    },
832    GetConfig {
833        responder: DeviceGetConfigResponder,
834    },
835    SetProcessedFifoData {
836        data: [u8; 152],
837        responder: DeviceSetProcessedFifoDataResponder,
838    },
839    GetStepAndJeitaParams {
840        responder: DeviceGetStepAndJeitaParamsResponder,
841    },
842    GetBatteryConfig {
843        responder: DeviceGetBatteryConfigResponder,
844    },
845    GetBatteryProfile {
846        request: [u8; 8],
847        responder: DeviceGetBatteryProfileResponder,
848    },
849    /// Gets Industrial I/O (IIO) reading value. Values available depend on what the server
850    /// supports. May overlap with other configs in fuchsia.power.battery, but will be cleaned
851    /// up with sysfs cleanup.
852    GetIioValue {
853        label: String,
854        responder: DeviceGetIioValueResponder,
855    },
856}
857
858impl DeviceRequest {
859    #[allow(irrefutable_let_patterns)]
860    pub fn into_get_essential_params(self) -> Option<(DeviceGetEssentialParamsResponder)> {
861        if let DeviceRequest::GetEssentialParams { responder } = self {
862            Some((responder))
863        } else {
864            None
865        }
866    }
867
868    #[allow(irrefutable_let_patterns)]
869    pub fn into_set_essential_params(
870        self,
871    ) -> Option<([u8; 48], DeviceSetEssentialParamsResponder)> {
872        if let DeviceRequest::SetEssentialParams { params, responder } = self {
873            Some((params, responder))
874        } else {
875            None
876        }
877    }
878
879    #[allow(irrefutable_let_patterns)]
880    pub fn into_get_config(self) -> Option<(DeviceGetConfigResponder)> {
881        if let DeviceRequest::GetConfig { responder } = self {
882            Some((responder))
883        } else {
884            None
885        }
886    }
887
888    #[allow(irrefutable_let_patterns)]
889    pub fn into_set_processed_fifo_data(
890        self,
891    ) -> Option<([u8; 152], DeviceSetProcessedFifoDataResponder)> {
892        if let DeviceRequest::SetProcessedFifoData { data, responder } = self {
893            Some((data, responder))
894        } else {
895            None
896        }
897    }
898
899    #[allow(irrefutable_let_patterns)]
900    pub fn into_get_step_and_jeita_params(self) -> Option<(DeviceGetStepAndJeitaParamsResponder)> {
901        if let DeviceRequest::GetStepAndJeitaParams { responder } = self {
902            Some((responder))
903        } else {
904            None
905        }
906    }
907
908    #[allow(irrefutable_let_patterns)]
909    pub fn into_get_battery_config(self) -> Option<(DeviceGetBatteryConfigResponder)> {
910        if let DeviceRequest::GetBatteryConfig { responder } = self {
911            Some((responder))
912        } else {
913            None
914        }
915    }
916
917    #[allow(irrefutable_let_patterns)]
918    pub fn into_get_battery_profile(self) -> Option<([u8; 8], DeviceGetBatteryProfileResponder)> {
919        if let DeviceRequest::GetBatteryProfile { request, responder } = self {
920            Some((request, responder))
921        } else {
922            None
923        }
924    }
925
926    #[allow(irrefutable_let_patterns)]
927    pub fn into_get_iio_value(self) -> Option<(String, DeviceGetIioValueResponder)> {
928        if let DeviceRequest::GetIioValue { label, responder } = self {
929            Some((label, responder))
930        } else {
931            None
932        }
933    }
934
935    /// Name of the method defined in FIDL
936    pub fn method_name(&self) -> &'static str {
937        match *self {
938            DeviceRequest::GetEssentialParams { .. } => "get_essential_params",
939            DeviceRequest::SetEssentialParams { .. } => "set_essential_params",
940            DeviceRequest::GetConfig { .. } => "get_config",
941            DeviceRequest::SetProcessedFifoData { .. } => "set_processed_fifo_data",
942            DeviceRequest::GetStepAndJeitaParams { .. } => "get_step_and_jeita_params",
943            DeviceRequest::GetBatteryConfig { .. } => "get_battery_config",
944            DeviceRequest::GetBatteryProfile { .. } => "get_battery_profile",
945            DeviceRequest::GetIioValue { .. } => "get_iio_value",
946        }
947    }
948}
949
950#[derive(Debug, Clone)]
951pub struct DeviceControlHandle {
952    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
953}
954
955impl fidl::endpoints::ControlHandle for DeviceControlHandle {
956    fn shutdown(&self) {
957        self.inner.shutdown()
958    }
959    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
960        self.inner.shutdown_with_epitaph(status)
961    }
962
963    fn is_closed(&self) -> bool {
964        self.inner.channel().is_closed()
965    }
966    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
967        self.inner.channel().on_closed()
968    }
969
970    #[cfg(target_os = "fuchsia")]
971    fn signal_peer(
972        &self,
973        clear_mask: zx::Signals,
974        set_mask: zx::Signals,
975    ) -> Result<(), zx_status::Status> {
976        use fidl::Peered;
977        self.inner.channel().signal_peer(clear_mask, set_mask)
978    }
979}
980
981impl DeviceControlHandle {
982    pub fn send_on_fifo_data(&self, mut data: &[u8]) -> Result<(), fidl::Error> {
983        self.inner.send::<DeviceOnFifoDataRequest>(
984            (data,),
985            0,
986            0x79aa05363cb0b4c7,
987            fidl::encoding::DynamicFlags::empty(),
988        )
989    }
990}
991
992#[must_use = "FIDL methods require a response to be sent"]
993#[derive(Debug)]
994pub struct DeviceGetEssentialParamsResponder {
995    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
996    tx_id: u32,
997}
998
999/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1000/// if the responder is dropped without sending a response, so that the client
1001/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1002impl std::ops::Drop for DeviceGetEssentialParamsResponder {
1003    fn drop(&mut self) {
1004        self.control_handle.shutdown();
1005        // Safety: drops once, never accessed again
1006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1007    }
1008}
1009
1010impl fidl::endpoints::Responder for DeviceGetEssentialParamsResponder {
1011    type ControlHandle = DeviceControlHandle;
1012
1013    fn control_handle(&self) -> &DeviceControlHandle {
1014        &self.control_handle
1015    }
1016
1017    fn drop_without_shutdown(mut self) {
1018        // Safety: drops once, never accessed again due to mem::forget
1019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1020        // Prevent Drop from running (which would shut down the channel)
1021        std::mem::forget(self);
1022    }
1023}
1024
1025impl DeviceGetEssentialParamsResponder {
1026    /// Sends a response to the FIDL transaction.
1027    ///
1028    /// Sets the channel to shutdown if an error occurs.
1029    pub fn send(self, mut result: Result<&[u8; 48], i32>) -> Result<(), fidl::Error> {
1030        let _result = self.send_raw(result);
1031        if _result.is_err() {
1032            self.control_handle.shutdown();
1033        }
1034        self.drop_without_shutdown();
1035        _result
1036    }
1037
1038    /// Similar to "send" but does not shutdown the channel if an error occurs.
1039    pub fn send_no_shutdown_on_err(
1040        self,
1041        mut result: Result<&[u8; 48], i32>,
1042    ) -> Result<(), fidl::Error> {
1043        let _result = self.send_raw(result);
1044        self.drop_without_shutdown();
1045        _result
1046    }
1047
1048    fn send_raw(&self, mut result: Result<&[u8; 48], i32>) -> Result<(), fidl::Error> {
1049        self.control_handle
1050            .inner
1051            .send::<fidl::encoding::ResultType<DeviceGetEssentialParamsResponse, i32>>(
1052                result.map(|params| (params,)),
1053                self.tx_id,
1054                0x2093fd296e2d8996,
1055                fidl::encoding::DynamicFlags::empty(),
1056            )
1057    }
1058}
1059
1060#[must_use = "FIDL methods require a response to be sent"]
1061#[derive(Debug)]
1062pub struct DeviceSetEssentialParamsResponder {
1063    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1064    tx_id: u32,
1065}
1066
1067/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1068/// if the responder is dropped without sending a response, so that the client
1069/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1070impl std::ops::Drop for DeviceSetEssentialParamsResponder {
1071    fn drop(&mut self) {
1072        self.control_handle.shutdown();
1073        // Safety: drops once, never accessed again
1074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075    }
1076}
1077
1078impl fidl::endpoints::Responder for DeviceSetEssentialParamsResponder {
1079    type ControlHandle = DeviceControlHandle;
1080
1081    fn control_handle(&self) -> &DeviceControlHandle {
1082        &self.control_handle
1083    }
1084
1085    fn drop_without_shutdown(mut self) {
1086        // Safety: drops once, never accessed again due to mem::forget
1087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088        // Prevent Drop from running (which would shut down the channel)
1089        std::mem::forget(self);
1090    }
1091}
1092
1093impl DeviceSetEssentialParamsResponder {
1094    /// Sends a response to the FIDL transaction.
1095    ///
1096    /// Sets the channel to shutdown if an error occurs.
1097    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1098        let _result = self.send_raw(result);
1099        if _result.is_err() {
1100            self.control_handle.shutdown();
1101        }
1102        self.drop_without_shutdown();
1103        _result
1104    }
1105
1106    /// Similar to "send" but does not shutdown the channel if an error occurs.
1107    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1108        let _result = self.send_raw(result);
1109        self.drop_without_shutdown();
1110        _result
1111    }
1112
1113    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1114        self.control_handle
1115            .inner
1116            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1117                result,
1118                self.tx_id,
1119                0x55b14f267312168c,
1120                fidl::encoding::DynamicFlags::empty(),
1121            )
1122    }
1123}
1124
1125#[must_use = "FIDL methods require a response to be sent"]
1126#[derive(Debug)]
1127pub struct DeviceGetConfigResponder {
1128    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1129    tx_id: u32,
1130}
1131
1132/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1133/// if the responder is dropped without sending a response, so that the client
1134/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1135impl std::ops::Drop for DeviceGetConfigResponder {
1136    fn drop(&mut self) {
1137        self.control_handle.shutdown();
1138        // Safety: drops once, never accessed again
1139        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1140    }
1141}
1142
1143impl fidl::endpoints::Responder for DeviceGetConfigResponder {
1144    type ControlHandle = DeviceControlHandle;
1145
1146    fn control_handle(&self) -> &DeviceControlHandle {
1147        &self.control_handle
1148    }
1149
1150    fn drop_without_shutdown(mut self) {
1151        // Safety: drops once, never accessed again due to mem::forget
1152        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1153        // Prevent Drop from running (which would shut down the channel)
1154        std::mem::forget(self);
1155    }
1156}
1157
1158impl DeviceGetConfigResponder {
1159    /// Sends a response to the FIDL transaction.
1160    ///
1161    /// Sets the channel to shutdown if an error occurs.
1162    pub fn send(self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1163        let _result = self.send_raw(config);
1164        if _result.is_err() {
1165            self.control_handle.shutdown();
1166        }
1167        self.drop_without_shutdown();
1168        _result
1169    }
1170
1171    /// Similar to "send" but does not shutdown the channel if an error occurs.
1172    pub fn send_no_shutdown_on_err(self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1173        let _result = self.send_raw(config);
1174        self.drop_without_shutdown();
1175        _result
1176    }
1177
1178    fn send_raw(&self, mut config: &[u8; 104]) -> Result<(), fidl::Error> {
1179        self.control_handle.inner.send::<DeviceGetConfigResponse>(
1180            (config,),
1181            self.tx_id,
1182            0x41a72f916b11e11f,
1183            fidl::encoding::DynamicFlags::empty(),
1184        )
1185    }
1186}
1187
1188#[must_use = "FIDL methods require a response to be sent"]
1189#[derive(Debug)]
1190pub struct DeviceSetProcessedFifoDataResponder {
1191    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1192    tx_id: u32,
1193}
1194
1195/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1196/// if the responder is dropped without sending a response, so that the client
1197/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1198impl std::ops::Drop for DeviceSetProcessedFifoDataResponder {
1199    fn drop(&mut self) {
1200        self.control_handle.shutdown();
1201        // Safety: drops once, never accessed again
1202        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1203    }
1204}
1205
1206impl fidl::endpoints::Responder for DeviceSetProcessedFifoDataResponder {
1207    type ControlHandle = DeviceControlHandle;
1208
1209    fn control_handle(&self) -> &DeviceControlHandle {
1210        &self.control_handle
1211    }
1212
1213    fn drop_without_shutdown(mut self) {
1214        // Safety: drops once, never accessed again due to mem::forget
1215        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1216        // Prevent Drop from running (which would shut down the channel)
1217        std::mem::forget(self);
1218    }
1219}
1220
1221impl DeviceSetProcessedFifoDataResponder {
1222    /// Sends a response to the FIDL transaction.
1223    ///
1224    /// Sets the channel to shutdown if an error occurs.
1225    pub fn send(self) -> Result<(), fidl::Error> {
1226        let _result = self.send_raw();
1227        if _result.is_err() {
1228            self.control_handle.shutdown();
1229        }
1230        self.drop_without_shutdown();
1231        _result
1232    }
1233
1234    /// Similar to "send" but does not shutdown the channel if an error occurs.
1235    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1236        let _result = self.send_raw();
1237        self.drop_without_shutdown();
1238        _result
1239    }
1240
1241    fn send_raw(&self) -> Result<(), fidl::Error> {
1242        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1243            (),
1244            self.tx_id,
1245            0x4689e121bf9e884,
1246            fidl::encoding::DynamicFlags::empty(),
1247        )
1248    }
1249}
1250
1251#[must_use = "FIDL methods require a response to be sent"]
1252#[derive(Debug)]
1253pub struct DeviceGetStepAndJeitaParamsResponder {
1254    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1255    tx_id: u32,
1256}
1257
1258/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1259/// if the responder is dropped without sending a response, so that the client
1260/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1261impl std::ops::Drop for DeviceGetStepAndJeitaParamsResponder {
1262    fn drop(&mut self) {
1263        self.control_handle.shutdown();
1264        // Safety: drops once, never accessed again
1265        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1266    }
1267}
1268
1269impl fidl::endpoints::Responder for DeviceGetStepAndJeitaParamsResponder {
1270    type ControlHandle = DeviceControlHandle;
1271
1272    fn control_handle(&self) -> &DeviceControlHandle {
1273        &self.control_handle
1274    }
1275
1276    fn drop_without_shutdown(mut self) {
1277        // Safety: drops once, never accessed again due to mem::forget
1278        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1279        // Prevent Drop from running (which would shut down the channel)
1280        std::mem::forget(self);
1281    }
1282}
1283
1284impl DeviceGetStepAndJeitaParamsResponder {
1285    /// Sends a response to the FIDL transaction.
1286    ///
1287    /// Sets the channel to shutdown if an error occurs.
1288    pub fn send(self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1289        let _result = self.send_raw(params);
1290        if _result.is_err() {
1291            self.control_handle.shutdown();
1292        }
1293        self.drop_without_shutdown();
1294        _result
1295    }
1296
1297    /// Similar to "send" but does not shutdown the channel if an error occurs.
1298    pub fn send_no_shutdown_on_err(self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1299        let _result = self.send_raw(params);
1300        self.drop_without_shutdown();
1301        _result
1302    }
1303
1304    fn send_raw(&self, mut params: &[u8; 247]) -> Result<(), fidl::Error> {
1305        self.control_handle.inner.send::<DeviceGetStepAndJeitaParamsResponse>(
1306            (params,),
1307            self.tx_id,
1308            0x1c7ba411ae13b250,
1309            fidl::encoding::DynamicFlags::empty(),
1310        )
1311    }
1312}
1313
1314#[must_use = "FIDL methods require a response to be sent"]
1315#[derive(Debug)]
1316pub struct DeviceGetBatteryConfigResponder {
1317    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1318    tx_id: u32,
1319}
1320
1321/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1322/// if the responder is dropped without sending a response, so that the client
1323/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1324impl std::ops::Drop for DeviceGetBatteryConfigResponder {
1325    fn drop(&mut self) {
1326        self.control_handle.shutdown();
1327        // Safety: drops once, never accessed again
1328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1329    }
1330}
1331
1332impl fidl::endpoints::Responder for DeviceGetBatteryConfigResponder {
1333    type ControlHandle = DeviceControlHandle;
1334
1335    fn control_handle(&self) -> &DeviceControlHandle {
1336        &self.control_handle
1337    }
1338
1339    fn drop_without_shutdown(mut self) {
1340        // Safety: drops once, never accessed again due to mem::forget
1341        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1342        // Prevent Drop from running (which would shut down the channel)
1343        std::mem::forget(self);
1344    }
1345}
1346
1347impl DeviceGetBatteryConfigResponder {
1348    /// Sends a response to the FIDL transaction.
1349    ///
1350    /// Sets the channel to shutdown if an error occurs.
1351    pub fn send(self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
1352        let _result = self.send_raw(config);
1353        if _result.is_err() {
1354            self.control_handle.shutdown();
1355        }
1356        self.drop_without_shutdown();
1357        _result
1358    }
1359
1360    /// Similar to "send" but does not shutdown the channel if an error occurs.
1361    pub fn send_no_shutdown_on_err(self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
1362        let _result = self.send_raw(config);
1363        self.drop_without_shutdown();
1364        _result
1365    }
1366
1367    fn send_raw(&self, mut config: &[u8; 304]) -> Result<(), fidl::Error> {
1368        self.control_handle.inner.send::<DeviceGetBatteryConfigResponse>(
1369            (config,),
1370            self.tx_id,
1371            0x1790c60bf5e3dd40,
1372            fidl::encoding::DynamicFlags::empty(),
1373        )
1374    }
1375}
1376
1377#[must_use = "FIDL methods require a response to be sent"]
1378#[derive(Debug)]
1379pub struct DeviceGetBatteryProfileResponder {
1380    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1381    tx_id: u32,
1382}
1383
1384/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1385/// if the responder is dropped without sending a response, so that the client
1386/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1387impl std::ops::Drop for DeviceGetBatteryProfileResponder {
1388    fn drop(&mut self) {
1389        self.control_handle.shutdown();
1390        // Safety: drops once, never accessed again
1391        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1392    }
1393}
1394
1395impl fidl::endpoints::Responder for DeviceGetBatteryProfileResponder {
1396    type ControlHandle = DeviceControlHandle;
1397
1398    fn control_handle(&self) -> &DeviceControlHandle {
1399        &self.control_handle
1400    }
1401
1402    fn drop_without_shutdown(mut self) {
1403        // Safety: drops once, never accessed again due to mem::forget
1404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405        // Prevent Drop from running (which would shut down the channel)
1406        std::mem::forget(self);
1407    }
1408}
1409
1410impl DeviceGetBatteryProfileResponder {
1411    /// Sends a response to the FIDL transaction.
1412    ///
1413    /// Sets the channel to shutdown if an error occurs.
1414    pub fn send(self, mut result: Result<&[u8; 596], i32>) -> Result<(), fidl::Error> {
1415        let _result = self.send_raw(result);
1416        if _result.is_err() {
1417            self.control_handle.shutdown();
1418        }
1419        self.drop_without_shutdown();
1420        _result
1421    }
1422
1423    /// Similar to "send" but does not shutdown the channel if an error occurs.
1424    pub fn send_no_shutdown_on_err(
1425        self,
1426        mut result: Result<&[u8; 596], i32>,
1427    ) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw(result);
1429        self.drop_without_shutdown();
1430        _result
1431    }
1432
1433    fn send_raw(&self, mut result: Result<&[u8; 596], i32>) -> Result<(), fidl::Error> {
1434        self.control_handle
1435            .inner
1436            .send::<fidl::encoding::ResultType<DeviceGetBatteryProfileResponse, i32>>(
1437                result.map(|profile| (profile,)),
1438                self.tx_id,
1439                0x35f1cb1630c6079f,
1440                fidl::encoding::DynamicFlags::empty(),
1441            )
1442    }
1443}
1444
1445#[must_use = "FIDL methods require a response to be sent"]
1446#[derive(Debug)]
1447pub struct DeviceGetIioValueResponder {
1448    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1449    tx_id: u32,
1450}
1451
1452/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1453/// if the responder is dropped without sending a response, so that the client
1454/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1455impl std::ops::Drop for DeviceGetIioValueResponder {
1456    fn drop(&mut self) {
1457        self.control_handle.shutdown();
1458        // Safety: drops once, never accessed again
1459        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1460    }
1461}
1462
1463impl fidl::endpoints::Responder for DeviceGetIioValueResponder {
1464    type ControlHandle = DeviceControlHandle;
1465
1466    fn control_handle(&self) -> &DeviceControlHandle {
1467        &self.control_handle
1468    }
1469
1470    fn drop_without_shutdown(mut self) {
1471        // Safety: drops once, never accessed again due to mem::forget
1472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1473        // Prevent Drop from running (which would shut down the channel)
1474        std::mem::forget(self);
1475    }
1476}
1477
1478impl DeviceGetIioValueResponder {
1479    /// Sends a response to the FIDL transaction.
1480    ///
1481    /// Sets the channel to shutdown if an error occurs.
1482    pub fn send(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
1483        let _result = self.send_raw(result);
1484        if _result.is_err() {
1485            self.control_handle.shutdown();
1486        }
1487        self.drop_without_shutdown();
1488        _result
1489    }
1490
1491    /// Similar to "send" but does not shutdown the channel if an error occurs.
1492    pub fn send_no_shutdown_on_err(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
1493        let _result = self.send_raw(result);
1494        self.drop_without_shutdown();
1495        _result
1496    }
1497
1498    fn send_raw(&self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
1499        self.control_handle
1500            .inner
1501            .send::<fidl::encoding::ResultType<DeviceGetIioValueResponse, i32>>(
1502                result.map(|value| (value,)),
1503                self.tx_id,
1504                0x7e59fae7f9193277,
1505                fidl::encoding::DynamicFlags::empty(),
1506            )
1507    }
1508}
1509
1510#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1511pub struct ServiceMarker;
1512
1513#[cfg(target_os = "fuchsia")]
1514impl fidl::endpoints::ServiceMarker for ServiceMarker {
1515    type Proxy = ServiceProxy;
1516    type Request = ServiceRequest;
1517    const SERVICE_NAME: &'static str = "fuchsia.hardware.qcom.hvdcpopti.Service";
1518}
1519
1520/// A request for one of the member protocols of Service.
1521///
1522#[cfg(target_os = "fuchsia")]
1523pub enum ServiceRequest {
1524    Device(DeviceRequestStream),
1525}
1526
1527#[cfg(target_os = "fuchsia")]
1528impl fidl::endpoints::ServiceRequest for ServiceRequest {
1529    type Service = ServiceMarker;
1530
1531    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1532        match name {
1533            "device" => Self::Device(
1534                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1535            ),
1536            _ => panic!("no such member protocol name for service Service"),
1537        }
1538    }
1539
1540    fn member_names() -> &'static [&'static str] {
1541        &["device"]
1542    }
1543}
1544#[cfg(target_os = "fuchsia")]
1545pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1546
1547#[cfg(target_os = "fuchsia")]
1548impl fidl::endpoints::ServiceProxy for ServiceProxy {
1549    type Service = ServiceMarker;
1550
1551    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1552        Self(opener)
1553    }
1554}
1555
1556#[cfg(target_os = "fuchsia")]
1557impl ServiceProxy {
1558    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1559        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1560        self.connect_channel_to_device(server_end)?;
1561        Ok(proxy)
1562    }
1563
1564    /// Like `connect_to_device`, but returns a sync proxy.
1565    /// See [`Self::connect_to_device`] for more details.
1566    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1567        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1568        self.connect_channel_to_device(server_end)?;
1569        Ok(proxy)
1570    }
1571
1572    /// Like `connect_to_device`, but accepts a server end.
1573    /// See [`Self::connect_to_device`] for more details.
1574    pub fn connect_channel_to_device(
1575        &self,
1576        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1577    ) -> Result<(), fidl::Error> {
1578        self.0.open_member("device", server_end.into_channel())
1579    }
1580
1581    pub fn instance_name(&self) -> &str {
1582        self.0.instance_name()
1583    }
1584}
1585
1586mod internal {
1587    use super::*;
1588}