Skip to main content

fidl_fuchsia_hardware_google_odpm/
fidl_fuchsia_hardware_google_odpm.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_google_odpm_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct OdpmDeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for OdpmDeviceMarker {
18    type Proxy = OdpmDeviceProxy;
19    type RequestStream = OdpmDeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = OdpmDeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) OdpmDevice";
24}
25pub type OdpmDeviceGetRailMetadataResult = Result<Vec<RailMetadata>, i32>;
26pub type OdpmDeviceGetAvailableRailsResult = Result<Vec<RailMetadata>, i32>;
27pub type OdpmDeviceSetChannelRailResult = Result<(), i32>;
28pub type OdpmDeviceGetPowerWattsResult = Result<Vec<PowerReading>, i32>;
29pub type OdpmDeviceGetCurrentAmperesResult = Result<Vec<CurrentReading>, i32>;
30pub type OdpmDeviceGetEnergyJoulesResult = Result<Vec<EnergyReading>, i32>;
31pub type OdpmDeviceSetPollingConfigResult = Result<(), i32>;
32pub type OdpmDeviceGetPollingConfigResult = Result<PollingConfig, i32>;
33pub type OdpmDeviceResetPollingConfigResult = Result<(), i32>;
34
35pub trait OdpmDeviceProxyInterface: Send + Sync {
36    type GetRailMetadataResponseFut: std::future::Future<Output = Result<OdpmDeviceGetRailMetadataResult, fidl::Error>>
37        + Send;
38    fn r#get_rail_metadata(&self) -> Self::GetRailMetadataResponseFut;
39    type GetAvailableRailsResponseFut: std::future::Future<Output = Result<OdpmDeviceGetAvailableRailsResult, fidl::Error>>
40        + Send;
41    fn r#get_available_rails(&self) -> Self::GetAvailableRailsResponseFut;
42    type SetChannelRailResponseFut: std::future::Future<Output = Result<OdpmDeviceSetChannelRailResult, fidl::Error>>
43        + Send;
44    fn r#set_channel_rail(
45        &self,
46        channel_id: u32,
47        rail_name: &str,
48    ) -> Self::SetChannelRailResponseFut;
49    type GetPowerWattsResponseFut: std::future::Future<Output = Result<OdpmDeviceGetPowerWattsResult, fidl::Error>>
50        + Send;
51    fn r#get_power_watts(&self, payload: &Options) -> Self::GetPowerWattsResponseFut;
52    type GetCurrentAmperesResponseFut: std::future::Future<Output = Result<OdpmDeviceGetCurrentAmperesResult, fidl::Error>>
53        + Send;
54    fn r#get_current_amperes(&self, payload: &Options) -> Self::GetCurrentAmperesResponseFut;
55    type GetEnergyJoulesResponseFut: std::future::Future<Output = Result<OdpmDeviceGetEnergyJoulesResult, fidl::Error>>
56        + Send;
57    fn r#get_energy_joules(&self, payload: &Options) -> Self::GetEnergyJoulesResponseFut;
58    type SetPollingConfigResponseFut: std::future::Future<Output = Result<OdpmDeviceSetPollingConfigResult, fidl::Error>>
59        + Send;
60    fn r#set_polling_config(&self, payload: &PollingConfig) -> Self::SetPollingConfigResponseFut;
61    type GetPollingConfigResponseFut: std::future::Future<Output = Result<OdpmDeviceGetPollingConfigResult, fidl::Error>>
62        + Send;
63    fn r#get_polling_config(&self) -> Self::GetPollingConfigResponseFut;
64    type ResetPollingConfigResponseFut: std::future::Future<Output = Result<OdpmDeviceResetPollingConfigResult, fidl::Error>>
65        + Send;
66    fn r#reset_polling_config(&self) -> Self::ResetPollingConfigResponseFut;
67}
68#[derive(Debug)]
69#[cfg(target_os = "fuchsia")]
70pub struct OdpmDeviceSynchronousProxy {
71    client: fidl::client::sync::Client,
72}
73
74#[cfg(target_os = "fuchsia")]
75impl fidl::endpoints::SynchronousProxy for OdpmDeviceSynchronousProxy {
76    type Proxy = OdpmDeviceProxy;
77    type Protocol = OdpmDeviceMarker;
78
79    fn from_channel(inner: fidl::Channel) -> Self {
80        Self::new(inner)
81    }
82
83    fn into_channel(self) -> fidl::Channel {
84        self.client.into_channel()
85    }
86
87    fn as_channel(&self) -> &fidl::Channel {
88        self.client.as_channel()
89    }
90}
91
92#[cfg(target_os = "fuchsia")]
93impl OdpmDeviceSynchronousProxy {
94    pub fn new(channel: fidl::Channel) -> Self {
95        Self { client: fidl::client::sync::Client::new(channel) }
96    }
97
98    pub fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    /// Waits until an event arrives and returns it. It is safe for other
103    /// threads to make concurrent requests while waiting for an event.
104    pub fn wait_for_event(
105        &self,
106        deadline: zx::MonotonicInstant,
107    ) -> Result<OdpmDeviceEvent, fidl::Error> {
108        OdpmDeviceEvent::decode(self.client.wait_for_event::<OdpmDeviceMarker>(deadline)?)
109    }
110
111    /// Returns metadata for all actively-monitored rails.
112    pub fn r#get_rail_metadata(
113        &self,
114        ___deadline: zx::MonotonicInstant,
115    ) -> Result<OdpmDeviceGetRailMetadataResult, fidl::Error> {
116        let _response = self.client.send_query::<
117            fidl::encoding::EmptyPayload,
118            fidl::encoding::FlexibleResultType<OdpmDeviceGetRailMetadataResponse, i32>,
119            OdpmDeviceMarker,
120        >(
121            (),
122            0x1370e2e1a26954e7,
123            fidl::encoding::DynamicFlags::FLEXIBLE,
124            ___deadline,
125        )?
126        .into_result::<OdpmDeviceMarker>("get_rail_metadata")?;
127        Ok(_response.map(|x| x.rails))
128    }
129
130    /// Returns metadata for all available power rails supported by the hardware
131    /// (both actively-monitored and unmonitored).
132    ///
133    /// * `measurement_start` is reported for rails that are actively monitored or
134    ///   were previously monitored.
135    /// * `measurement_stop` and `energy_uj` are reported only for rails that have
136    ///   been swapped out, retaining only the most recent completed measurement
137    ///   window (rather than an entry per session or an aggregate across sessions).
138    ///   If a stopped rail is swapped back onto an active channel, its previous
139    ///   stopped reading (`measurement_stop` and `energy_uj`) is cleared and a new
140    ///   measurement window begins.
141    ///
142    /// Returns `ZX_ERR_INTERNAL` if internal rail state cannot be retrieved.
143    pub fn r#get_available_rails(
144        &self,
145        ___deadline: zx::MonotonicInstant,
146    ) -> Result<OdpmDeviceGetAvailableRailsResult, fidl::Error> {
147        let _response = self.client.send_query::<
148            fidl::encoding::EmptyPayload,
149            fidl::encoding::FlexibleResultType<OdpmDeviceGetAvailableRailsResponse, i32>,
150            OdpmDeviceMarker,
151        >(
152            (),
153            0x5d2f432497df351a,
154            fidl::encoding::DynamicFlags::FLEXIBLE,
155            ___deadline,
156        )?
157        .into_result::<OdpmDeviceMarker>("get_available_rails")?;
158        Ok(_response.map(|x| x.rails))
159    }
160
161    /// Reconfigures an internal telemetry channel (`channel_id`) to monitor `rail_name`
162    /// (matched case-insensitively against `name`, `regulator_name`, or `schematic_name`).
163    ///
164    /// The new assignment is visible to all clients: readings for `channel_id` from
165    /// `GetPowerWatts`, `GetCurrentAmperes`, and `GetEnergyJoules` then refer to `rail_name`
166    /// and restart from a new measurement window. Clients that cache `GetRailMetadata` can
167    /// detect the change by re-querying it and comparing `name` or `measurement_start`.
168    ///
169    /// Returns:
170    /// * `ZX_OK` (as a no-op) if `channel_id` is already actively monitoring `rail_name`.
171    /// * `ZX_ERR_NOT_FOUND` if `rail_name` does not match any available rail.
172    /// * `ZX_ERR_INVALID_ARGS` if `channel_id` is invalid, is an external shunt channel,
173    ///   or if the requested rail is an external shunt rail or belongs to a different PMIC
174    ///   than `channel_id`.
175    /// * `ZX_ERR_ALREADY_BOUND` if the requested rail is already monitored on a different
176    ///   active channel.
177    /// * `ZX_ERR_UNAVAILABLE` if the hardware operation fails.
178    /// * `ZX_ERR_INTERNAL` if an internal driver error occurs.
179    pub fn r#set_channel_rail(
180        &self,
181        mut channel_id: u32,
182        mut rail_name: &str,
183        ___deadline: zx::MonotonicInstant,
184    ) -> Result<OdpmDeviceSetChannelRailResult, fidl::Error> {
185        let _response = self.client.send_query::<
186            OdpmDeviceSetChannelRailRequest,
187            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
188            OdpmDeviceMarker,
189        >(
190            (channel_id, rail_name,),
191            0x59748499a188a657,
192            fidl::encoding::DynamicFlags::FLEXIBLE,
193            ___deadline,
194        )?
195        .into_result::<OdpmDeviceMarker>("set_channel_rail")?;
196        Ok(_response.map(|x| x))
197    }
198
199    /// Returns the power consumption for all actively-monitored rails.
200    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
201    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
202    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
203    pub fn r#get_power_watts(
204        &self,
205        mut payload: &Options,
206        ___deadline: zx::MonotonicInstant,
207    ) -> Result<OdpmDeviceGetPowerWattsResult, fidl::Error> {
208        let _response = self.client.send_query::<
209            Options,
210            fidl::encoding::FlexibleResultType<OdpmDeviceGetPowerWattsResponse, i32>,
211            OdpmDeviceMarker,
212        >(
213            payload,
214            0x2e26ec237d170791,
215            fidl::encoding::DynamicFlags::FLEXIBLE,
216            ___deadline,
217        )?
218        .into_result::<OdpmDeviceMarker>("get_power_watts")?;
219        Ok(_response.map(|x| x.readings))
220    }
221
222    /// Returns the current for all actively-monitored rails.
223    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
224    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
225    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
226    pub fn r#get_current_amperes(
227        &self,
228        mut payload: &Options,
229        ___deadline: zx::MonotonicInstant,
230    ) -> Result<OdpmDeviceGetCurrentAmperesResult, fidl::Error> {
231        let _response = self.client.send_query::<
232            Options,
233            fidl::encoding::FlexibleResultType<OdpmDeviceGetCurrentAmperesResponse, i32>,
234            OdpmDeviceMarker,
235        >(
236            payload,
237            0x2efa123da8afbcec,
238            fidl::encoding::DynamicFlags::FLEXIBLE,
239            ___deadline,
240        )?
241        .into_result::<OdpmDeviceMarker>("get_current_amperes")?;
242        Ok(_response.map(|x| x.readings))
243    }
244
245    /// Returns the energy consumption for all actively-monitored rails.
246    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
247    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
248    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
249    pub fn r#get_energy_joules(
250        &self,
251        mut payload: &Options,
252        ___deadline: zx::MonotonicInstant,
253    ) -> Result<OdpmDeviceGetEnergyJoulesResult, fidl::Error> {
254        let _response = self.client.send_query::<
255            Options,
256            fidl::encoding::FlexibleResultType<OdpmDeviceGetEnergyJoulesResponse, i32>,
257            OdpmDeviceMarker,
258        >(
259            payload,
260            0x25bf6e4b27991b1c,
261            fidl::encoding::DynamicFlags::FLEXIBLE,
262            ___deadline,
263        )?
264        .into_result::<OdpmDeviceMarker>("get_energy_joules")?;
265        Ok(_response.map(|x| x.readings))
266    }
267
268    /// Overrides polling configuration parameters. Any omitted fields in `PollingConfig`
269    /// remain unchanged.
270    /// Returns `ZX_ERR_INVALID_ARGS` if `poll_interval` is less than `MIN_POLL_INTERVAL` or
271    /// `polls_per_series_entry` == 0.
272    pub fn r#set_polling_config(
273        &self,
274        mut payload: &PollingConfig,
275        ___deadline: zx::MonotonicInstant,
276    ) -> Result<OdpmDeviceSetPollingConfigResult, fidl::Error> {
277        let _response = self.client.send_query::<
278            PollingConfig,
279            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
280            OdpmDeviceMarker,
281        >(
282            payload,
283            0x23821a66e6c6647d,
284            fidl::encoding::DynamicFlags::FLEXIBLE,
285            ___deadline,
286        )?
287        .into_result::<OdpmDeviceMarker>("set_polling_config")?;
288        Ok(_response.map(|x| x))
289    }
290
291    /// Retrieves the current polling configuration parameters.
292    pub fn r#get_polling_config(
293        &self,
294        ___deadline: zx::MonotonicInstant,
295    ) -> Result<OdpmDeviceGetPollingConfigResult, fidl::Error> {
296        let _response = self.client.send_query::<
297            fidl::encoding::EmptyPayload,
298            fidl::encoding::FlexibleResultType<PollingConfig, i32>,
299            OdpmDeviceMarker,
300        >(
301            (),
302            0x476f23167a254bd3,
303            fidl::encoding::DynamicFlags::FLEXIBLE,
304            ___deadline,
305        )?
306        .into_result::<OdpmDeviceMarker>("get_polling_config")?;
307        Ok(_response.map(|x| x))
308    }
309
310    /// Resets polling configuration parameters to the driver's default values.
311    pub fn r#reset_polling_config(
312        &self,
313        ___deadline: zx::MonotonicInstant,
314    ) -> Result<OdpmDeviceResetPollingConfigResult, fidl::Error> {
315        let _response = self.client.send_query::<
316            fidl::encoding::EmptyPayload,
317            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
318            OdpmDeviceMarker,
319        >(
320            (),
321            0x182591ccbe96a9d,
322            fidl::encoding::DynamicFlags::FLEXIBLE,
323            ___deadline,
324        )?
325        .into_result::<OdpmDeviceMarker>("reset_polling_config")?;
326        Ok(_response.map(|x| x))
327    }
328}
329
330#[cfg(target_os = "fuchsia")]
331impl From<OdpmDeviceSynchronousProxy> for zx::NullableHandle {
332    fn from(value: OdpmDeviceSynchronousProxy) -> Self {
333        value.into_channel().into()
334    }
335}
336
337#[cfg(target_os = "fuchsia")]
338impl From<fidl::Channel> for OdpmDeviceSynchronousProxy {
339    fn from(value: fidl::Channel) -> Self {
340        Self::new(value)
341    }
342}
343
344#[cfg(target_os = "fuchsia")]
345impl fidl::endpoints::FromClient for OdpmDeviceSynchronousProxy {
346    type Protocol = OdpmDeviceMarker;
347
348    fn from_client(value: fidl::endpoints::ClientEnd<OdpmDeviceMarker>) -> Self {
349        Self::new(value.into_channel())
350    }
351}
352
353#[derive(Debug, Clone)]
354pub struct OdpmDeviceProxy {
355    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
356}
357
358impl fidl::endpoints::Proxy for OdpmDeviceProxy {
359    type Protocol = OdpmDeviceMarker;
360
361    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
362        Self::new(inner)
363    }
364
365    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
366        self.client.into_channel().map_err(|client| Self { client })
367    }
368
369    fn as_channel(&self) -> &::fidl::AsyncChannel {
370        self.client.as_channel()
371    }
372}
373
374impl OdpmDeviceProxy {
375    /// Create a new Proxy for fuchsia.hardware.google.odpm/OdpmDevice.
376    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
377        let protocol_name = <OdpmDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
378        Self { client: fidl::client::Client::new(channel, protocol_name) }
379    }
380
381    /// Get a Stream of events from the remote end of the protocol.
382    ///
383    /// # Panics
384    ///
385    /// Panics if the event stream was already taken.
386    pub fn take_event_stream(&self) -> OdpmDeviceEventStream {
387        OdpmDeviceEventStream { event_receiver: self.client.take_event_receiver() }
388    }
389
390    /// Returns metadata for all actively-monitored rails.
391    pub fn r#get_rail_metadata(
392        &self,
393    ) -> fidl::client::QueryResponseFut<
394        OdpmDeviceGetRailMetadataResult,
395        fidl::encoding::DefaultFuchsiaResourceDialect,
396    > {
397        OdpmDeviceProxyInterface::r#get_rail_metadata(self)
398    }
399
400    /// Returns metadata for all available power rails supported by the hardware
401    /// (both actively-monitored and unmonitored).
402    ///
403    /// * `measurement_start` is reported for rails that are actively monitored or
404    ///   were previously monitored.
405    /// * `measurement_stop` and `energy_uj` are reported only for rails that have
406    ///   been swapped out, retaining only the most recent completed measurement
407    ///   window (rather than an entry per session or an aggregate across sessions).
408    ///   If a stopped rail is swapped back onto an active channel, its previous
409    ///   stopped reading (`measurement_stop` and `energy_uj`) is cleared and a new
410    ///   measurement window begins.
411    ///
412    /// Returns `ZX_ERR_INTERNAL` if internal rail state cannot be retrieved.
413    pub fn r#get_available_rails(
414        &self,
415    ) -> fidl::client::QueryResponseFut<
416        OdpmDeviceGetAvailableRailsResult,
417        fidl::encoding::DefaultFuchsiaResourceDialect,
418    > {
419        OdpmDeviceProxyInterface::r#get_available_rails(self)
420    }
421
422    /// Reconfigures an internal telemetry channel (`channel_id`) to monitor `rail_name`
423    /// (matched case-insensitively against `name`, `regulator_name`, or `schematic_name`).
424    ///
425    /// The new assignment is visible to all clients: readings for `channel_id` from
426    /// `GetPowerWatts`, `GetCurrentAmperes`, and `GetEnergyJoules` then refer to `rail_name`
427    /// and restart from a new measurement window. Clients that cache `GetRailMetadata` can
428    /// detect the change by re-querying it and comparing `name` or `measurement_start`.
429    ///
430    /// Returns:
431    /// * `ZX_OK` (as a no-op) if `channel_id` is already actively monitoring `rail_name`.
432    /// * `ZX_ERR_NOT_FOUND` if `rail_name` does not match any available rail.
433    /// * `ZX_ERR_INVALID_ARGS` if `channel_id` is invalid, is an external shunt channel,
434    ///   or if the requested rail is an external shunt rail or belongs to a different PMIC
435    ///   than `channel_id`.
436    /// * `ZX_ERR_ALREADY_BOUND` if the requested rail is already monitored on a different
437    ///   active channel.
438    /// * `ZX_ERR_UNAVAILABLE` if the hardware operation fails.
439    /// * `ZX_ERR_INTERNAL` if an internal driver error occurs.
440    pub fn r#set_channel_rail(
441        &self,
442        mut channel_id: u32,
443        mut rail_name: &str,
444    ) -> fidl::client::QueryResponseFut<
445        OdpmDeviceSetChannelRailResult,
446        fidl::encoding::DefaultFuchsiaResourceDialect,
447    > {
448        OdpmDeviceProxyInterface::r#set_channel_rail(self, channel_id, rail_name)
449    }
450
451    /// Returns the power consumption for all actively-monitored rails.
452    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
453    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
454    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
455    pub fn r#get_power_watts(
456        &self,
457        mut payload: &Options,
458    ) -> fidl::client::QueryResponseFut<
459        OdpmDeviceGetPowerWattsResult,
460        fidl::encoding::DefaultFuchsiaResourceDialect,
461    > {
462        OdpmDeviceProxyInterface::r#get_power_watts(self, payload)
463    }
464
465    /// Returns the current for all actively-monitored rails.
466    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
467    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
468    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
469    pub fn r#get_current_amperes(
470        &self,
471        mut payload: &Options,
472    ) -> fidl::client::QueryResponseFut<
473        OdpmDeviceGetCurrentAmperesResult,
474        fidl::encoding::DefaultFuchsiaResourceDialect,
475    > {
476        OdpmDeviceProxyInterface::r#get_current_amperes(self, payload)
477    }
478
479    /// Returns the energy consumption for all actively-monitored rails.
480    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
481    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
482    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
483    pub fn r#get_energy_joules(
484        &self,
485        mut payload: &Options,
486    ) -> fidl::client::QueryResponseFut<
487        OdpmDeviceGetEnergyJoulesResult,
488        fidl::encoding::DefaultFuchsiaResourceDialect,
489    > {
490        OdpmDeviceProxyInterface::r#get_energy_joules(self, payload)
491    }
492
493    /// Overrides polling configuration parameters. Any omitted fields in `PollingConfig`
494    /// remain unchanged.
495    /// Returns `ZX_ERR_INVALID_ARGS` if `poll_interval` is less than `MIN_POLL_INTERVAL` or
496    /// `polls_per_series_entry` == 0.
497    pub fn r#set_polling_config(
498        &self,
499        mut payload: &PollingConfig,
500    ) -> fidl::client::QueryResponseFut<
501        OdpmDeviceSetPollingConfigResult,
502        fidl::encoding::DefaultFuchsiaResourceDialect,
503    > {
504        OdpmDeviceProxyInterface::r#set_polling_config(self, payload)
505    }
506
507    /// Retrieves the current polling configuration parameters.
508    pub fn r#get_polling_config(
509        &self,
510    ) -> fidl::client::QueryResponseFut<
511        OdpmDeviceGetPollingConfigResult,
512        fidl::encoding::DefaultFuchsiaResourceDialect,
513    > {
514        OdpmDeviceProxyInterface::r#get_polling_config(self)
515    }
516
517    /// Resets polling configuration parameters to the driver's default values.
518    pub fn r#reset_polling_config(
519        &self,
520    ) -> fidl::client::QueryResponseFut<
521        OdpmDeviceResetPollingConfigResult,
522        fidl::encoding::DefaultFuchsiaResourceDialect,
523    > {
524        OdpmDeviceProxyInterface::r#reset_polling_config(self)
525    }
526}
527
528impl OdpmDeviceProxyInterface for OdpmDeviceProxy {
529    type GetRailMetadataResponseFut = fidl::client::QueryResponseFut<
530        OdpmDeviceGetRailMetadataResult,
531        fidl::encoding::DefaultFuchsiaResourceDialect,
532    >;
533    fn r#get_rail_metadata(&self) -> Self::GetRailMetadataResponseFut {
534        fn _decode(
535            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
536        ) -> Result<OdpmDeviceGetRailMetadataResult, fidl::Error> {
537            let _response = fidl::client::decode_transaction_body::<
538                fidl::encoding::FlexibleResultType<OdpmDeviceGetRailMetadataResponse, i32>,
539                fidl::encoding::DefaultFuchsiaResourceDialect,
540                0x1370e2e1a26954e7,
541            >(_buf?)?
542            .into_result::<OdpmDeviceMarker>("get_rail_metadata")?;
543            Ok(_response.map(|x| x.rails))
544        }
545        self.client
546            .send_query_and_decode::<fidl::encoding::EmptyPayload, OdpmDeviceGetRailMetadataResult>(
547                (),
548                0x1370e2e1a26954e7,
549                fidl::encoding::DynamicFlags::FLEXIBLE,
550                _decode,
551            )
552    }
553
554    type GetAvailableRailsResponseFut = fidl::client::QueryResponseFut<
555        OdpmDeviceGetAvailableRailsResult,
556        fidl::encoding::DefaultFuchsiaResourceDialect,
557    >;
558    fn r#get_available_rails(&self) -> Self::GetAvailableRailsResponseFut {
559        fn _decode(
560            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
561        ) -> Result<OdpmDeviceGetAvailableRailsResult, fidl::Error> {
562            let _response = fidl::client::decode_transaction_body::<
563                fidl::encoding::FlexibleResultType<OdpmDeviceGetAvailableRailsResponse, i32>,
564                fidl::encoding::DefaultFuchsiaResourceDialect,
565                0x5d2f432497df351a,
566            >(_buf?)?
567            .into_result::<OdpmDeviceMarker>("get_available_rails")?;
568            Ok(_response.map(|x| x.rails))
569        }
570        self.client.send_query_and_decode::<
571            fidl::encoding::EmptyPayload,
572            OdpmDeviceGetAvailableRailsResult,
573        >(
574            (),
575            0x5d2f432497df351a,
576            fidl::encoding::DynamicFlags::FLEXIBLE,
577            _decode,
578        )
579    }
580
581    type SetChannelRailResponseFut = fidl::client::QueryResponseFut<
582        OdpmDeviceSetChannelRailResult,
583        fidl::encoding::DefaultFuchsiaResourceDialect,
584    >;
585    fn r#set_channel_rail(
586        &self,
587        mut channel_id: u32,
588        mut rail_name: &str,
589    ) -> Self::SetChannelRailResponseFut {
590        fn _decode(
591            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
592        ) -> Result<OdpmDeviceSetChannelRailResult, fidl::Error> {
593            let _response = fidl::client::decode_transaction_body::<
594                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
595                fidl::encoding::DefaultFuchsiaResourceDialect,
596                0x59748499a188a657,
597            >(_buf?)?
598            .into_result::<OdpmDeviceMarker>("set_channel_rail")?;
599            Ok(_response.map(|x| x))
600        }
601        self.client.send_query_and_decode::<
602            OdpmDeviceSetChannelRailRequest,
603            OdpmDeviceSetChannelRailResult,
604        >(
605            (channel_id, rail_name,),
606            0x59748499a188a657,
607            fidl::encoding::DynamicFlags::FLEXIBLE,
608            _decode,
609        )
610    }
611
612    type GetPowerWattsResponseFut = fidl::client::QueryResponseFut<
613        OdpmDeviceGetPowerWattsResult,
614        fidl::encoding::DefaultFuchsiaResourceDialect,
615    >;
616    fn r#get_power_watts(&self, mut payload: &Options) -> Self::GetPowerWattsResponseFut {
617        fn _decode(
618            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
619        ) -> Result<OdpmDeviceGetPowerWattsResult, fidl::Error> {
620            let _response = fidl::client::decode_transaction_body::<
621                fidl::encoding::FlexibleResultType<OdpmDeviceGetPowerWattsResponse, i32>,
622                fidl::encoding::DefaultFuchsiaResourceDialect,
623                0x2e26ec237d170791,
624            >(_buf?)?
625            .into_result::<OdpmDeviceMarker>("get_power_watts")?;
626            Ok(_response.map(|x| x.readings))
627        }
628        self.client.send_query_and_decode::<Options, OdpmDeviceGetPowerWattsResult>(
629            payload,
630            0x2e26ec237d170791,
631            fidl::encoding::DynamicFlags::FLEXIBLE,
632            _decode,
633        )
634    }
635
636    type GetCurrentAmperesResponseFut = fidl::client::QueryResponseFut<
637        OdpmDeviceGetCurrentAmperesResult,
638        fidl::encoding::DefaultFuchsiaResourceDialect,
639    >;
640    fn r#get_current_amperes(&self, mut payload: &Options) -> Self::GetCurrentAmperesResponseFut {
641        fn _decode(
642            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
643        ) -> Result<OdpmDeviceGetCurrentAmperesResult, fidl::Error> {
644            let _response = fidl::client::decode_transaction_body::<
645                fidl::encoding::FlexibleResultType<OdpmDeviceGetCurrentAmperesResponse, i32>,
646                fidl::encoding::DefaultFuchsiaResourceDialect,
647                0x2efa123da8afbcec,
648            >(_buf?)?
649            .into_result::<OdpmDeviceMarker>("get_current_amperes")?;
650            Ok(_response.map(|x| x.readings))
651        }
652        self.client.send_query_and_decode::<Options, OdpmDeviceGetCurrentAmperesResult>(
653            payload,
654            0x2efa123da8afbcec,
655            fidl::encoding::DynamicFlags::FLEXIBLE,
656            _decode,
657        )
658    }
659
660    type GetEnergyJoulesResponseFut = fidl::client::QueryResponseFut<
661        OdpmDeviceGetEnergyJoulesResult,
662        fidl::encoding::DefaultFuchsiaResourceDialect,
663    >;
664    fn r#get_energy_joules(&self, mut payload: &Options) -> Self::GetEnergyJoulesResponseFut {
665        fn _decode(
666            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
667        ) -> Result<OdpmDeviceGetEnergyJoulesResult, fidl::Error> {
668            let _response = fidl::client::decode_transaction_body::<
669                fidl::encoding::FlexibleResultType<OdpmDeviceGetEnergyJoulesResponse, i32>,
670                fidl::encoding::DefaultFuchsiaResourceDialect,
671                0x25bf6e4b27991b1c,
672            >(_buf?)?
673            .into_result::<OdpmDeviceMarker>("get_energy_joules")?;
674            Ok(_response.map(|x| x.readings))
675        }
676        self.client.send_query_and_decode::<Options, OdpmDeviceGetEnergyJoulesResult>(
677            payload,
678            0x25bf6e4b27991b1c,
679            fidl::encoding::DynamicFlags::FLEXIBLE,
680            _decode,
681        )
682    }
683
684    type SetPollingConfigResponseFut = fidl::client::QueryResponseFut<
685        OdpmDeviceSetPollingConfigResult,
686        fidl::encoding::DefaultFuchsiaResourceDialect,
687    >;
688    fn r#set_polling_config(
689        &self,
690        mut payload: &PollingConfig,
691    ) -> Self::SetPollingConfigResponseFut {
692        fn _decode(
693            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
694        ) -> Result<OdpmDeviceSetPollingConfigResult, fidl::Error> {
695            let _response = fidl::client::decode_transaction_body::<
696                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
697                fidl::encoding::DefaultFuchsiaResourceDialect,
698                0x23821a66e6c6647d,
699            >(_buf?)?
700            .into_result::<OdpmDeviceMarker>("set_polling_config")?;
701            Ok(_response.map(|x| x))
702        }
703        self.client.send_query_and_decode::<PollingConfig, OdpmDeviceSetPollingConfigResult>(
704            payload,
705            0x23821a66e6c6647d,
706            fidl::encoding::DynamicFlags::FLEXIBLE,
707            _decode,
708        )
709    }
710
711    type GetPollingConfigResponseFut = fidl::client::QueryResponseFut<
712        OdpmDeviceGetPollingConfigResult,
713        fidl::encoding::DefaultFuchsiaResourceDialect,
714    >;
715    fn r#get_polling_config(&self) -> Self::GetPollingConfigResponseFut {
716        fn _decode(
717            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
718        ) -> Result<OdpmDeviceGetPollingConfigResult, fidl::Error> {
719            let _response = fidl::client::decode_transaction_body::<
720                fidl::encoding::FlexibleResultType<PollingConfig, i32>,
721                fidl::encoding::DefaultFuchsiaResourceDialect,
722                0x476f23167a254bd3,
723            >(_buf?)?
724            .into_result::<OdpmDeviceMarker>("get_polling_config")?;
725            Ok(_response.map(|x| x))
726        }
727        self.client.send_query_and_decode::<
728            fidl::encoding::EmptyPayload,
729            OdpmDeviceGetPollingConfigResult,
730        >(
731            (),
732            0x476f23167a254bd3,
733            fidl::encoding::DynamicFlags::FLEXIBLE,
734            _decode,
735        )
736    }
737
738    type ResetPollingConfigResponseFut = fidl::client::QueryResponseFut<
739        OdpmDeviceResetPollingConfigResult,
740        fidl::encoding::DefaultFuchsiaResourceDialect,
741    >;
742    fn r#reset_polling_config(&self) -> Self::ResetPollingConfigResponseFut {
743        fn _decode(
744            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
745        ) -> Result<OdpmDeviceResetPollingConfigResult, fidl::Error> {
746            let _response = fidl::client::decode_transaction_body::<
747                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
748                fidl::encoding::DefaultFuchsiaResourceDialect,
749                0x182591ccbe96a9d,
750            >(_buf?)?
751            .into_result::<OdpmDeviceMarker>("reset_polling_config")?;
752            Ok(_response.map(|x| x))
753        }
754        self.client.send_query_and_decode::<
755            fidl::encoding::EmptyPayload,
756            OdpmDeviceResetPollingConfigResult,
757        >(
758            (),
759            0x182591ccbe96a9d,
760            fidl::encoding::DynamicFlags::FLEXIBLE,
761            _decode,
762        )
763    }
764}
765
766pub struct OdpmDeviceEventStream {
767    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
768}
769
770impl std::marker::Unpin for OdpmDeviceEventStream {}
771
772impl futures::stream::FusedStream for OdpmDeviceEventStream {
773    fn is_terminated(&self) -> bool {
774        self.event_receiver.is_terminated()
775    }
776}
777
778impl futures::Stream for OdpmDeviceEventStream {
779    type Item = Result<OdpmDeviceEvent, fidl::Error>;
780
781    fn poll_next(
782        mut self: std::pin::Pin<&mut Self>,
783        cx: &mut std::task::Context<'_>,
784    ) -> std::task::Poll<Option<Self::Item>> {
785        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
786            &mut self.event_receiver,
787            cx
788        )?) {
789            Some(buf) => std::task::Poll::Ready(Some(OdpmDeviceEvent::decode(buf))),
790            None => std::task::Poll::Ready(None),
791        }
792    }
793}
794
795#[derive(Debug)]
796pub enum OdpmDeviceEvent {
797    #[non_exhaustive]
798    _UnknownEvent {
799        /// Ordinal of the event that was sent.
800        ordinal: u64,
801    },
802}
803
804impl OdpmDeviceEvent {
805    /// Decodes a message buffer as a [`OdpmDeviceEvent`].
806    fn decode(
807        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
808    ) -> Result<OdpmDeviceEvent, fidl::Error> {
809        let (bytes, _handles) = buf.split_mut();
810        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
811        debug_assert_eq!(tx_header.tx_id, 0);
812        match tx_header.ordinal {
813            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
814                Ok(OdpmDeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
815            }
816            _ => Err(fidl::Error::UnknownOrdinal {
817                ordinal: tx_header.ordinal,
818                protocol_name: <OdpmDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
819            }),
820        }
821    }
822}
823
824/// A Stream of incoming requests for fuchsia.hardware.google.odpm/OdpmDevice.
825pub struct OdpmDeviceRequestStream {
826    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
827    is_terminated: bool,
828}
829
830impl std::marker::Unpin for OdpmDeviceRequestStream {}
831
832impl futures::stream::FusedStream for OdpmDeviceRequestStream {
833    fn is_terminated(&self) -> bool {
834        self.is_terminated
835    }
836}
837
838impl fidl::endpoints::RequestStream for OdpmDeviceRequestStream {
839    type Protocol = OdpmDeviceMarker;
840    type ControlHandle = OdpmDeviceControlHandle;
841
842    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
843        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
844    }
845
846    fn control_handle(&self) -> Self::ControlHandle {
847        OdpmDeviceControlHandle { inner: self.inner.clone() }
848    }
849
850    fn into_inner(
851        self,
852    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
853    {
854        (self.inner, self.is_terminated)
855    }
856
857    fn from_inner(
858        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
859        is_terminated: bool,
860    ) -> Self {
861        Self { inner, is_terminated }
862    }
863}
864
865impl futures::Stream for OdpmDeviceRequestStream {
866    type Item = Result<OdpmDeviceRequest, fidl::Error>;
867
868    fn poll_next(
869        mut self: std::pin::Pin<&mut Self>,
870        cx: &mut std::task::Context<'_>,
871    ) -> std::task::Poll<Option<Self::Item>> {
872        let this = &mut *self;
873        if this.inner.check_shutdown(cx) {
874            this.is_terminated = true;
875            return std::task::Poll::Ready(None);
876        }
877        if this.is_terminated {
878            panic!("polled OdpmDeviceRequestStream after completion");
879        }
880        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
881            |bytes, handles| {
882                match this.inner.channel().read_etc(cx, bytes, handles) {
883                    std::task::Poll::Ready(Ok(())) => {}
884                    std::task::Poll::Pending => return std::task::Poll::Pending,
885                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
886                        this.is_terminated = true;
887                        return std::task::Poll::Ready(None);
888                    }
889                    std::task::Poll::Ready(Err(e)) => {
890                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
891                            e.into(),
892                        ))));
893                    }
894                }
895
896                // A message has been received from the channel
897                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
898
899                std::task::Poll::Ready(Some(match header.ordinal {
900                    0x1370e2e1a26954e7 => {
901                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
902                        let mut req = fidl::new_empty!(
903                            fidl::encoding::EmptyPayload,
904                            fidl::encoding::DefaultFuchsiaResourceDialect
905                        );
906                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
907                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
908                        Ok(OdpmDeviceRequest::GetRailMetadata {
909                            responder: OdpmDeviceGetRailMetadataResponder {
910                                control_handle: std::mem::ManuallyDrop::new(control_handle),
911                                tx_id: header.tx_id,
912                            },
913                        })
914                    }
915                    0x5d2f432497df351a => {
916                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
917                        let mut req = fidl::new_empty!(
918                            fidl::encoding::EmptyPayload,
919                            fidl::encoding::DefaultFuchsiaResourceDialect
920                        );
921                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
922                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
923                        Ok(OdpmDeviceRequest::GetAvailableRails {
924                            responder: OdpmDeviceGetAvailableRailsResponder {
925                                control_handle: std::mem::ManuallyDrop::new(control_handle),
926                                tx_id: header.tx_id,
927                            },
928                        })
929                    }
930                    0x59748499a188a657 => {
931                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
932                        let mut req = fidl::new_empty!(
933                            OdpmDeviceSetChannelRailRequest,
934                            fidl::encoding::DefaultFuchsiaResourceDialect
935                        );
936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<OdpmDeviceSetChannelRailRequest>(&header, _body_bytes, handles, &mut req)?;
937                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
938                        Ok(OdpmDeviceRequest::SetChannelRail {
939                            channel_id: req.channel_id,
940                            rail_name: req.rail_name,
941
942                            responder: OdpmDeviceSetChannelRailResponder {
943                                control_handle: std::mem::ManuallyDrop::new(control_handle),
944                                tx_id: header.tx_id,
945                            },
946                        })
947                    }
948                    0x2e26ec237d170791 => {
949                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
950                        let mut req = fidl::new_empty!(
951                            Options,
952                            fidl::encoding::DefaultFuchsiaResourceDialect
953                        );
954                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
955                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
956                        Ok(OdpmDeviceRequest::GetPowerWatts {
957                            payload: req,
958                            responder: OdpmDeviceGetPowerWattsResponder {
959                                control_handle: std::mem::ManuallyDrop::new(control_handle),
960                                tx_id: header.tx_id,
961                            },
962                        })
963                    }
964                    0x2efa123da8afbcec => {
965                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
966                        let mut req = fidl::new_empty!(
967                            Options,
968                            fidl::encoding::DefaultFuchsiaResourceDialect
969                        );
970                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
971                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
972                        Ok(OdpmDeviceRequest::GetCurrentAmperes {
973                            payload: req,
974                            responder: OdpmDeviceGetCurrentAmperesResponder {
975                                control_handle: std::mem::ManuallyDrop::new(control_handle),
976                                tx_id: header.tx_id,
977                            },
978                        })
979                    }
980                    0x25bf6e4b27991b1c => {
981                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
982                        let mut req = fidl::new_empty!(
983                            Options,
984                            fidl::encoding::DefaultFuchsiaResourceDialect
985                        );
986                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
987                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
988                        Ok(OdpmDeviceRequest::GetEnergyJoules {
989                            payload: req,
990                            responder: OdpmDeviceGetEnergyJoulesResponder {
991                                control_handle: std::mem::ManuallyDrop::new(control_handle),
992                                tx_id: header.tx_id,
993                            },
994                        })
995                    }
996                    0x23821a66e6c6647d => {
997                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
998                        let mut req = fidl::new_empty!(
999                            PollingConfig,
1000                            fidl::encoding::DefaultFuchsiaResourceDialect
1001                        );
1002                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PollingConfig>(&header, _body_bytes, handles, &mut req)?;
1003                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
1004                        Ok(OdpmDeviceRequest::SetPollingConfig {
1005                            payload: req,
1006                            responder: OdpmDeviceSetPollingConfigResponder {
1007                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1008                                tx_id: header.tx_id,
1009                            },
1010                        })
1011                    }
1012                    0x476f23167a254bd3 => {
1013                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1014                        let mut req = fidl::new_empty!(
1015                            fidl::encoding::EmptyPayload,
1016                            fidl::encoding::DefaultFuchsiaResourceDialect
1017                        );
1018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1019                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
1020                        Ok(OdpmDeviceRequest::GetPollingConfig {
1021                            responder: OdpmDeviceGetPollingConfigResponder {
1022                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1023                                tx_id: header.tx_id,
1024                            },
1025                        })
1026                    }
1027                    0x182591ccbe96a9d => {
1028                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1029                        let mut req = fidl::new_empty!(
1030                            fidl::encoding::EmptyPayload,
1031                            fidl::encoding::DefaultFuchsiaResourceDialect
1032                        );
1033                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1034                        let control_handle = OdpmDeviceControlHandle { inner: this.inner.clone() };
1035                        Ok(OdpmDeviceRequest::ResetPollingConfig {
1036                            responder: OdpmDeviceResetPollingConfigResponder {
1037                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1038                                tx_id: header.tx_id,
1039                            },
1040                        })
1041                    }
1042                    _ if header.tx_id == 0
1043                        && header
1044                            .dynamic_flags()
1045                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1046                    {
1047                        Ok(OdpmDeviceRequest::_UnknownMethod {
1048                            ordinal: header.ordinal,
1049                            control_handle: OdpmDeviceControlHandle { inner: this.inner.clone() },
1050                            method_type: fidl::MethodType::OneWay,
1051                        })
1052                    }
1053                    _ if header
1054                        .dynamic_flags()
1055                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1056                    {
1057                        this.inner.send_framework_err(
1058                            fidl::encoding::FrameworkErr::UnknownMethod,
1059                            header.tx_id,
1060                            header.ordinal,
1061                            header.dynamic_flags(),
1062                            (bytes, handles),
1063                        )?;
1064                        Ok(OdpmDeviceRequest::_UnknownMethod {
1065                            ordinal: header.ordinal,
1066                            control_handle: OdpmDeviceControlHandle { inner: this.inner.clone() },
1067                            method_type: fidl::MethodType::TwoWay,
1068                        })
1069                    }
1070                    _ => Err(fidl::Error::UnknownOrdinal {
1071                        ordinal: header.ordinal,
1072                        protocol_name:
1073                            <OdpmDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1074                    }),
1075                }))
1076            },
1077        )
1078    }
1079}
1080
1081/// Provides power and power-related measurements for all actively-monitored rails,
1082/// dynamic rail multiplexing, and configuration for the ODPM driver's hardware polling loop.
1083#[derive(Debug)]
1084pub enum OdpmDeviceRequest {
1085    /// Returns metadata for all actively-monitored rails.
1086    GetRailMetadata { responder: OdpmDeviceGetRailMetadataResponder },
1087    /// Returns metadata for all available power rails supported by the hardware
1088    /// (both actively-monitored and unmonitored).
1089    ///
1090    /// * `measurement_start` is reported for rails that are actively monitored or
1091    ///   were previously monitored.
1092    /// * `measurement_stop` and `energy_uj` are reported only for rails that have
1093    ///   been swapped out, retaining only the most recent completed measurement
1094    ///   window (rather than an entry per session or an aggregate across sessions).
1095    ///   If a stopped rail is swapped back onto an active channel, its previous
1096    ///   stopped reading (`measurement_stop` and `energy_uj`) is cleared and a new
1097    ///   measurement window begins.
1098    ///
1099    /// Returns `ZX_ERR_INTERNAL` if internal rail state cannot be retrieved.
1100    GetAvailableRails { responder: OdpmDeviceGetAvailableRailsResponder },
1101    /// Reconfigures an internal telemetry channel (`channel_id`) to monitor `rail_name`
1102    /// (matched case-insensitively against `name`, `regulator_name`, or `schematic_name`).
1103    ///
1104    /// The new assignment is visible to all clients: readings for `channel_id` from
1105    /// `GetPowerWatts`, `GetCurrentAmperes`, and `GetEnergyJoules` then refer to `rail_name`
1106    /// and restart from a new measurement window. Clients that cache `GetRailMetadata` can
1107    /// detect the change by re-querying it and comparing `name` or `measurement_start`.
1108    ///
1109    /// Returns:
1110    /// * `ZX_OK` (as a no-op) if `channel_id` is already actively monitoring `rail_name`.
1111    /// * `ZX_ERR_NOT_FOUND` if `rail_name` does not match any available rail.
1112    /// * `ZX_ERR_INVALID_ARGS` if `channel_id` is invalid, is an external shunt channel,
1113    ///   or if the requested rail is an external shunt rail or belongs to a different PMIC
1114    ///   than `channel_id`.
1115    /// * `ZX_ERR_ALREADY_BOUND` if the requested rail is already monitored on a different
1116    ///   active channel.
1117    /// * `ZX_ERR_UNAVAILABLE` if the hardware operation fails.
1118    /// * `ZX_ERR_INTERNAL` if an internal driver error occurs.
1119    SetChannelRail {
1120        channel_id: u32,
1121        rail_name: String,
1122        responder: OdpmDeviceSetChannelRailResponder,
1123    },
1124    /// Returns the power consumption for all actively-monitored rails.
1125    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
1126    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
1127    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
1128    GetPowerWatts { payload: Options, responder: OdpmDeviceGetPowerWattsResponder },
1129    /// Returns the current for all actively-monitored rails.
1130    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
1131    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
1132    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
1133    GetCurrentAmperes { payload: Options, responder: OdpmDeviceGetCurrentAmperesResponder },
1134    /// Returns the energy consumption for all actively-monitored rails.
1135    /// Returns `ZX_ERR_NOT_SUPPORTED` if the requested measurement type is not supported.
1136    /// Returns `ZX_ERR_UNAVAILABLE` if the hardware read fails.
1137    /// Returns `ZX_ERR_INTERNAL` if internal rail state is inconsistent.
1138    GetEnergyJoules { payload: Options, responder: OdpmDeviceGetEnergyJoulesResponder },
1139    /// Overrides polling configuration parameters. Any omitted fields in `PollingConfig`
1140    /// remain unchanged.
1141    /// Returns `ZX_ERR_INVALID_ARGS` if `poll_interval` is less than `MIN_POLL_INTERVAL` or
1142    /// `polls_per_series_entry` == 0.
1143    SetPollingConfig { payload: PollingConfig, responder: OdpmDeviceSetPollingConfigResponder },
1144    /// Retrieves the current polling configuration parameters.
1145    GetPollingConfig { responder: OdpmDeviceGetPollingConfigResponder },
1146    /// Resets polling configuration parameters to the driver's default values.
1147    ResetPollingConfig { responder: OdpmDeviceResetPollingConfigResponder },
1148    /// An interaction was received which does not match any known method.
1149    #[non_exhaustive]
1150    _UnknownMethod {
1151        /// Ordinal of the method that was called.
1152        ordinal: u64,
1153        control_handle: OdpmDeviceControlHandle,
1154        method_type: fidl::MethodType,
1155    },
1156}
1157
1158impl OdpmDeviceRequest {
1159    #[allow(irrefutable_let_patterns)]
1160    pub fn into_get_rail_metadata(self) -> Option<(OdpmDeviceGetRailMetadataResponder)> {
1161        if let OdpmDeviceRequest::GetRailMetadata { responder } = self {
1162            Some((responder))
1163        } else {
1164            None
1165        }
1166    }
1167
1168    #[allow(irrefutable_let_patterns)]
1169    pub fn into_get_available_rails(self) -> Option<(OdpmDeviceGetAvailableRailsResponder)> {
1170        if let OdpmDeviceRequest::GetAvailableRails { responder } = self {
1171            Some((responder))
1172        } else {
1173            None
1174        }
1175    }
1176
1177    #[allow(irrefutable_let_patterns)]
1178    pub fn into_set_channel_rail(self) -> Option<(u32, String, OdpmDeviceSetChannelRailResponder)> {
1179        if let OdpmDeviceRequest::SetChannelRail { channel_id, rail_name, responder } = self {
1180            Some((channel_id, rail_name, responder))
1181        } else {
1182            None
1183        }
1184    }
1185
1186    #[allow(irrefutable_let_patterns)]
1187    pub fn into_get_power_watts(self) -> Option<(Options, OdpmDeviceGetPowerWattsResponder)> {
1188        if let OdpmDeviceRequest::GetPowerWatts { payload, responder } = self {
1189            Some((payload, responder))
1190        } else {
1191            None
1192        }
1193    }
1194
1195    #[allow(irrefutable_let_patterns)]
1196    pub fn into_get_current_amperes(
1197        self,
1198    ) -> Option<(Options, OdpmDeviceGetCurrentAmperesResponder)> {
1199        if let OdpmDeviceRequest::GetCurrentAmperes { payload, responder } = self {
1200            Some((payload, responder))
1201        } else {
1202            None
1203        }
1204    }
1205
1206    #[allow(irrefutable_let_patterns)]
1207    pub fn into_get_energy_joules(self) -> Option<(Options, OdpmDeviceGetEnergyJoulesResponder)> {
1208        if let OdpmDeviceRequest::GetEnergyJoules { payload, responder } = self {
1209            Some((payload, responder))
1210        } else {
1211            None
1212        }
1213    }
1214
1215    #[allow(irrefutable_let_patterns)]
1216    pub fn into_set_polling_config(
1217        self,
1218    ) -> Option<(PollingConfig, OdpmDeviceSetPollingConfigResponder)> {
1219        if let OdpmDeviceRequest::SetPollingConfig { payload, responder } = self {
1220            Some((payload, responder))
1221        } else {
1222            None
1223        }
1224    }
1225
1226    #[allow(irrefutable_let_patterns)]
1227    pub fn into_get_polling_config(self) -> Option<(OdpmDeviceGetPollingConfigResponder)> {
1228        if let OdpmDeviceRequest::GetPollingConfig { responder } = self {
1229            Some((responder))
1230        } else {
1231            None
1232        }
1233    }
1234
1235    #[allow(irrefutable_let_patterns)]
1236    pub fn into_reset_polling_config(self) -> Option<(OdpmDeviceResetPollingConfigResponder)> {
1237        if let OdpmDeviceRequest::ResetPollingConfig { responder } = self {
1238            Some((responder))
1239        } else {
1240            None
1241        }
1242    }
1243
1244    /// Name of the method defined in FIDL
1245    pub fn method_name(&self) -> &'static str {
1246        match *self {
1247            OdpmDeviceRequest::GetRailMetadata { .. } => "get_rail_metadata",
1248            OdpmDeviceRequest::GetAvailableRails { .. } => "get_available_rails",
1249            OdpmDeviceRequest::SetChannelRail { .. } => "set_channel_rail",
1250            OdpmDeviceRequest::GetPowerWatts { .. } => "get_power_watts",
1251            OdpmDeviceRequest::GetCurrentAmperes { .. } => "get_current_amperes",
1252            OdpmDeviceRequest::GetEnergyJoules { .. } => "get_energy_joules",
1253            OdpmDeviceRequest::SetPollingConfig { .. } => "set_polling_config",
1254            OdpmDeviceRequest::GetPollingConfig { .. } => "get_polling_config",
1255            OdpmDeviceRequest::ResetPollingConfig { .. } => "reset_polling_config",
1256            OdpmDeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1257                "unknown one-way method"
1258            }
1259            OdpmDeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1260                "unknown two-way method"
1261            }
1262        }
1263    }
1264}
1265
1266#[derive(Debug, Clone)]
1267pub struct OdpmDeviceControlHandle {
1268    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1269}
1270
1271impl OdpmDeviceControlHandle {
1272    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1273        self.inner.shutdown_with_epitaph(status.into())
1274    }
1275}
1276
1277impl fidl::endpoints::ControlHandle for OdpmDeviceControlHandle {
1278    fn shutdown(&self) {
1279        self.inner.shutdown()
1280    }
1281
1282    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1283        self.inner.shutdown_with_epitaph(status)
1284    }
1285
1286    fn is_closed(&self) -> bool {
1287        self.inner.channel().is_closed()
1288    }
1289    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1290        self.inner.channel().on_closed()
1291    }
1292
1293    #[cfg(target_os = "fuchsia")]
1294    fn signal_peer(
1295        &self,
1296        clear_mask: zx::Signals,
1297        set_mask: zx::Signals,
1298    ) -> Result<(), zx_status::Status> {
1299        use fidl::Peered;
1300        self.inner.channel().signal_peer(clear_mask, set_mask)
1301    }
1302}
1303
1304impl OdpmDeviceControlHandle {}
1305
1306#[must_use = "FIDL methods require a response to be sent"]
1307#[derive(Debug)]
1308pub struct OdpmDeviceGetRailMetadataResponder {
1309    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1310    tx_id: u32,
1311}
1312
1313/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1314/// if the responder is dropped without sending a response, so that the client
1315/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1316impl std::ops::Drop for OdpmDeviceGetRailMetadataResponder {
1317    fn drop(&mut self) {
1318        self.control_handle.shutdown();
1319        // Safety: drops once, never accessed again
1320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1321    }
1322}
1323
1324impl fidl::endpoints::Responder for OdpmDeviceGetRailMetadataResponder {
1325    type ControlHandle = OdpmDeviceControlHandle;
1326
1327    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1328        &self.control_handle
1329    }
1330
1331    fn drop_without_shutdown(mut self) {
1332        // Safety: drops once, never accessed again due to mem::forget
1333        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1334        // Prevent Drop from running (which would shut down the channel)
1335        std::mem::forget(self);
1336    }
1337}
1338
1339impl OdpmDeviceGetRailMetadataResponder {
1340    /// Sends a response to the FIDL transaction.
1341    ///
1342    /// Sets the channel to shutdown if an error occurs.
1343    pub fn send(self, mut result: Result<&[RailMetadata], i32>) -> Result<(), fidl::Error> {
1344        let _result = self.send_raw(result);
1345        if _result.is_err() {
1346            self.control_handle.shutdown();
1347        }
1348        self.drop_without_shutdown();
1349        _result
1350    }
1351
1352    /// Similar to "send" but does not shutdown the channel if an error occurs.
1353    pub fn send_no_shutdown_on_err(
1354        self,
1355        mut result: Result<&[RailMetadata], i32>,
1356    ) -> Result<(), fidl::Error> {
1357        let _result = self.send_raw(result);
1358        self.drop_without_shutdown();
1359        _result
1360    }
1361
1362    fn send_raw(&self, mut result: Result<&[RailMetadata], i32>) -> Result<(), fidl::Error> {
1363        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1364            OdpmDeviceGetRailMetadataResponse,
1365            i32,
1366        >>(
1367            fidl::encoding::FlexibleResult::new(result.map(|rails| (rails,))),
1368            self.tx_id,
1369            0x1370e2e1a26954e7,
1370            fidl::encoding::DynamicFlags::FLEXIBLE,
1371        )
1372    }
1373}
1374
1375#[must_use = "FIDL methods require a response to be sent"]
1376#[derive(Debug)]
1377pub struct OdpmDeviceGetAvailableRailsResponder {
1378    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1379    tx_id: u32,
1380}
1381
1382/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1383/// if the responder is dropped without sending a response, so that the client
1384/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1385impl std::ops::Drop for OdpmDeviceGetAvailableRailsResponder {
1386    fn drop(&mut self) {
1387        self.control_handle.shutdown();
1388        // Safety: drops once, never accessed again
1389        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1390    }
1391}
1392
1393impl fidl::endpoints::Responder for OdpmDeviceGetAvailableRailsResponder {
1394    type ControlHandle = OdpmDeviceControlHandle;
1395
1396    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1397        &self.control_handle
1398    }
1399
1400    fn drop_without_shutdown(mut self) {
1401        // Safety: drops once, never accessed again due to mem::forget
1402        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1403        // Prevent Drop from running (which would shut down the channel)
1404        std::mem::forget(self);
1405    }
1406}
1407
1408impl OdpmDeviceGetAvailableRailsResponder {
1409    /// Sends a response to the FIDL transaction.
1410    ///
1411    /// Sets the channel to shutdown if an error occurs.
1412    pub fn send(self, mut result: Result<&[RailMetadata], i32>) -> Result<(), fidl::Error> {
1413        let _result = self.send_raw(result);
1414        if _result.is_err() {
1415            self.control_handle.shutdown();
1416        }
1417        self.drop_without_shutdown();
1418        _result
1419    }
1420
1421    /// Similar to "send" but does not shutdown the channel if an error occurs.
1422    pub fn send_no_shutdown_on_err(
1423        self,
1424        mut result: Result<&[RailMetadata], i32>,
1425    ) -> Result<(), fidl::Error> {
1426        let _result = self.send_raw(result);
1427        self.drop_without_shutdown();
1428        _result
1429    }
1430
1431    fn send_raw(&self, mut result: Result<&[RailMetadata], i32>) -> Result<(), fidl::Error> {
1432        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1433            OdpmDeviceGetAvailableRailsResponse,
1434            i32,
1435        >>(
1436            fidl::encoding::FlexibleResult::new(result.map(|rails| (rails,))),
1437            self.tx_id,
1438            0x5d2f432497df351a,
1439            fidl::encoding::DynamicFlags::FLEXIBLE,
1440        )
1441    }
1442}
1443
1444#[must_use = "FIDL methods require a response to be sent"]
1445#[derive(Debug)]
1446pub struct OdpmDeviceSetChannelRailResponder {
1447    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1448    tx_id: u32,
1449}
1450
1451/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1452/// if the responder is dropped without sending a response, so that the client
1453/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1454impl std::ops::Drop for OdpmDeviceSetChannelRailResponder {
1455    fn drop(&mut self) {
1456        self.control_handle.shutdown();
1457        // Safety: drops once, never accessed again
1458        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1459    }
1460}
1461
1462impl fidl::endpoints::Responder for OdpmDeviceSetChannelRailResponder {
1463    type ControlHandle = OdpmDeviceControlHandle;
1464
1465    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1466        &self.control_handle
1467    }
1468
1469    fn drop_without_shutdown(mut self) {
1470        // Safety: drops once, never accessed again due to mem::forget
1471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1472        // Prevent Drop from running (which would shut down the channel)
1473        std::mem::forget(self);
1474    }
1475}
1476
1477impl OdpmDeviceSetChannelRailResponder {
1478    /// Sends a response to the FIDL transaction.
1479    ///
1480    /// Sets the channel to shutdown if an error occurs.
1481    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1482        let _result = self.send_raw(result);
1483        if _result.is_err() {
1484            self.control_handle.shutdown();
1485        }
1486        self.drop_without_shutdown();
1487        _result
1488    }
1489
1490    /// Similar to "send" but does not shutdown the channel if an error occurs.
1491    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1492        let _result = self.send_raw(result);
1493        self.drop_without_shutdown();
1494        _result
1495    }
1496
1497    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1498        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1499            fidl::encoding::EmptyStruct,
1500            i32,
1501        >>(
1502            fidl::encoding::FlexibleResult::new(result),
1503            self.tx_id,
1504            0x59748499a188a657,
1505            fidl::encoding::DynamicFlags::FLEXIBLE,
1506        )
1507    }
1508}
1509
1510#[must_use = "FIDL methods require a response to be sent"]
1511#[derive(Debug)]
1512pub struct OdpmDeviceGetPowerWattsResponder {
1513    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1514    tx_id: u32,
1515}
1516
1517/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1518/// if the responder is dropped without sending a response, so that the client
1519/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1520impl std::ops::Drop for OdpmDeviceGetPowerWattsResponder {
1521    fn drop(&mut self) {
1522        self.control_handle.shutdown();
1523        // Safety: drops once, never accessed again
1524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1525    }
1526}
1527
1528impl fidl::endpoints::Responder for OdpmDeviceGetPowerWattsResponder {
1529    type ControlHandle = OdpmDeviceControlHandle;
1530
1531    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1532        &self.control_handle
1533    }
1534
1535    fn drop_without_shutdown(mut self) {
1536        // Safety: drops once, never accessed again due to mem::forget
1537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1538        // Prevent Drop from running (which would shut down the channel)
1539        std::mem::forget(self);
1540    }
1541}
1542
1543impl OdpmDeviceGetPowerWattsResponder {
1544    /// Sends a response to the FIDL transaction.
1545    ///
1546    /// Sets the channel to shutdown if an error occurs.
1547    pub fn send(self, mut result: Result<&[PowerReading], i32>) -> Result<(), fidl::Error> {
1548        let _result = self.send_raw(result);
1549        if _result.is_err() {
1550            self.control_handle.shutdown();
1551        }
1552        self.drop_without_shutdown();
1553        _result
1554    }
1555
1556    /// Similar to "send" but does not shutdown the channel if an error occurs.
1557    pub fn send_no_shutdown_on_err(
1558        self,
1559        mut result: Result<&[PowerReading], i32>,
1560    ) -> Result<(), fidl::Error> {
1561        let _result = self.send_raw(result);
1562        self.drop_without_shutdown();
1563        _result
1564    }
1565
1566    fn send_raw(&self, mut result: Result<&[PowerReading], i32>) -> Result<(), fidl::Error> {
1567        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1568            OdpmDeviceGetPowerWattsResponse,
1569            i32,
1570        >>(
1571            fidl::encoding::FlexibleResult::new(result.map(|readings| (readings,))),
1572            self.tx_id,
1573            0x2e26ec237d170791,
1574            fidl::encoding::DynamicFlags::FLEXIBLE,
1575        )
1576    }
1577}
1578
1579#[must_use = "FIDL methods require a response to be sent"]
1580#[derive(Debug)]
1581pub struct OdpmDeviceGetCurrentAmperesResponder {
1582    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1583    tx_id: u32,
1584}
1585
1586/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1587/// if the responder is dropped without sending a response, so that the client
1588/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1589impl std::ops::Drop for OdpmDeviceGetCurrentAmperesResponder {
1590    fn drop(&mut self) {
1591        self.control_handle.shutdown();
1592        // Safety: drops once, never accessed again
1593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1594    }
1595}
1596
1597impl fidl::endpoints::Responder for OdpmDeviceGetCurrentAmperesResponder {
1598    type ControlHandle = OdpmDeviceControlHandle;
1599
1600    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1601        &self.control_handle
1602    }
1603
1604    fn drop_without_shutdown(mut self) {
1605        // Safety: drops once, never accessed again due to mem::forget
1606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1607        // Prevent Drop from running (which would shut down the channel)
1608        std::mem::forget(self);
1609    }
1610}
1611
1612impl OdpmDeviceGetCurrentAmperesResponder {
1613    /// Sends a response to the FIDL transaction.
1614    ///
1615    /// Sets the channel to shutdown if an error occurs.
1616    pub fn send(self, mut result: Result<&[CurrentReading], i32>) -> Result<(), fidl::Error> {
1617        let _result = self.send_raw(result);
1618        if _result.is_err() {
1619            self.control_handle.shutdown();
1620        }
1621        self.drop_without_shutdown();
1622        _result
1623    }
1624
1625    /// Similar to "send" but does not shutdown the channel if an error occurs.
1626    pub fn send_no_shutdown_on_err(
1627        self,
1628        mut result: Result<&[CurrentReading], i32>,
1629    ) -> Result<(), fidl::Error> {
1630        let _result = self.send_raw(result);
1631        self.drop_without_shutdown();
1632        _result
1633    }
1634
1635    fn send_raw(&self, mut result: Result<&[CurrentReading], i32>) -> Result<(), fidl::Error> {
1636        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1637            OdpmDeviceGetCurrentAmperesResponse,
1638            i32,
1639        >>(
1640            fidl::encoding::FlexibleResult::new(result.map(|readings| (readings,))),
1641            self.tx_id,
1642            0x2efa123da8afbcec,
1643            fidl::encoding::DynamicFlags::FLEXIBLE,
1644        )
1645    }
1646}
1647
1648#[must_use = "FIDL methods require a response to be sent"]
1649#[derive(Debug)]
1650pub struct OdpmDeviceGetEnergyJoulesResponder {
1651    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1652    tx_id: u32,
1653}
1654
1655/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1656/// if the responder is dropped without sending a response, so that the client
1657/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1658impl std::ops::Drop for OdpmDeviceGetEnergyJoulesResponder {
1659    fn drop(&mut self) {
1660        self.control_handle.shutdown();
1661        // Safety: drops once, never accessed again
1662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1663    }
1664}
1665
1666impl fidl::endpoints::Responder for OdpmDeviceGetEnergyJoulesResponder {
1667    type ControlHandle = OdpmDeviceControlHandle;
1668
1669    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1670        &self.control_handle
1671    }
1672
1673    fn drop_without_shutdown(mut self) {
1674        // Safety: drops once, never accessed again due to mem::forget
1675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1676        // Prevent Drop from running (which would shut down the channel)
1677        std::mem::forget(self);
1678    }
1679}
1680
1681impl OdpmDeviceGetEnergyJoulesResponder {
1682    /// Sends a response to the FIDL transaction.
1683    ///
1684    /// Sets the channel to shutdown if an error occurs.
1685    pub fn send(self, mut result: Result<&[EnergyReading], i32>) -> Result<(), fidl::Error> {
1686        let _result = self.send_raw(result);
1687        if _result.is_err() {
1688            self.control_handle.shutdown();
1689        }
1690        self.drop_without_shutdown();
1691        _result
1692    }
1693
1694    /// Similar to "send" but does not shutdown the channel if an error occurs.
1695    pub fn send_no_shutdown_on_err(
1696        self,
1697        mut result: Result<&[EnergyReading], i32>,
1698    ) -> Result<(), fidl::Error> {
1699        let _result = self.send_raw(result);
1700        self.drop_without_shutdown();
1701        _result
1702    }
1703
1704    fn send_raw(&self, mut result: Result<&[EnergyReading], i32>) -> Result<(), fidl::Error> {
1705        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1706            OdpmDeviceGetEnergyJoulesResponse,
1707            i32,
1708        >>(
1709            fidl::encoding::FlexibleResult::new(result.map(|readings| (readings,))),
1710            self.tx_id,
1711            0x25bf6e4b27991b1c,
1712            fidl::encoding::DynamicFlags::FLEXIBLE,
1713        )
1714    }
1715}
1716
1717#[must_use = "FIDL methods require a response to be sent"]
1718#[derive(Debug)]
1719pub struct OdpmDeviceSetPollingConfigResponder {
1720    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1721    tx_id: u32,
1722}
1723
1724/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1725/// if the responder is dropped without sending a response, so that the client
1726/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1727impl std::ops::Drop for OdpmDeviceSetPollingConfigResponder {
1728    fn drop(&mut self) {
1729        self.control_handle.shutdown();
1730        // Safety: drops once, never accessed again
1731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1732    }
1733}
1734
1735impl fidl::endpoints::Responder for OdpmDeviceSetPollingConfigResponder {
1736    type ControlHandle = OdpmDeviceControlHandle;
1737
1738    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1739        &self.control_handle
1740    }
1741
1742    fn drop_without_shutdown(mut self) {
1743        // Safety: drops once, never accessed again due to mem::forget
1744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1745        // Prevent Drop from running (which would shut down the channel)
1746        std::mem::forget(self);
1747    }
1748}
1749
1750impl OdpmDeviceSetPollingConfigResponder {
1751    /// Sends a response to the FIDL transaction.
1752    ///
1753    /// Sets the channel to shutdown if an error occurs.
1754    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1755        let _result = self.send_raw(result);
1756        if _result.is_err() {
1757            self.control_handle.shutdown();
1758        }
1759        self.drop_without_shutdown();
1760        _result
1761    }
1762
1763    /// Similar to "send" but does not shutdown the channel if an error occurs.
1764    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1765        let _result = self.send_raw(result);
1766        self.drop_without_shutdown();
1767        _result
1768    }
1769
1770    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1771        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1772            fidl::encoding::EmptyStruct,
1773            i32,
1774        >>(
1775            fidl::encoding::FlexibleResult::new(result),
1776            self.tx_id,
1777            0x23821a66e6c6647d,
1778            fidl::encoding::DynamicFlags::FLEXIBLE,
1779        )
1780    }
1781}
1782
1783#[must_use = "FIDL methods require a response to be sent"]
1784#[derive(Debug)]
1785pub struct OdpmDeviceGetPollingConfigResponder {
1786    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1787    tx_id: u32,
1788}
1789
1790/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1791/// if the responder is dropped without sending a response, so that the client
1792/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1793impl std::ops::Drop for OdpmDeviceGetPollingConfigResponder {
1794    fn drop(&mut self) {
1795        self.control_handle.shutdown();
1796        // Safety: drops once, never accessed again
1797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1798    }
1799}
1800
1801impl fidl::endpoints::Responder for OdpmDeviceGetPollingConfigResponder {
1802    type ControlHandle = OdpmDeviceControlHandle;
1803
1804    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1805        &self.control_handle
1806    }
1807
1808    fn drop_without_shutdown(mut self) {
1809        // Safety: drops once, never accessed again due to mem::forget
1810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1811        // Prevent Drop from running (which would shut down the channel)
1812        std::mem::forget(self);
1813    }
1814}
1815
1816impl OdpmDeviceGetPollingConfigResponder {
1817    /// Sends a response to the FIDL transaction.
1818    ///
1819    /// Sets the channel to shutdown if an error occurs.
1820    pub fn send(self, mut result: Result<&PollingConfig, i32>) -> Result<(), fidl::Error> {
1821        let _result = self.send_raw(result);
1822        if _result.is_err() {
1823            self.control_handle.shutdown();
1824        }
1825        self.drop_without_shutdown();
1826        _result
1827    }
1828
1829    /// Similar to "send" but does not shutdown the channel if an error occurs.
1830    pub fn send_no_shutdown_on_err(
1831        self,
1832        mut result: Result<&PollingConfig, i32>,
1833    ) -> Result<(), fidl::Error> {
1834        let _result = self.send_raw(result);
1835        self.drop_without_shutdown();
1836        _result
1837    }
1838
1839    fn send_raw(&self, mut result: Result<&PollingConfig, i32>) -> Result<(), fidl::Error> {
1840        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<PollingConfig, i32>>(
1841            fidl::encoding::FlexibleResult::new(result),
1842            self.tx_id,
1843            0x476f23167a254bd3,
1844            fidl::encoding::DynamicFlags::FLEXIBLE,
1845        )
1846    }
1847}
1848
1849#[must_use = "FIDL methods require a response to be sent"]
1850#[derive(Debug)]
1851pub struct OdpmDeviceResetPollingConfigResponder {
1852    control_handle: std::mem::ManuallyDrop<OdpmDeviceControlHandle>,
1853    tx_id: u32,
1854}
1855
1856/// Set the the channel to be shutdown (see [`OdpmDeviceControlHandle::shutdown`])
1857/// if the responder is dropped without sending a response, so that the client
1858/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1859impl std::ops::Drop for OdpmDeviceResetPollingConfigResponder {
1860    fn drop(&mut self) {
1861        self.control_handle.shutdown();
1862        // Safety: drops once, never accessed again
1863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1864    }
1865}
1866
1867impl fidl::endpoints::Responder for OdpmDeviceResetPollingConfigResponder {
1868    type ControlHandle = OdpmDeviceControlHandle;
1869
1870    fn control_handle(&self) -> &OdpmDeviceControlHandle {
1871        &self.control_handle
1872    }
1873
1874    fn drop_without_shutdown(mut self) {
1875        // Safety: drops once, never accessed again due to mem::forget
1876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1877        // Prevent Drop from running (which would shut down the channel)
1878        std::mem::forget(self);
1879    }
1880}
1881
1882impl OdpmDeviceResetPollingConfigResponder {
1883    /// Sends a response to the FIDL transaction.
1884    ///
1885    /// Sets the channel to shutdown if an error occurs.
1886    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1887        let _result = self.send_raw(result);
1888        if _result.is_err() {
1889            self.control_handle.shutdown();
1890        }
1891        self.drop_without_shutdown();
1892        _result
1893    }
1894
1895    /// Similar to "send" but does not shutdown the channel if an error occurs.
1896    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1897        let _result = self.send_raw(result);
1898        self.drop_without_shutdown();
1899        _result
1900    }
1901
1902    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1903        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1904            fidl::encoding::EmptyStruct,
1905            i32,
1906        >>(
1907            fidl::encoding::FlexibleResult::new(result),
1908            self.tx_id,
1909            0x182591ccbe96a9d,
1910            fidl::encoding::DynamicFlags::FLEXIBLE,
1911        )
1912    }
1913}
1914
1915#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1916pub struct ServiceMarker;
1917
1918#[cfg(target_os = "fuchsia")]
1919impl fidl::endpoints::ServiceMarker for ServiceMarker {
1920    type Proxy = ServiceProxy;
1921    type Request = ServiceRequest;
1922    const SERVICE_NAME: &'static str = "fuchsia.hardware.google.odpm.Service";
1923}
1924
1925/// A request for one of the member protocols of Service.
1926///
1927#[cfg(target_os = "fuchsia")]
1928pub enum ServiceRequest {
1929    Device(OdpmDeviceRequestStream),
1930}
1931
1932#[cfg(target_os = "fuchsia")]
1933impl fidl::endpoints::ServiceRequest for ServiceRequest {
1934    type Service = ServiceMarker;
1935
1936    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1937        match name {
1938            "device" => Self::Device(
1939                <OdpmDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1940            ),
1941            _ => panic!("no such member protocol name for service Service"),
1942        }
1943    }
1944
1945    fn member_names() -> &'static [&'static str] {
1946        &["device"]
1947    }
1948}
1949#[cfg(target_os = "fuchsia")]
1950pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1951
1952#[cfg(target_os = "fuchsia")]
1953impl fidl::endpoints::ServiceProxy for ServiceProxy {
1954    type Service = ServiceMarker;
1955
1956    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1957        Self(opener)
1958    }
1959}
1960
1961#[cfg(target_os = "fuchsia")]
1962impl ServiceProxy {
1963    pub fn connect_to_device(&self) -> Result<OdpmDeviceProxy, fidl::Error> {
1964        let (proxy, server_end) = fidl::endpoints::create_proxy::<OdpmDeviceMarker>();
1965        self.connect_channel_to_device(server_end)?;
1966        Ok(proxy)
1967    }
1968
1969    /// Like `connect_to_device`, but returns a sync proxy.
1970    /// See [`Self::connect_to_device`] for more details.
1971    pub fn connect_to_device_sync(&self) -> Result<OdpmDeviceSynchronousProxy, fidl::Error> {
1972        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<OdpmDeviceMarker>();
1973        self.connect_channel_to_device(server_end)?;
1974        Ok(proxy)
1975    }
1976
1977    /// Like `connect_to_device`, but accepts a server end.
1978    /// See [`Self::connect_to_device`] for more details.
1979    pub fn connect_channel_to_device(
1980        &self,
1981        server_end: fidl::endpoints::ServerEnd<OdpmDeviceMarker>,
1982    ) -> Result<(), fidl::Error> {
1983        self.0.open_member("device", server_end.into_channel())
1984    }
1985
1986    pub fn instance_name(&self) -> &str {
1987        self.0.instance_name()
1988    }
1989}
1990
1991mod internal {
1992    use super::*;
1993}