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