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