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#[cfg(target_os = "fuchsia")]
147impl fidl::endpoints::FromClient for BatteryInfoProviderSynchronousProxy {
148    type Protocol = BatteryInfoProviderMarker;
149
150    fn from_client(value: fidl::endpoints::ClientEnd<BatteryInfoProviderMarker>) -> Self {
151        Self::new(value.into_channel())
152    }
153}
154
155#[derive(Debug, Clone)]
156pub struct BatteryInfoProviderProxy {
157    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
158}
159
160impl fidl::endpoints::Proxy for BatteryInfoProviderProxy {
161    type Protocol = BatteryInfoProviderMarker;
162
163    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
164        Self::new(inner)
165    }
166
167    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
168        self.client.into_channel().map_err(|client| Self { client })
169    }
170
171    fn as_channel(&self) -> &::fidl::AsyncChannel {
172        self.client.as_channel()
173    }
174}
175
176impl BatteryInfoProviderProxy {
177    /// Create a new Proxy for fuchsia.power.battery/BatteryInfoProvider.
178    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
179        let protocol_name =
180            <BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
181        Self { client: fidl::client::Client::new(channel, protocol_name) }
182    }
183
184    /// Get a Stream of events from the remote end of the protocol.
185    ///
186    /// # Panics
187    ///
188    /// Panics if the event stream was already taken.
189    pub fn take_event_stream(&self) -> BatteryInfoProviderEventStream {
190        BatteryInfoProviderEventStream { event_receiver: self.client.take_event_receiver() }
191    }
192
193    /// Gets battery info.
194    pub fn r#get_battery_info(
195        &self,
196    ) -> fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
197    {
198        BatteryInfoProviderProxyInterface::r#get_battery_info(self)
199    }
200
201    /// Registers a watcher for battery info changes.
202    pub fn r#watch(
203        &self,
204        mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
205    ) -> Result<(), fidl::Error> {
206        BatteryInfoProviderProxyInterface::r#watch(self, watcher)
207    }
208}
209
210impl BatteryInfoProviderProxyInterface for BatteryInfoProviderProxy {
211    type GetBatteryInfoResponseFut =
212        fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
213    fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
214        fn _decode(
215            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
216        ) -> Result<BatteryInfo, fidl::Error> {
217            let _response = fidl::client::decode_transaction_body::<
218                BatteryInfoProviderGetBatteryInfoResponse,
219                fidl::encoding::DefaultFuchsiaResourceDialect,
220                0x51ea101e4fe7a192,
221            >(_buf?)?;
222            Ok(_response.info)
223        }
224        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BatteryInfo>(
225            (),
226            0x51ea101e4fe7a192,
227            fidl::encoding::DynamicFlags::empty(),
228            _decode,
229        )
230    }
231
232    fn r#watch(
233        &self,
234        mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
235    ) -> Result<(), fidl::Error> {
236        self.client.send::<BatteryInfoProviderWatchRequest>(
237            (watcher,),
238            0x4d44a314cd3f5191,
239            fidl::encoding::DynamicFlags::empty(),
240        )
241    }
242}
243
244pub struct BatteryInfoProviderEventStream {
245    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
246}
247
248impl std::marker::Unpin for BatteryInfoProviderEventStream {}
249
250impl futures::stream::FusedStream for BatteryInfoProviderEventStream {
251    fn is_terminated(&self) -> bool {
252        self.event_receiver.is_terminated()
253    }
254}
255
256impl futures::Stream for BatteryInfoProviderEventStream {
257    type Item = Result<BatteryInfoProviderEvent, fidl::Error>;
258
259    fn poll_next(
260        mut self: std::pin::Pin<&mut Self>,
261        cx: &mut std::task::Context<'_>,
262    ) -> std::task::Poll<Option<Self::Item>> {
263        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
264            &mut self.event_receiver,
265            cx
266        )?) {
267            Some(buf) => std::task::Poll::Ready(Some(BatteryInfoProviderEvent::decode(buf))),
268            None => std::task::Poll::Ready(None),
269        }
270    }
271}
272
273#[derive(Debug)]
274pub enum BatteryInfoProviderEvent {}
275
276impl BatteryInfoProviderEvent {
277    /// Decodes a message buffer as a [`BatteryInfoProviderEvent`].
278    fn decode(
279        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
280    ) -> Result<BatteryInfoProviderEvent, fidl::Error> {
281        let (bytes, _handles) = buf.split_mut();
282        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
283        debug_assert_eq!(tx_header.tx_id, 0);
284        match tx_header.ordinal {
285            _ => Err(fidl::Error::UnknownOrdinal {
286                ordinal: tx_header.ordinal,
287                protocol_name:
288                    <BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
289            }),
290        }
291    }
292}
293
294/// A Stream of incoming requests for fuchsia.power.battery/BatteryInfoProvider.
295pub struct BatteryInfoProviderRequestStream {
296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297    is_terminated: bool,
298}
299
300impl std::marker::Unpin for BatteryInfoProviderRequestStream {}
301
302impl futures::stream::FusedStream for BatteryInfoProviderRequestStream {
303    fn is_terminated(&self) -> bool {
304        self.is_terminated
305    }
306}
307
308impl fidl::endpoints::RequestStream for BatteryInfoProviderRequestStream {
309    type Protocol = BatteryInfoProviderMarker;
310    type ControlHandle = BatteryInfoProviderControlHandle;
311
312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
314    }
315
316    fn control_handle(&self) -> Self::ControlHandle {
317        BatteryInfoProviderControlHandle { inner: self.inner.clone() }
318    }
319
320    fn into_inner(
321        self,
322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
323    {
324        (self.inner, self.is_terminated)
325    }
326
327    fn from_inner(
328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
329        is_terminated: bool,
330    ) -> Self {
331        Self { inner, is_terminated }
332    }
333}
334
335impl futures::Stream for BatteryInfoProviderRequestStream {
336    type Item = Result<BatteryInfoProviderRequest, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        let this = &mut *self;
343        if this.inner.check_shutdown(cx) {
344            this.is_terminated = true;
345            return std::task::Poll::Ready(None);
346        }
347        if this.is_terminated {
348            panic!("polled BatteryInfoProviderRequestStream after completion");
349        }
350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
351            |bytes, handles| {
352                match this.inner.channel().read_etc(cx, bytes, handles) {
353                    std::task::Poll::Ready(Ok(())) => {}
354                    std::task::Poll::Pending => return std::task::Poll::Pending,
355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
356                        this.is_terminated = true;
357                        return std::task::Poll::Ready(None);
358                    }
359                    std::task::Poll::Ready(Err(e)) => {
360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
361                            e.into(),
362                        ))));
363                    }
364                }
365
366                // A message has been received from the channel
367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
368
369                std::task::Poll::Ready(Some(match header.ordinal {
370                0x51ea101e4fe7a192 => {
371                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
373                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
374                    let control_handle = BatteryInfoProviderControlHandle {
375                        inner: this.inner.clone(),
376                    };
377                    Ok(BatteryInfoProviderRequest::GetBatteryInfo {
378                        responder: BatteryInfoProviderGetBatteryInfoResponder {
379                            control_handle: std::mem::ManuallyDrop::new(control_handle),
380                            tx_id: header.tx_id,
381                        },
382                    })
383                }
384                0x4d44a314cd3f5191 => {
385                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
386                    let mut req = fidl::new_empty!(BatteryInfoProviderWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
387                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoProviderWatchRequest>(&header, _body_bytes, handles, &mut req)?;
388                    let control_handle = BatteryInfoProviderControlHandle {
389                        inner: this.inner.clone(),
390                    };
391                    Ok(BatteryInfoProviderRequest::Watch {watcher: req.watcher,
392
393                        control_handle,
394                    })
395                }
396                _ => Err(fidl::Error::UnknownOrdinal {
397                    ordinal: header.ordinal,
398                    protocol_name: <BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
399                }),
400            }))
401            },
402        )
403    }
404}
405
406/// Provider interface used to obtain battery status details.
407#[derive(Debug)]
408pub enum BatteryInfoProviderRequest {
409    /// Gets battery info.
410    GetBatteryInfo { responder: BatteryInfoProviderGetBatteryInfoResponder },
411    /// Registers a watcher for battery info changes.
412    Watch {
413        watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
414        control_handle: BatteryInfoProviderControlHandle,
415    },
416}
417
418impl BatteryInfoProviderRequest {
419    #[allow(irrefutable_let_patterns)]
420    pub fn into_get_battery_info(self) -> Option<(BatteryInfoProviderGetBatteryInfoResponder)> {
421        if let BatteryInfoProviderRequest::GetBatteryInfo { responder } = self {
422            Some((responder))
423        } else {
424            None
425        }
426    }
427
428    #[allow(irrefutable_let_patterns)]
429    pub fn into_watch(
430        self,
431    ) -> Option<(
432        fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
433        BatteryInfoProviderControlHandle,
434    )> {
435        if let BatteryInfoProviderRequest::Watch { watcher, control_handle } = self {
436            Some((watcher, control_handle))
437        } else {
438            None
439        }
440    }
441
442    /// Name of the method defined in FIDL
443    pub fn method_name(&self) -> &'static str {
444        match *self {
445            BatteryInfoProviderRequest::GetBatteryInfo { .. } => "get_battery_info",
446            BatteryInfoProviderRequest::Watch { .. } => "watch",
447        }
448    }
449}
450
451#[derive(Debug, Clone)]
452pub struct BatteryInfoProviderControlHandle {
453    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
454}
455
456impl fidl::endpoints::ControlHandle for BatteryInfoProviderControlHandle {
457    fn shutdown(&self) {
458        self.inner.shutdown()
459    }
460    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
461        self.inner.shutdown_with_epitaph(status)
462    }
463
464    fn is_closed(&self) -> bool {
465        self.inner.channel().is_closed()
466    }
467    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
468        self.inner.channel().on_closed()
469    }
470
471    #[cfg(target_os = "fuchsia")]
472    fn signal_peer(
473        &self,
474        clear_mask: zx::Signals,
475        set_mask: zx::Signals,
476    ) -> Result<(), zx_status::Status> {
477        use fidl::Peered;
478        self.inner.channel().signal_peer(clear_mask, set_mask)
479    }
480}
481
482impl BatteryInfoProviderControlHandle {}
483
484#[must_use = "FIDL methods require a response to be sent"]
485#[derive(Debug)]
486pub struct BatteryInfoProviderGetBatteryInfoResponder {
487    control_handle: std::mem::ManuallyDrop<BatteryInfoProviderControlHandle>,
488    tx_id: u32,
489}
490
491/// Set the the channel to be shutdown (see [`BatteryInfoProviderControlHandle::shutdown`])
492/// if the responder is dropped without sending a response, so that the client
493/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
494impl std::ops::Drop for BatteryInfoProviderGetBatteryInfoResponder {
495    fn drop(&mut self) {
496        self.control_handle.shutdown();
497        // Safety: drops once, never accessed again
498        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
499    }
500}
501
502impl fidl::endpoints::Responder for BatteryInfoProviderGetBatteryInfoResponder {
503    type ControlHandle = BatteryInfoProviderControlHandle;
504
505    fn control_handle(&self) -> &BatteryInfoProviderControlHandle {
506        &self.control_handle
507    }
508
509    fn drop_without_shutdown(mut self) {
510        // Safety: drops once, never accessed again due to mem::forget
511        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
512        // Prevent Drop from running (which would shut down the channel)
513        std::mem::forget(self);
514    }
515}
516
517impl BatteryInfoProviderGetBatteryInfoResponder {
518    /// Sends a response to the FIDL transaction.
519    ///
520    /// Sets the channel to shutdown if an error occurs.
521    pub fn send(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
522        let _result = self.send_raw(info);
523        if _result.is_err() {
524            self.control_handle.shutdown();
525        }
526        self.drop_without_shutdown();
527        _result
528    }
529
530    /// Similar to "send" but does not shutdown the channel if an error occurs.
531    pub fn send_no_shutdown_on_err(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
532        let _result = self.send_raw(info);
533        self.drop_without_shutdown();
534        _result
535    }
536
537    fn send_raw(&self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
538        self.control_handle.inner.send::<BatteryInfoProviderGetBatteryInfoResponse>(
539            (info,),
540            self.tx_id,
541            0x51ea101e4fe7a192,
542            fidl::encoding::DynamicFlags::empty(),
543        )
544    }
545}
546
547#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
548pub struct BatteryInfoWatcherMarker;
549
550impl fidl::endpoints::ProtocolMarker for BatteryInfoWatcherMarker {
551    type Proxy = BatteryInfoWatcherProxy;
552    type RequestStream = BatteryInfoWatcherRequestStream;
553    #[cfg(target_os = "fuchsia")]
554    type SynchronousProxy = BatteryInfoWatcherSynchronousProxy;
555
556    const DEBUG_NAME: &'static str = "(anonymous) BatteryInfoWatcher";
557}
558
559pub trait BatteryInfoWatcherProxyInterface: Send + Sync {
560    type OnChangeBatteryInfoResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
561        + Send;
562    fn r#on_change_battery_info(
563        &self,
564        info: &BatteryInfo,
565        wake_lease: Option<fidl::EventPair>,
566    ) -> Self::OnChangeBatteryInfoResponseFut;
567}
568#[derive(Debug)]
569#[cfg(target_os = "fuchsia")]
570pub struct BatteryInfoWatcherSynchronousProxy {
571    client: fidl::client::sync::Client,
572}
573
574#[cfg(target_os = "fuchsia")]
575impl fidl::endpoints::SynchronousProxy for BatteryInfoWatcherSynchronousProxy {
576    type Proxy = BatteryInfoWatcherProxy;
577    type Protocol = BatteryInfoWatcherMarker;
578
579    fn from_channel(inner: fidl::Channel) -> Self {
580        Self::new(inner)
581    }
582
583    fn into_channel(self) -> fidl::Channel {
584        self.client.into_channel()
585    }
586
587    fn as_channel(&self) -> &fidl::Channel {
588        self.client.as_channel()
589    }
590}
591
592#[cfg(target_os = "fuchsia")]
593impl BatteryInfoWatcherSynchronousProxy {
594    pub fn new(channel: fidl::Channel) -> Self {
595        let protocol_name =
596            <BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
597        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
598    }
599
600    pub fn into_channel(self) -> fidl::Channel {
601        self.client.into_channel()
602    }
603
604    /// Waits until an event arrives and returns it. It is safe for other
605    /// threads to make concurrent requests while waiting for an event.
606    pub fn wait_for_event(
607        &self,
608        deadline: zx::MonotonicInstant,
609    ) -> Result<BatteryInfoWatcherEvent, fidl::Error> {
610        BatteryInfoWatcherEvent::decode(self.client.wait_for_event(deadline)?)
611    }
612
613    /// Callback triggered when battery info changes.
614    pub fn r#on_change_battery_info(
615        &self,
616        mut info: &BatteryInfo,
617        mut wake_lease: Option<fidl::EventPair>,
618        ___deadline: zx::MonotonicInstant,
619    ) -> Result<(), fidl::Error> {
620        let _response = self.client.send_query::<
621            BatteryInfoWatcherOnChangeBatteryInfoRequest,
622            fidl::encoding::EmptyPayload,
623        >(
624            (info, wake_lease,),
625            0x2d1eb8ed2b619a7d,
626            fidl::encoding::DynamicFlags::empty(),
627            ___deadline,
628        )?;
629        Ok(_response)
630    }
631}
632
633#[cfg(target_os = "fuchsia")]
634impl From<BatteryInfoWatcherSynchronousProxy> for zx::Handle {
635    fn from(value: BatteryInfoWatcherSynchronousProxy) -> Self {
636        value.into_channel().into()
637    }
638}
639
640#[cfg(target_os = "fuchsia")]
641impl From<fidl::Channel> for BatteryInfoWatcherSynchronousProxy {
642    fn from(value: fidl::Channel) -> Self {
643        Self::new(value)
644    }
645}
646
647#[cfg(target_os = "fuchsia")]
648impl fidl::endpoints::FromClient for BatteryInfoWatcherSynchronousProxy {
649    type Protocol = BatteryInfoWatcherMarker;
650
651    fn from_client(value: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>) -> Self {
652        Self::new(value.into_channel())
653    }
654}
655
656#[derive(Debug, Clone)]
657pub struct BatteryInfoWatcherProxy {
658    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
659}
660
661impl fidl::endpoints::Proxy for BatteryInfoWatcherProxy {
662    type Protocol = BatteryInfoWatcherMarker;
663
664    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
665        Self::new(inner)
666    }
667
668    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
669        self.client.into_channel().map_err(|client| Self { client })
670    }
671
672    fn as_channel(&self) -> &::fidl::AsyncChannel {
673        self.client.as_channel()
674    }
675}
676
677impl BatteryInfoWatcherProxy {
678    /// Create a new Proxy for fuchsia.power.battery/BatteryInfoWatcher.
679    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
680        let protocol_name =
681            <BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
682        Self { client: fidl::client::Client::new(channel, protocol_name) }
683    }
684
685    /// Get a Stream of events from the remote end of the protocol.
686    ///
687    /// # Panics
688    ///
689    /// Panics if the event stream was already taken.
690    pub fn take_event_stream(&self) -> BatteryInfoWatcherEventStream {
691        BatteryInfoWatcherEventStream { event_receiver: self.client.take_event_receiver() }
692    }
693
694    /// Callback triggered when battery info changes.
695    pub fn r#on_change_battery_info(
696        &self,
697        mut info: &BatteryInfo,
698        mut wake_lease: Option<fidl::EventPair>,
699    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
700        BatteryInfoWatcherProxyInterface::r#on_change_battery_info(self, info, wake_lease)
701    }
702}
703
704impl BatteryInfoWatcherProxyInterface for BatteryInfoWatcherProxy {
705    type OnChangeBatteryInfoResponseFut =
706        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
707    fn r#on_change_battery_info(
708        &self,
709        mut info: &BatteryInfo,
710        mut wake_lease: Option<fidl::EventPair>,
711    ) -> Self::OnChangeBatteryInfoResponseFut {
712        fn _decode(
713            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
714        ) -> Result<(), fidl::Error> {
715            let _response = fidl::client::decode_transaction_body::<
716                fidl::encoding::EmptyPayload,
717                fidl::encoding::DefaultFuchsiaResourceDialect,
718                0x2d1eb8ed2b619a7d,
719            >(_buf?)?;
720            Ok(_response)
721        }
722        self.client.send_query_and_decode::<BatteryInfoWatcherOnChangeBatteryInfoRequest, ()>(
723            (info, wake_lease),
724            0x2d1eb8ed2b619a7d,
725            fidl::encoding::DynamicFlags::empty(),
726            _decode,
727        )
728    }
729}
730
731pub struct BatteryInfoWatcherEventStream {
732    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
733}
734
735impl std::marker::Unpin for BatteryInfoWatcherEventStream {}
736
737impl futures::stream::FusedStream for BatteryInfoWatcherEventStream {
738    fn is_terminated(&self) -> bool {
739        self.event_receiver.is_terminated()
740    }
741}
742
743impl futures::Stream for BatteryInfoWatcherEventStream {
744    type Item = Result<BatteryInfoWatcherEvent, fidl::Error>;
745
746    fn poll_next(
747        mut self: std::pin::Pin<&mut Self>,
748        cx: &mut std::task::Context<'_>,
749    ) -> std::task::Poll<Option<Self::Item>> {
750        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
751            &mut self.event_receiver,
752            cx
753        )?) {
754            Some(buf) => std::task::Poll::Ready(Some(BatteryInfoWatcherEvent::decode(buf))),
755            None => std::task::Poll::Ready(None),
756        }
757    }
758}
759
760#[derive(Debug)]
761pub enum BatteryInfoWatcherEvent {}
762
763impl BatteryInfoWatcherEvent {
764    /// Decodes a message buffer as a [`BatteryInfoWatcherEvent`].
765    fn decode(
766        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
767    ) -> Result<BatteryInfoWatcherEvent, fidl::Error> {
768        let (bytes, _handles) = buf.split_mut();
769        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
770        debug_assert_eq!(tx_header.tx_id, 0);
771        match tx_header.ordinal {
772            _ => Err(fidl::Error::UnknownOrdinal {
773                ordinal: tx_header.ordinal,
774                protocol_name:
775                    <BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
776            }),
777        }
778    }
779}
780
781/// A Stream of incoming requests for fuchsia.power.battery/BatteryInfoWatcher.
782pub struct BatteryInfoWatcherRequestStream {
783    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
784    is_terminated: bool,
785}
786
787impl std::marker::Unpin for BatteryInfoWatcherRequestStream {}
788
789impl futures::stream::FusedStream for BatteryInfoWatcherRequestStream {
790    fn is_terminated(&self) -> bool {
791        self.is_terminated
792    }
793}
794
795impl fidl::endpoints::RequestStream for BatteryInfoWatcherRequestStream {
796    type Protocol = BatteryInfoWatcherMarker;
797    type ControlHandle = BatteryInfoWatcherControlHandle;
798
799    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
800        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
801    }
802
803    fn control_handle(&self) -> Self::ControlHandle {
804        BatteryInfoWatcherControlHandle { inner: self.inner.clone() }
805    }
806
807    fn into_inner(
808        self,
809    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
810    {
811        (self.inner, self.is_terminated)
812    }
813
814    fn from_inner(
815        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
816        is_terminated: bool,
817    ) -> Self {
818        Self { inner, is_terminated }
819    }
820}
821
822impl futures::Stream for BatteryInfoWatcherRequestStream {
823    type Item = Result<BatteryInfoWatcherRequest, fidl::Error>;
824
825    fn poll_next(
826        mut self: std::pin::Pin<&mut Self>,
827        cx: &mut std::task::Context<'_>,
828    ) -> std::task::Poll<Option<Self::Item>> {
829        let this = &mut *self;
830        if this.inner.check_shutdown(cx) {
831            this.is_terminated = true;
832            return std::task::Poll::Ready(None);
833        }
834        if this.is_terminated {
835            panic!("polled BatteryInfoWatcherRequestStream after completion");
836        }
837        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
838            |bytes, handles| {
839                match this.inner.channel().read_etc(cx, bytes, handles) {
840                    std::task::Poll::Ready(Ok(())) => {}
841                    std::task::Poll::Pending => return std::task::Poll::Pending,
842                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
843                        this.is_terminated = true;
844                        return std::task::Poll::Ready(None);
845                    }
846                    std::task::Poll::Ready(Err(e)) => {
847                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
848                            e.into(),
849                        ))));
850                    }
851                }
852
853                // A message has been received from the channel
854                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
855
856                std::task::Poll::Ready(Some(match header.ordinal {
857                0x2d1eb8ed2b619a7d => {
858                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
859                    let mut req = fidl::new_empty!(BatteryInfoWatcherOnChangeBatteryInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
860                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(&header, _body_bytes, handles, &mut req)?;
861                    let control_handle = BatteryInfoWatcherControlHandle {
862                        inner: this.inner.clone(),
863                    };
864                    Ok(BatteryInfoWatcherRequest::OnChangeBatteryInfo {info: req.info,
865wake_lease: req.wake_lease,
866
867                        responder: BatteryInfoWatcherOnChangeBatteryInfoResponder {
868                            control_handle: std::mem::ManuallyDrop::new(control_handle),
869                            tx_id: header.tx_id,
870                        },
871                    })
872                }
873                _ => Err(fidl::Error::UnknownOrdinal {
874                    ordinal: header.ordinal,
875                    protocol_name: <BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
876                }),
877            }))
878            },
879        )
880    }
881}
882
883/// Watcher on battery info.
884#[derive(Debug)]
885pub enum BatteryInfoWatcherRequest {
886    /// Callback triggered when battery info changes.
887    OnChangeBatteryInfo {
888        info: BatteryInfo,
889        wake_lease: Option<fidl::EventPair>,
890        responder: BatteryInfoWatcherOnChangeBatteryInfoResponder,
891    },
892}
893
894impl BatteryInfoWatcherRequest {
895    #[allow(irrefutable_let_patterns)]
896    pub fn into_on_change_battery_info(
897        self,
898    ) -> Option<(
899        BatteryInfo,
900        Option<fidl::EventPair>,
901        BatteryInfoWatcherOnChangeBatteryInfoResponder,
902    )> {
903        if let BatteryInfoWatcherRequest::OnChangeBatteryInfo { info, wake_lease, responder } = self
904        {
905            Some((info, wake_lease, responder))
906        } else {
907            None
908        }
909    }
910
911    /// Name of the method defined in FIDL
912    pub fn method_name(&self) -> &'static str {
913        match *self {
914            BatteryInfoWatcherRequest::OnChangeBatteryInfo { .. } => "on_change_battery_info",
915        }
916    }
917}
918
919#[derive(Debug, Clone)]
920pub struct BatteryInfoWatcherControlHandle {
921    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
922}
923
924impl fidl::endpoints::ControlHandle for BatteryInfoWatcherControlHandle {
925    fn shutdown(&self) {
926        self.inner.shutdown()
927    }
928    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
929        self.inner.shutdown_with_epitaph(status)
930    }
931
932    fn is_closed(&self) -> bool {
933        self.inner.channel().is_closed()
934    }
935    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
936        self.inner.channel().on_closed()
937    }
938
939    #[cfg(target_os = "fuchsia")]
940    fn signal_peer(
941        &self,
942        clear_mask: zx::Signals,
943        set_mask: zx::Signals,
944    ) -> Result<(), zx_status::Status> {
945        use fidl::Peered;
946        self.inner.channel().signal_peer(clear_mask, set_mask)
947    }
948}
949
950impl BatteryInfoWatcherControlHandle {}
951
952#[must_use = "FIDL methods require a response to be sent"]
953#[derive(Debug)]
954pub struct BatteryInfoWatcherOnChangeBatteryInfoResponder {
955    control_handle: std::mem::ManuallyDrop<BatteryInfoWatcherControlHandle>,
956    tx_id: u32,
957}
958
959/// Set the the channel to be shutdown (see [`BatteryInfoWatcherControlHandle::shutdown`])
960/// if the responder is dropped without sending a response, so that the client
961/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
962impl std::ops::Drop for BatteryInfoWatcherOnChangeBatteryInfoResponder {
963    fn drop(&mut self) {
964        self.control_handle.shutdown();
965        // Safety: drops once, never accessed again
966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
967    }
968}
969
970impl fidl::endpoints::Responder for BatteryInfoWatcherOnChangeBatteryInfoResponder {
971    type ControlHandle = BatteryInfoWatcherControlHandle;
972
973    fn control_handle(&self) -> &BatteryInfoWatcherControlHandle {
974        &self.control_handle
975    }
976
977    fn drop_without_shutdown(mut self) {
978        // Safety: drops once, never accessed again due to mem::forget
979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
980        // Prevent Drop from running (which would shut down the channel)
981        std::mem::forget(self);
982    }
983}
984
985impl BatteryInfoWatcherOnChangeBatteryInfoResponder {
986    /// Sends a response to the FIDL transaction.
987    ///
988    /// Sets the channel to shutdown if an error occurs.
989    pub fn send(self) -> Result<(), fidl::Error> {
990        let _result = self.send_raw();
991        if _result.is_err() {
992            self.control_handle.shutdown();
993        }
994        self.drop_without_shutdown();
995        _result
996    }
997
998    /// Similar to "send" but does not shutdown the channel if an error occurs.
999    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1000        let _result = self.send_raw();
1001        self.drop_without_shutdown();
1002        _result
1003    }
1004
1005    fn send_raw(&self) -> Result<(), fidl::Error> {
1006        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1007            (),
1008            self.tx_id,
1009            0x2d1eb8ed2b619a7d,
1010            fidl::encoding::DynamicFlags::empty(),
1011        )
1012    }
1013}
1014
1015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1016pub struct BatteryManagerMarker;
1017
1018impl fidl::endpoints::ProtocolMarker for BatteryManagerMarker {
1019    type Proxy = BatteryManagerProxy;
1020    type RequestStream = BatteryManagerRequestStream;
1021    #[cfg(target_os = "fuchsia")]
1022    type SynchronousProxy = BatteryManagerSynchronousProxy;
1023
1024    const DEBUG_NAME: &'static str = "fuchsia.power.battery.BatteryManager";
1025}
1026impl fidl::endpoints::DiscoverableProtocolMarker for BatteryManagerMarker {}
1027
1028pub trait BatteryManagerProxyInterface: Send + Sync {
1029    type GetBatteryInfoResponseFut: std::future::Future<Output = Result<BatteryInfo, fidl::Error>>
1030        + Send;
1031    fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
1032    fn r#watch(
1033        &self,
1034        watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
1035    ) -> Result<(), fidl::Error>;
1036}
1037#[derive(Debug)]
1038#[cfg(target_os = "fuchsia")]
1039pub struct BatteryManagerSynchronousProxy {
1040    client: fidl::client::sync::Client,
1041}
1042
1043#[cfg(target_os = "fuchsia")]
1044impl fidl::endpoints::SynchronousProxy for BatteryManagerSynchronousProxy {
1045    type Proxy = BatteryManagerProxy;
1046    type Protocol = BatteryManagerMarker;
1047
1048    fn from_channel(inner: fidl::Channel) -> Self {
1049        Self::new(inner)
1050    }
1051
1052    fn into_channel(self) -> fidl::Channel {
1053        self.client.into_channel()
1054    }
1055
1056    fn as_channel(&self) -> &fidl::Channel {
1057        self.client.as_channel()
1058    }
1059}
1060
1061#[cfg(target_os = "fuchsia")]
1062impl BatteryManagerSynchronousProxy {
1063    pub fn new(channel: fidl::Channel) -> Self {
1064        let protocol_name = <BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1065        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1066    }
1067
1068    pub fn into_channel(self) -> fidl::Channel {
1069        self.client.into_channel()
1070    }
1071
1072    /// Waits until an event arrives and returns it. It is safe for other
1073    /// threads to make concurrent requests while waiting for an event.
1074    pub fn wait_for_event(
1075        &self,
1076        deadline: zx::MonotonicInstant,
1077    ) -> Result<BatteryManagerEvent, fidl::Error> {
1078        BatteryManagerEvent::decode(self.client.wait_for_event(deadline)?)
1079    }
1080
1081    /// Gets battery info.
1082    pub fn r#get_battery_info(
1083        &self,
1084        ___deadline: zx::MonotonicInstant,
1085    ) -> Result<BatteryInfo, fidl::Error> {
1086        let _response = self
1087            .client
1088            .send_query::<fidl::encoding::EmptyPayload, BatteryInfoProviderGetBatteryInfoResponse>(
1089                (),
1090                0x51ea101e4fe7a192,
1091                fidl::encoding::DynamicFlags::empty(),
1092                ___deadline,
1093            )?;
1094        Ok(_response.info)
1095    }
1096
1097    /// Registers a watcher for battery info changes.
1098    pub fn r#watch(
1099        &self,
1100        mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
1101    ) -> Result<(), fidl::Error> {
1102        self.client.send::<BatteryInfoProviderWatchRequest>(
1103            (watcher,),
1104            0x4d44a314cd3f5191,
1105            fidl::encoding::DynamicFlags::empty(),
1106        )
1107    }
1108}
1109
1110#[cfg(target_os = "fuchsia")]
1111impl From<BatteryManagerSynchronousProxy> for zx::Handle {
1112    fn from(value: BatteryManagerSynchronousProxy) -> Self {
1113        value.into_channel().into()
1114    }
1115}
1116
1117#[cfg(target_os = "fuchsia")]
1118impl From<fidl::Channel> for BatteryManagerSynchronousProxy {
1119    fn from(value: fidl::Channel) -> Self {
1120        Self::new(value)
1121    }
1122}
1123
1124#[cfg(target_os = "fuchsia")]
1125impl fidl::endpoints::FromClient for BatteryManagerSynchronousProxy {
1126    type Protocol = BatteryManagerMarker;
1127
1128    fn from_client(value: fidl::endpoints::ClientEnd<BatteryManagerMarker>) -> Self {
1129        Self::new(value.into_channel())
1130    }
1131}
1132
1133#[derive(Debug, Clone)]
1134pub struct BatteryManagerProxy {
1135    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1136}
1137
1138impl fidl::endpoints::Proxy for BatteryManagerProxy {
1139    type Protocol = BatteryManagerMarker;
1140
1141    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1142        Self::new(inner)
1143    }
1144
1145    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1146        self.client.into_channel().map_err(|client| Self { client })
1147    }
1148
1149    fn as_channel(&self) -> &::fidl::AsyncChannel {
1150        self.client.as_channel()
1151    }
1152}
1153
1154impl BatteryManagerProxy {
1155    /// Create a new Proxy for fuchsia.power.battery/BatteryManager.
1156    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1157        let protocol_name = <BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1158        Self { client: fidl::client::Client::new(channel, protocol_name) }
1159    }
1160
1161    /// Get a Stream of events from the remote end of the protocol.
1162    ///
1163    /// # Panics
1164    ///
1165    /// Panics if the event stream was already taken.
1166    pub fn take_event_stream(&self) -> BatteryManagerEventStream {
1167        BatteryManagerEventStream { event_receiver: self.client.take_event_receiver() }
1168    }
1169
1170    /// Gets battery info.
1171    pub fn r#get_battery_info(
1172        &self,
1173    ) -> fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
1174    {
1175        BatteryManagerProxyInterface::r#get_battery_info(self)
1176    }
1177
1178    /// Registers a watcher for battery info changes.
1179    pub fn r#watch(
1180        &self,
1181        mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
1182    ) -> Result<(), fidl::Error> {
1183        BatteryManagerProxyInterface::r#watch(self, watcher)
1184    }
1185}
1186
1187impl BatteryManagerProxyInterface for BatteryManagerProxy {
1188    type GetBatteryInfoResponseFut =
1189        fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1190    fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
1191        fn _decode(
1192            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1193        ) -> Result<BatteryInfo, fidl::Error> {
1194            let _response = fidl::client::decode_transaction_body::<
1195                BatteryInfoProviderGetBatteryInfoResponse,
1196                fidl::encoding::DefaultFuchsiaResourceDialect,
1197                0x51ea101e4fe7a192,
1198            >(_buf?)?;
1199            Ok(_response.info)
1200        }
1201        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BatteryInfo>(
1202            (),
1203            0x51ea101e4fe7a192,
1204            fidl::encoding::DynamicFlags::empty(),
1205            _decode,
1206        )
1207    }
1208
1209    fn r#watch(
1210        &self,
1211        mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
1212    ) -> Result<(), fidl::Error> {
1213        self.client.send::<BatteryInfoProviderWatchRequest>(
1214            (watcher,),
1215            0x4d44a314cd3f5191,
1216            fidl::encoding::DynamicFlags::empty(),
1217        )
1218    }
1219}
1220
1221pub struct BatteryManagerEventStream {
1222    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1223}
1224
1225impl std::marker::Unpin for BatteryManagerEventStream {}
1226
1227impl futures::stream::FusedStream for BatteryManagerEventStream {
1228    fn is_terminated(&self) -> bool {
1229        self.event_receiver.is_terminated()
1230    }
1231}
1232
1233impl futures::Stream for BatteryManagerEventStream {
1234    type Item = Result<BatteryManagerEvent, fidl::Error>;
1235
1236    fn poll_next(
1237        mut self: std::pin::Pin<&mut Self>,
1238        cx: &mut std::task::Context<'_>,
1239    ) -> std::task::Poll<Option<Self::Item>> {
1240        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1241            &mut self.event_receiver,
1242            cx
1243        )?) {
1244            Some(buf) => std::task::Poll::Ready(Some(BatteryManagerEvent::decode(buf))),
1245            None => std::task::Poll::Ready(None),
1246        }
1247    }
1248}
1249
1250#[derive(Debug)]
1251pub enum BatteryManagerEvent {}
1252
1253impl BatteryManagerEvent {
1254    /// Decodes a message buffer as a [`BatteryManagerEvent`].
1255    fn decode(
1256        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1257    ) -> Result<BatteryManagerEvent, fidl::Error> {
1258        let (bytes, _handles) = buf.split_mut();
1259        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1260        debug_assert_eq!(tx_header.tx_id, 0);
1261        match tx_header.ordinal {
1262            _ => Err(fidl::Error::UnknownOrdinal {
1263                ordinal: tx_header.ordinal,
1264                protocol_name:
1265                    <BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1266            }),
1267        }
1268    }
1269}
1270
1271/// A Stream of incoming requests for fuchsia.power.battery/BatteryManager.
1272pub struct BatteryManagerRequestStream {
1273    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1274    is_terminated: bool,
1275}
1276
1277impl std::marker::Unpin for BatteryManagerRequestStream {}
1278
1279impl futures::stream::FusedStream for BatteryManagerRequestStream {
1280    fn is_terminated(&self) -> bool {
1281        self.is_terminated
1282    }
1283}
1284
1285impl fidl::endpoints::RequestStream for BatteryManagerRequestStream {
1286    type Protocol = BatteryManagerMarker;
1287    type ControlHandle = BatteryManagerControlHandle;
1288
1289    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1290        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1291    }
1292
1293    fn control_handle(&self) -> Self::ControlHandle {
1294        BatteryManagerControlHandle { inner: self.inner.clone() }
1295    }
1296
1297    fn into_inner(
1298        self,
1299    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1300    {
1301        (self.inner, self.is_terminated)
1302    }
1303
1304    fn from_inner(
1305        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1306        is_terminated: bool,
1307    ) -> Self {
1308        Self { inner, is_terminated }
1309    }
1310}
1311
1312impl futures::Stream for BatteryManagerRequestStream {
1313    type Item = Result<BatteryManagerRequest, fidl::Error>;
1314
1315    fn poll_next(
1316        mut self: std::pin::Pin<&mut Self>,
1317        cx: &mut std::task::Context<'_>,
1318    ) -> std::task::Poll<Option<Self::Item>> {
1319        let this = &mut *self;
1320        if this.inner.check_shutdown(cx) {
1321            this.is_terminated = true;
1322            return std::task::Poll::Ready(None);
1323        }
1324        if this.is_terminated {
1325            panic!("polled BatteryManagerRequestStream after completion");
1326        }
1327        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1328            |bytes, handles| {
1329                match this.inner.channel().read_etc(cx, bytes, handles) {
1330                    std::task::Poll::Ready(Ok(())) => {}
1331                    std::task::Poll::Pending => return std::task::Poll::Pending,
1332                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1333                        this.is_terminated = true;
1334                        return std::task::Poll::Ready(None);
1335                    }
1336                    std::task::Poll::Ready(Err(e)) => {
1337                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1338                            e.into(),
1339                        ))));
1340                    }
1341                }
1342
1343                // A message has been received from the channel
1344                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1345
1346                std::task::Poll::Ready(Some(match header.ordinal {
1347                    0x51ea101e4fe7a192 => {
1348                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1349                        let mut req = fidl::new_empty!(
1350                            fidl::encoding::EmptyPayload,
1351                            fidl::encoding::DefaultFuchsiaResourceDialect
1352                        );
1353                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1354                        let control_handle =
1355                            BatteryManagerControlHandle { inner: this.inner.clone() };
1356                        Ok(BatteryManagerRequest::GetBatteryInfo {
1357                            responder: BatteryManagerGetBatteryInfoResponder {
1358                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1359                                tx_id: header.tx_id,
1360                            },
1361                        })
1362                    }
1363                    0x4d44a314cd3f5191 => {
1364                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1365                        let mut req = fidl::new_empty!(
1366                            BatteryInfoProviderWatchRequest,
1367                            fidl::encoding::DefaultFuchsiaResourceDialect
1368                        );
1369                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoProviderWatchRequest>(&header, _body_bytes, handles, &mut req)?;
1370                        let control_handle =
1371                            BatteryManagerControlHandle { inner: this.inner.clone() };
1372                        Ok(BatteryManagerRequest::Watch { watcher: req.watcher, control_handle })
1373                    }
1374                    _ => Err(fidl::Error::UnknownOrdinal {
1375                        ordinal: header.ordinal,
1376                        protocol_name:
1377                            <BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1378                    }),
1379                }))
1380            },
1381        )
1382    }
1383}
1384
1385/// General manager interface for battery management.
1386#[derive(Debug)]
1387pub enum BatteryManagerRequest {
1388    /// Gets battery info.
1389    GetBatteryInfo { responder: BatteryManagerGetBatteryInfoResponder },
1390    /// Registers a watcher for battery info changes.
1391    Watch {
1392        watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
1393        control_handle: BatteryManagerControlHandle,
1394    },
1395}
1396
1397impl BatteryManagerRequest {
1398    #[allow(irrefutable_let_patterns)]
1399    pub fn into_get_battery_info(self) -> Option<(BatteryManagerGetBatteryInfoResponder)> {
1400        if let BatteryManagerRequest::GetBatteryInfo { responder } = self {
1401            Some((responder))
1402        } else {
1403            None
1404        }
1405    }
1406
1407    #[allow(irrefutable_let_patterns)]
1408    pub fn into_watch(
1409        self,
1410    ) -> Option<(fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>, BatteryManagerControlHandle)>
1411    {
1412        if let BatteryManagerRequest::Watch { watcher, control_handle } = self {
1413            Some((watcher, control_handle))
1414        } else {
1415            None
1416        }
1417    }
1418
1419    /// Name of the method defined in FIDL
1420    pub fn method_name(&self) -> &'static str {
1421        match *self {
1422            BatteryManagerRequest::GetBatteryInfo { .. } => "get_battery_info",
1423            BatteryManagerRequest::Watch { .. } => "watch",
1424        }
1425    }
1426}
1427
1428#[derive(Debug, Clone)]
1429pub struct BatteryManagerControlHandle {
1430    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1431}
1432
1433impl fidl::endpoints::ControlHandle for BatteryManagerControlHandle {
1434    fn shutdown(&self) {
1435        self.inner.shutdown()
1436    }
1437    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1438        self.inner.shutdown_with_epitaph(status)
1439    }
1440
1441    fn is_closed(&self) -> bool {
1442        self.inner.channel().is_closed()
1443    }
1444    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1445        self.inner.channel().on_closed()
1446    }
1447
1448    #[cfg(target_os = "fuchsia")]
1449    fn signal_peer(
1450        &self,
1451        clear_mask: zx::Signals,
1452        set_mask: zx::Signals,
1453    ) -> Result<(), zx_status::Status> {
1454        use fidl::Peered;
1455        self.inner.channel().signal_peer(clear_mask, set_mask)
1456    }
1457}
1458
1459impl BatteryManagerControlHandle {}
1460
1461#[must_use = "FIDL methods require a response to be sent"]
1462#[derive(Debug)]
1463pub struct BatteryManagerGetBatteryInfoResponder {
1464    control_handle: std::mem::ManuallyDrop<BatteryManagerControlHandle>,
1465    tx_id: u32,
1466}
1467
1468/// Set the the channel to be shutdown (see [`BatteryManagerControlHandle::shutdown`])
1469/// if the responder is dropped without sending a response, so that the client
1470/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1471impl std::ops::Drop for BatteryManagerGetBatteryInfoResponder {
1472    fn drop(&mut self) {
1473        self.control_handle.shutdown();
1474        // Safety: drops once, never accessed again
1475        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1476    }
1477}
1478
1479impl fidl::endpoints::Responder for BatteryManagerGetBatteryInfoResponder {
1480    type ControlHandle = BatteryManagerControlHandle;
1481
1482    fn control_handle(&self) -> &BatteryManagerControlHandle {
1483        &self.control_handle
1484    }
1485
1486    fn drop_without_shutdown(mut self) {
1487        // Safety: drops once, never accessed again due to mem::forget
1488        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1489        // Prevent Drop from running (which would shut down the channel)
1490        std::mem::forget(self);
1491    }
1492}
1493
1494impl BatteryManagerGetBatteryInfoResponder {
1495    /// Sends a response to the FIDL transaction.
1496    ///
1497    /// Sets the channel to shutdown if an error occurs.
1498    pub fn send(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
1499        let _result = self.send_raw(info);
1500        if _result.is_err() {
1501            self.control_handle.shutdown();
1502        }
1503        self.drop_without_shutdown();
1504        _result
1505    }
1506
1507    /// Similar to "send" but does not shutdown the channel if an error occurs.
1508    pub fn send_no_shutdown_on_err(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
1509        let _result = self.send_raw(info);
1510        self.drop_without_shutdown();
1511        _result
1512    }
1513
1514    fn send_raw(&self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
1515        self.control_handle.inner.send::<BatteryInfoProviderGetBatteryInfoResponse>(
1516            (info,),
1517            self.tx_id,
1518            0x51ea101e4fe7a192,
1519            fidl::encoding::DynamicFlags::empty(),
1520        )
1521    }
1522}
1523
1524#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1525pub struct ChargerMarker;
1526
1527impl fidl::endpoints::ProtocolMarker for ChargerMarker {
1528    type Proxy = ChargerProxy;
1529    type RequestStream = ChargerRequestStream;
1530    #[cfg(target_os = "fuchsia")]
1531    type SynchronousProxy = ChargerSynchronousProxy;
1532
1533    const DEBUG_NAME: &'static str = "fuchsia.power.battery.Charger";
1534}
1535impl fidl::endpoints::DiscoverableProtocolMarker for ChargerMarker {}
1536pub type ChargerEnableResult = Result<(), i32>;
1537
1538pub trait ChargerProxyInterface: Send + Sync {
1539    type EnableResponseFut: std::future::Future<Output = Result<ChargerEnableResult, fidl::Error>>
1540        + Send;
1541    fn r#enable(&self, enable: bool) -> Self::EnableResponseFut;
1542}
1543#[derive(Debug)]
1544#[cfg(target_os = "fuchsia")]
1545pub struct ChargerSynchronousProxy {
1546    client: fidl::client::sync::Client,
1547}
1548
1549#[cfg(target_os = "fuchsia")]
1550impl fidl::endpoints::SynchronousProxy for ChargerSynchronousProxy {
1551    type Proxy = ChargerProxy;
1552    type Protocol = ChargerMarker;
1553
1554    fn from_channel(inner: fidl::Channel) -> Self {
1555        Self::new(inner)
1556    }
1557
1558    fn into_channel(self) -> fidl::Channel {
1559        self.client.into_channel()
1560    }
1561
1562    fn as_channel(&self) -> &fidl::Channel {
1563        self.client.as_channel()
1564    }
1565}
1566
1567#[cfg(target_os = "fuchsia")]
1568impl ChargerSynchronousProxy {
1569    pub fn new(channel: fidl::Channel) -> Self {
1570        let protocol_name = <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1571        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1572    }
1573
1574    pub fn into_channel(self) -> fidl::Channel {
1575        self.client.into_channel()
1576    }
1577
1578    /// Waits until an event arrives and returns it. It is safe for other
1579    /// threads to make concurrent requests while waiting for an event.
1580    pub fn wait_for_event(
1581        &self,
1582        deadline: zx::MonotonicInstant,
1583    ) -> Result<ChargerEvent, fidl::Error> {
1584        ChargerEvent::decode(self.client.wait_for_event(deadline)?)
1585    }
1586
1587    pub fn r#enable(
1588        &self,
1589        mut enable: bool,
1590        ___deadline: zx::MonotonicInstant,
1591    ) -> Result<ChargerEnableResult, fidl::Error> {
1592        let _response = self.client.send_query::<
1593            ChargerEnableRequest,
1594            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1595        >(
1596            (enable,),
1597            0x5b3feccb039ff5ed,
1598            fidl::encoding::DynamicFlags::FLEXIBLE,
1599            ___deadline,
1600        )?
1601        .into_result::<ChargerMarker>("enable")?;
1602        Ok(_response.map(|x| x))
1603    }
1604}
1605
1606#[cfg(target_os = "fuchsia")]
1607impl From<ChargerSynchronousProxy> for zx::Handle {
1608    fn from(value: ChargerSynchronousProxy) -> Self {
1609        value.into_channel().into()
1610    }
1611}
1612
1613#[cfg(target_os = "fuchsia")]
1614impl From<fidl::Channel> for ChargerSynchronousProxy {
1615    fn from(value: fidl::Channel) -> Self {
1616        Self::new(value)
1617    }
1618}
1619
1620#[cfg(target_os = "fuchsia")]
1621impl fidl::endpoints::FromClient for ChargerSynchronousProxy {
1622    type Protocol = ChargerMarker;
1623
1624    fn from_client(value: fidl::endpoints::ClientEnd<ChargerMarker>) -> Self {
1625        Self::new(value.into_channel())
1626    }
1627}
1628
1629#[derive(Debug, Clone)]
1630pub struct ChargerProxy {
1631    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1632}
1633
1634impl fidl::endpoints::Proxy for ChargerProxy {
1635    type Protocol = ChargerMarker;
1636
1637    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1638        Self::new(inner)
1639    }
1640
1641    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1642        self.client.into_channel().map_err(|client| Self { client })
1643    }
1644
1645    fn as_channel(&self) -> &::fidl::AsyncChannel {
1646        self.client.as_channel()
1647    }
1648}
1649
1650impl ChargerProxy {
1651    /// Create a new Proxy for fuchsia.power.battery/Charger.
1652    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1653        let protocol_name = <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1654        Self { client: fidl::client::Client::new(channel, protocol_name) }
1655    }
1656
1657    /// Get a Stream of events from the remote end of the protocol.
1658    ///
1659    /// # Panics
1660    ///
1661    /// Panics if the event stream was already taken.
1662    pub fn take_event_stream(&self) -> ChargerEventStream {
1663        ChargerEventStream { event_receiver: self.client.take_event_receiver() }
1664    }
1665
1666    pub fn r#enable(
1667        &self,
1668        mut enable: bool,
1669    ) -> fidl::client::QueryResponseFut<
1670        ChargerEnableResult,
1671        fidl::encoding::DefaultFuchsiaResourceDialect,
1672    > {
1673        ChargerProxyInterface::r#enable(self, enable)
1674    }
1675}
1676
1677impl ChargerProxyInterface for ChargerProxy {
1678    type EnableResponseFut = fidl::client::QueryResponseFut<
1679        ChargerEnableResult,
1680        fidl::encoding::DefaultFuchsiaResourceDialect,
1681    >;
1682    fn r#enable(&self, mut enable: bool) -> Self::EnableResponseFut {
1683        fn _decode(
1684            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1685        ) -> Result<ChargerEnableResult, fidl::Error> {
1686            let _response = fidl::client::decode_transaction_body::<
1687                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1688                fidl::encoding::DefaultFuchsiaResourceDialect,
1689                0x5b3feccb039ff5ed,
1690            >(_buf?)?
1691            .into_result::<ChargerMarker>("enable")?;
1692            Ok(_response.map(|x| x))
1693        }
1694        self.client.send_query_and_decode::<ChargerEnableRequest, ChargerEnableResult>(
1695            (enable,),
1696            0x5b3feccb039ff5ed,
1697            fidl::encoding::DynamicFlags::FLEXIBLE,
1698            _decode,
1699        )
1700    }
1701}
1702
1703pub struct ChargerEventStream {
1704    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1705}
1706
1707impl std::marker::Unpin for ChargerEventStream {}
1708
1709impl futures::stream::FusedStream for ChargerEventStream {
1710    fn is_terminated(&self) -> bool {
1711        self.event_receiver.is_terminated()
1712    }
1713}
1714
1715impl futures::Stream for ChargerEventStream {
1716    type Item = Result<ChargerEvent, fidl::Error>;
1717
1718    fn poll_next(
1719        mut self: std::pin::Pin<&mut Self>,
1720        cx: &mut std::task::Context<'_>,
1721    ) -> std::task::Poll<Option<Self::Item>> {
1722        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1723            &mut self.event_receiver,
1724            cx
1725        )?) {
1726            Some(buf) => std::task::Poll::Ready(Some(ChargerEvent::decode(buf))),
1727            None => std::task::Poll::Ready(None),
1728        }
1729    }
1730}
1731
1732#[derive(Debug)]
1733pub enum ChargerEvent {
1734    #[non_exhaustive]
1735    _UnknownEvent {
1736        /// Ordinal of the event that was sent.
1737        ordinal: u64,
1738    },
1739}
1740
1741impl ChargerEvent {
1742    /// Decodes a message buffer as a [`ChargerEvent`].
1743    fn decode(
1744        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1745    ) -> Result<ChargerEvent, fidl::Error> {
1746        let (bytes, _handles) = buf.split_mut();
1747        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1748        debug_assert_eq!(tx_header.tx_id, 0);
1749        match tx_header.ordinal {
1750            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1751                Ok(ChargerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1752            }
1753            _ => Err(fidl::Error::UnknownOrdinal {
1754                ordinal: tx_header.ordinal,
1755                protocol_name: <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1756            }),
1757        }
1758    }
1759}
1760
1761/// A Stream of incoming requests for fuchsia.power.battery/Charger.
1762pub struct ChargerRequestStream {
1763    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1764    is_terminated: bool,
1765}
1766
1767impl std::marker::Unpin for ChargerRequestStream {}
1768
1769impl futures::stream::FusedStream for ChargerRequestStream {
1770    fn is_terminated(&self) -> bool {
1771        self.is_terminated
1772    }
1773}
1774
1775impl fidl::endpoints::RequestStream for ChargerRequestStream {
1776    type Protocol = ChargerMarker;
1777    type ControlHandle = ChargerControlHandle;
1778
1779    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1780        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1781    }
1782
1783    fn control_handle(&self) -> Self::ControlHandle {
1784        ChargerControlHandle { inner: self.inner.clone() }
1785    }
1786
1787    fn into_inner(
1788        self,
1789    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1790    {
1791        (self.inner, self.is_terminated)
1792    }
1793
1794    fn from_inner(
1795        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1796        is_terminated: bool,
1797    ) -> Self {
1798        Self { inner, is_terminated }
1799    }
1800}
1801
1802impl futures::Stream for ChargerRequestStream {
1803    type Item = Result<ChargerRequest, fidl::Error>;
1804
1805    fn poll_next(
1806        mut self: std::pin::Pin<&mut Self>,
1807        cx: &mut std::task::Context<'_>,
1808    ) -> std::task::Poll<Option<Self::Item>> {
1809        let this = &mut *self;
1810        if this.inner.check_shutdown(cx) {
1811            this.is_terminated = true;
1812            return std::task::Poll::Ready(None);
1813        }
1814        if this.is_terminated {
1815            panic!("polled ChargerRequestStream after completion");
1816        }
1817        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1818            |bytes, handles| {
1819                match this.inner.channel().read_etc(cx, bytes, handles) {
1820                    std::task::Poll::Ready(Ok(())) => {}
1821                    std::task::Poll::Pending => return std::task::Poll::Pending,
1822                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1823                        this.is_terminated = true;
1824                        return std::task::Poll::Ready(None);
1825                    }
1826                    std::task::Poll::Ready(Err(e)) => {
1827                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1828                            e.into(),
1829                        ))));
1830                    }
1831                }
1832
1833                // A message has been received from the channel
1834                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1835
1836                std::task::Poll::Ready(Some(match header.ordinal {
1837                    0x5b3feccb039ff5ed => {
1838                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1839                        let mut req = fidl::new_empty!(
1840                            ChargerEnableRequest,
1841                            fidl::encoding::DefaultFuchsiaResourceDialect
1842                        );
1843                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChargerEnableRequest>(&header, _body_bytes, handles, &mut req)?;
1844                        let control_handle = ChargerControlHandle { inner: this.inner.clone() };
1845                        Ok(ChargerRequest::Enable {
1846                            enable: req.enable,
1847
1848                            responder: ChargerEnableResponder {
1849                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1850                                tx_id: header.tx_id,
1851                            },
1852                        })
1853                    }
1854                    _ if header.tx_id == 0
1855                        && header
1856                            .dynamic_flags()
1857                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1858                    {
1859                        Ok(ChargerRequest::_UnknownMethod {
1860                            ordinal: header.ordinal,
1861                            control_handle: ChargerControlHandle { inner: this.inner.clone() },
1862                            method_type: fidl::MethodType::OneWay,
1863                        })
1864                    }
1865                    _ if header
1866                        .dynamic_flags()
1867                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1868                    {
1869                        this.inner.send_framework_err(
1870                            fidl::encoding::FrameworkErr::UnknownMethod,
1871                            header.tx_id,
1872                            header.ordinal,
1873                            header.dynamic_flags(),
1874                            (bytes, handles),
1875                        )?;
1876                        Ok(ChargerRequest::_UnknownMethod {
1877                            ordinal: header.ordinal,
1878                            control_handle: ChargerControlHandle { inner: this.inner.clone() },
1879                            method_type: fidl::MethodType::TwoWay,
1880                        })
1881                    }
1882                    _ => Err(fidl::Error::UnknownOrdinal {
1883                        ordinal: header.ordinal,
1884                        protocol_name:
1885                            <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1886                    }),
1887                }))
1888            },
1889        )
1890    }
1891}
1892
1893/// Charging control
1894#[derive(Debug)]
1895pub enum ChargerRequest {
1896    Enable {
1897        enable: bool,
1898        responder: ChargerEnableResponder,
1899    },
1900    /// An interaction was received which does not match any known method.
1901    #[non_exhaustive]
1902    _UnknownMethod {
1903        /// Ordinal of the method that was called.
1904        ordinal: u64,
1905        control_handle: ChargerControlHandle,
1906        method_type: fidl::MethodType,
1907    },
1908}
1909
1910impl ChargerRequest {
1911    #[allow(irrefutable_let_patterns)]
1912    pub fn into_enable(self) -> Option<(bool, ChargerEnableResponder)> {
1913        if let ChargerRequest::Enable { enable, responder } = self {
1914            Some((enable, responder))
1915        } else {
1916            None
1917        }
1918    }
1919
1920    /// Name of the method defined in FIDL
1921    pub fn method_name(&self) -> &'static str {
1922        match *self {
1923            ChargerRequest::Enable { .. } => "enable",
1924            ChargerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1925                "unknown one-way method"
1926            }
1927            ChargerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1928                "unknown two-way method"
1929            }
1930        }
1931    }
1932}
1933
1934#[derive(Debug, Clone)]
1935pub struct ChargerControlHandle {
1936    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1937}
1938
1939impl fidl::endpoints::ControlHandle for ChargerControlHandle {
1940    fn shutdown(&self) {
1941        self.inner.shutdown()
1942    }
1943    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1944        self.inner.shutdown_with_epitaph(status)
1945    }
1946
1947    fn is_closed(&self) -> bool {
1948        self.inner.channel().is_closed()
1949    }
1950    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1951        self.inner.channel().on_closed()
1952    }
1953
1954    #[cfg(target_os = "fuchsia")]
1955    fn signal_peer(
1956        &self,
1957        clear_mask: zx::Signals,
1958        set_mask: zx::Signals,
1959    ) -> Result<(), zx_status::Status> {
1960        use fidl::Peered;
1961        self.inner.channel().signal_peer(clear_mask, set_mask)
1962    }
1963}
1964
1965impl ChargerControlHandle {}
1966
1967#[must_use = "FIDL methods require a response to be sent"]
1968#[derive(Debug)]
1969pub struct ChargerEnableResponder {
1970    control_handle: std::mem::ManuallyDrop<ChargerControlHandle>,
1971    tx_id: u32,
1972}
1973
1974/// Set the the channel to be shutdown (see [`ChargerControlHandle::shutdown`])
1975/// if the responder is dropped without sending a response, so that the client
1976/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1977impl std::ops::Drop for ChargerEnableResponder {
1978    fn drop(&mut self) {
1979        self.control_handle.shutdown();
1980        // Safety: drops once, never accessed again
1981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1982    }
1983}
1984
1985impl fidl::endpoints::Responder for ChargerEnableResponder {
1986    type ControlHandle = ChargerControlHandle;
1987
1988    fn control_handle(&self) -> &ChargerControlHandle {
1989        &self.control_handle
1990    }
1991
1992    fn drop_without_shutdown(mut self) {
1993        // Safety: drops once, never accessed again due to mem::forget
1994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1995        // Prevent Drop from running (which would shut down the channel)
1996        std::mem::forget(self);
1997    }
1998}
1999
2000impl ChargerEnableResponder {
2001    /// Sends a response to the FIDL transaction.
2002    ///
2003    /// Sets the channel to shutdown if an error occurs.
2004    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2005        let _result = self.send_raw(result);
2006        if _result.is_err() {
2007            self.control_handle.shutdown();
2008        }
2009        self.drop_without_shutdown();
2010        _result
2011    }
2012
2013    /// Similar to "send" but does not shutdown the channel if an error occurs.
2014    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2015        let _result = self.send_raw(result);
2016        self.drop_without_shutdown();
2017        _result
2018    }
2019
2020    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2021        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2022            fidl::encoding::EmptyStruct,
2023            i32,
2024        >>(
2025            fidl::encoding::FlexibleResult::new(result),
2026            self.tx_id,
2027            0x5b3feccb039ff5ed,
2028            fidl::encoding::DynamicFlags::FLEXIBLE,
2029        )
2030    }
2031}
2032
2033#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2034pub struct ChargerServiceMarker;
2035
2036#[cfg(target_os = "fuchsia")]
2037impl fidl::endpoints::ServiceMarker for ChargerServiceMarker {
2038    type Proxy = ChargerServiceProxy;
2039    type Request = ChargerServiceRequest;
2040    const SERVICE_NAME: &'static str = "fuchsia.power.battery.ChargerService";
2041}
2042
2043/// A request for one of the member protocols of ChargerService.
2044///
2045#[cfg(target_os = "fuchsia")]
2046pub enum ChargerServiceRequest {
2047    Device(ChargerRequestStream),
2048}
2049
2050#[cfg(target_os = "fuchsia")]
2051impl fidl::endpoints::ServiceRequest for ChargerServiceRequest {
2052    type Service = ChargerServiceMarker;
2053
2054    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2055        match name {
2056            "device" => Self::Device(
2057                <ChargerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2058            ),
2059            _ => panic!("no such member protocol name for service ChargerService"),
2060        }
2061    }
2062
2063    fn member_names() -> &'static [&'static str] {
2064        &["device"]
2065    }
2066}
2067#[cfg(target_os = "fuchsia")]
2068pub struct ChargerServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2069
2070#[cfg(target_os = "fuchsia")]
2071impl fidl::endpoints::ServiceProxy for ChargerServiceProxy {
2072    type Service = ChargerServiceMarker;
2073
2074    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2075        Self(opener)
2076    }
2077}
2078
2079#[cfg(target_os = "fuchsia")]
2080impl ChargerServiceProxy {
2081    pub fn connect_to_device(&self) -> Result<ChargerProxy, fidl::Error> {
2082        let (proxy, server_end) = fidl::endpoints::create_proxy::<ChargerMarker>();
2083        self.connect_channel_to_device(server_end)?;
2084        Ok(proxy)
2085    }
2086
2087    /// Like `connect_to_device`, but returns a sync proxy.
2088    /// See [`Self::connect_to_device`] for more details.
2089    pub fn connect_to_device_sync(&self) -> Result<ChargerSynchronousProxy, fidl::Error> {
2090        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ChargerMarker>();
2091        self.connect_channel_to_device(server_end)?;
2092        Ok(proxy)
2093    }
2094
2095    /// Like `connect_to_device`, but accepts a server end.
2096    /// See [`Self::connect_to_device`] for more details.
2097    pub fn connect_channel_to_device(
2098        &self,
2099        server_end: fidl::endpoints::ServerEnd<ChargerMarker>,
2100    ) -> Result<(), fidl::Error> {
2101        self.0.open_member("device", server_end.into_channel())
2102    }
2103
2104    pub fn instance_name(&self) -> &str {
2105        self.0.instance_name()
2106    }
2107}
2108
2109#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2110pub struct InfoServiceMarker;
2111
2112#[cfg(target_os = "fuchsia")]
2113impl fidl::endpoints::ServiceMarker for InfoServiceMarker {
2114    type Proxy = InfoServiceProxy;
2115    type Request = InfoServiceRequest;
2116    const SERVICE_NAME: &'static str = "fuchsia.power.battery.InfoService";
2117}
2118
2119/// A request for one of the member protocols of InfoService.
2120///
2121#[cfg(target_os = "fuchsia")]
2122pub enum InfoServiceRequest {
2123    Device(BatteryInfoProviderRequestStream),
2124}
2125
2126#[cfg(target_os = "fuchsia")]
2127impl fidl::endpoints::ServiceRequest for InfoServiceRequest {
2128    type Service = InfoServiceMarker;
2129
2130    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2131        match name {
2132            "device" => Self::Device(
2133                <BatteryInfoProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
2134                    _channel,
2135                ),
2136            ),
2137            _ => panic!("no such member protocol name for service InfoService"),
2138        }
2139    }
2140
2141    fn member_names() -> &'static [&'static str] {
2142        &["device"]
2143    }
2144}
2145#[cfg(target_os = "fuchsia")]
2146pub struct InfoServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2147
2148#[cfg(target_os = "fuchsia")]
2149impl fidl::endpoints::ServiceProxy for InfoServiceProxy {
2150    type Service = InfoServiceMarker;
2151
2152    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2153        Self(opener)
2154    }
2155}
2156
2157#[cfg(target_os = "fuchsia")]
2158impl InfoServiceProxy {
2159    pub fn connect_to_device(&self) -> Result<BatteryInfoProviderProxy, fidl::Error> {
2160        let (proxy, server_end) = fidl::endpoints::create_proxy::<BatteryInfoProviderMarker>();
2161        self.connect_channel_to_device(server_end)?;
2162        Ok(proxy)
2163    }
2164
2165    /// Like `connect_to_device`, but returns a sync proxy.
2166    /// See [`Self::connect_to_device`] for more details.
2167    pub fn connect_to_device_sync(
2168        &self,
2169    ) -> Result<BatteryInfoProviderSynchronousProxy, fidl::Error> {
2170        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<BatteryInfoProviderMarker>();
2171        self.connect_channel_to_device(server_end)?;
2172        Ok(proxy)
2173    }
2174
2175    /// Like `connect_to_device`, but accepts a server end.
2176    /// See [`Self::connect_to_device`] for more details.
2177    pub fn connect_channel_to_device(
2178        &self,
2179        server_end: fidl::endpoints::ServerEnd<BatteryInfoProviderMarker>,
2180    ) -> Result<(), fidl::Error> {
2181        self.0.open_member("device", server_end.into_channel())
2182    }
2183
2184    pub fn instance_name(&self) -> &str {
2185        self.0.instance_name()
2186    }
2187}
2188
2189mod internal {
2190    use super::*;
2191
2192    impl fidl::encoding::ResourceTypeMarker for BatteryInfoProviderWatchRequest {
2193        type Borrowed<'a> = &'a mut Self;
2194        fn take_or_borrow<'a>(
2195            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2196        ) -> Self::Borrowed<'a> {
2197            value
2198        }
2199    }
2200
2201    unsafe impl fidl::encoding::TypeMarker for BatteryInfoProviderWatchRequest {
2202        type Owned = Self;
2203
2204        #[inline(always)]
2205        fn inline_align(_context: fidl::encoding::Context) -> usize {
2206            4
2207        }
2208
2209        #[inline(always)]
2210        fn inline_size(_context: fidl::encoding::Context) -> usize {
2211            4
2212        }
2213    }
2214
2215    unsafe impl
2216        fidl::encoding::Encode<
2217            BatteryInfoProviderWatchRequest,
2218            fidl::encoding::DefaultFuchsiaResourceDialect,
2219        > for &mut BatteryInfoProviderWatchRequest
2220    {
2221        #[inline]
2222        unsafe fn encode(
2223            self,
2224            encoder: &mut fidl::encoding::Encoder<
2225                '_,
2226                fidl::encoding::DefaultFuchsiaResourceDialect,
2227            >,
2228            offset: usize,
2229            _depth: fidl::encoding::Depth,
2230        ) -> fidl::Result<()> {
2231            encoder.debug_check_bounds::<BatteryInfoProviderWatchRequest>(offset);
2232            // Delegate to tuple encoding.
2233            fidl::encoding::Encode::<BatteryInfoProviderWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2234                (
2235                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
2236                ),
2237                encoder, offset, _depth
2238            )
2239        }
2240    }
2241    unsafe impl<
2242        T0: fidl::encoding::Encode<
2243                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
2244                fidl::encoding::DefaultFuchsiaResourceDialect,
2245            >,
2246    >
2247        fidl::encoding::Encode<
2248            BatteryInfoProviderWatchRequest,
2249            fidl::encoding::DefaultFuchsiaResourceDialect,
2250        > for (T0,)
2251    {
2252        #[inline]
2253        unsafe fn encode(
2254            self,
2255            encoder: &mut fidl::encoding::Encoder<
2256                '_,
2257                fidl::encoding::DefaultFuchsiaResourceDialect,
2258            >,
2259            offset: usize,
2260            depth: fidl::encoding::Depth,
2261        ) -> fidl::Result<()> {
2262            encoder.debug_check_bounds::<BatteryInfoProviderWatchRequest>(offset);
2263            // Zero out padding regions. There's no need to apply masks
2264            // because the unmasked parts will be overwritten by fields.
2265            // Write the fields.
2266            self.0.encode(encoder, offset + 0, depth)?;
2267            Ok(())
2268        }
2269    }
2270
2271    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2272        for BatteryInfoProviderWatchRequest
2273    {
2274        #[inline(always)]
2275        fn new_empty() -> Self {
2276            Self {
2277                watcher: fidl::new_empty!(
2278                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
2279                    fidl::encoding::DefaultFuchsiaResourceDialect
2280                ),
2281            }
2282        }
2283
2284        #[inline]
2285        unsafe fn decode(
2286            &mut self,
2287            decoder: &mut fidl::encoding::Decoder<
2288                '_,
2289                fidl::encoding::DefaultFuchsiaResourceDialect,
2290            >,
2291            offset: usize,
2292            _depth: fidl::encoding::Depth,
2293        ) -> fidl::Result<()> {
2294            decoder.debug_check_bounds::<Self>(offset);
2295            // Verify that padding bytes are zero.
2296            fidl::decode!(
2297                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
2298                fidl::encoding::DefaultFuchsiaResourceDialect,
2299                &mut self.watcher,
2300                decoder,
2301                offset + 0,
2302                _depth
2303            )?;
2304            Ok(())
2305        }
2306    }
2307
2308    impl fidl::encoding::ResourceTypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
2309        type Borrowed<'a> = &'a mut Self;
2310        fn take_or_borrow<'a>(
2311            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2312        ) -> Self::Borrowed<'a> {
2313            value
2314        }
2315    }
2316
2317    unsafe impl fidl::encoding::TypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
2318        type Owned = Self;
2319
2320        #[inline(always)]
2321        fn inline_align(_context: fidl::encoding::Context) -> usize {
2322            8
2323        }
2324
2325        #[inline(always)]
2326        fn inline_size(_context: fidl::encoding::Context) -> usize {
2327            24
2328        }
2329    }
2330
2331    unsafe impl
2332        fidl::encoding::Encode<
2333            BatteryInfoWatcherOnChangeBatteryInfoRequest,
2334            fidl::encoding::DefaultFuchsiaResourceDialect,
2335        > for &mut BatteryInfoWatcherOnChangeBatteryInfoRequest
2336    {
2337        #[inline]
2338        unsafe fn encode(
2339            self,
2340            encoder: &mut fidl::encoding::Encoder<
2341                '_,
2342                fidl::encoding::DefaultFuchsiaResourceDialect,
2343            >,
2344            offset: usize,
2345            _depth: fidl::encoding::Depth,
2346        ) -> fidl::Result<()> {
2347            encoder.debug_check_bounds::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
2348            // Delegate to tuple encoding.
2349            fidl::encoding::Encode::<
2350                BatteryInfoWatcherOnChangeBatteryInfoRequest,
2351                fidl::encoding::DefaultFuchsiaResourceDialect,
2352            >::encode(
2353                (
2354                    <BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
2355                    <fidl::encoding::Optional<
2356                        fidl::encoding::HandleType<
2357                            fidl::EventPair,
2358                            { fidl::ObjectType::EVENTPAIR.into_raw() },
2359                            16387,
2360                        >,
2361                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2362                        &mut self.wake_lease
2363                    ),
2364                ),
2365                encoder,
2366                offset,
2367                _depth,
2368            )
2369        }
2370    }
2371    unsafe impl<
2372        T0: fidl::encoding::Encode<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
2373        T1: fidl::encoding::Encode<
2374                fidl::encoding::Optional<
2375                    fidl::encoding::HandleType<
2376                        fidl::EventPair,
2377                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2378                        16387,
2379                    >,
2380                >,
2381                fidl::encoding::DefaultFuchsiaResourceDialect,
2382            >,
2383    >
2384        fidl::encoding::Encode<
2385            BatteryInfoWatcherOnChangeBatteryInfoRequest,
2386            fidl::encoding::DefaultFuchsiaResourceDialect,
2387        > for (T0, T1)
2388    {
2389        #[inline]
2390        unsafe fn encode(
2391            self,
2392            encoder: &mut fidl::encoding::Encoder<
2393                '_,
2394                fidl::encoding::DefaultFuchsiaResourceDialect,
2395            >,
2396            offset: usize,
2397            depth: fidl::encoding::Depth,
2398        ) -> fidl::Result<()> {
2399            encoder.debug_check_bounds::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
2400            // Zero out padding regions. There's no need to apply masks
2401            // because the unmasked parts will be overwritten by fields.
2402            unsafe {
2403                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2404                (ptr as *mut u64).write_unaligned(0);
2405            }
2406            // Write the fields.
2407            self.0.encode(encoder, offset + 0, depth)?;
2408            self.1.encode(encoder, offset + 16, depth)?;
2409            Ok(())
2410        }
2411    }
2412
2413    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2414        for BatteryInfoWatcherOnChangeBatteryInfoRequest
2415    {
2416        #[inline(always)]
2417        fn new_empty() -> Self {
2418            Self {
2419                info: fidl::new_empty!(BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect),
2420                wake_lease: fidl::new_empty!(
2421                    fidl::encoding::Optional<
2422                        fidl::encoding::HandleType<
2423                            fidl::EventPair,
2424                            { fidl::ObjectType::EVENTPAIR.into_raw() },
2425                            16387,
2426                        >,
2427                    >,
2428                    fidl::encoding::DefaultFuchsiaResourceDialect
2429                ),
2430            }
2431        }
2432
2433        #[inline]
2434        unsafe fn decode(
2435            &mut self,
2436            decoder: &mut fidl::encoding::Decoder<
2437                '_,
2438                fidl::encoding::DefaultFuchsiaResourceDialect,
2439            >,
2440            offset: usize,
2441            _depth: fidl::encoding::Depth,
2442        ) -> fidl::Result<()> {
2443            decoder.debug_check_bounds::<Self>(offset);
2444            // Verify that padding bytes are zero.
2445            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2446            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2447            let mask = 0xffffffff00000000u64;
2448            let maskedval = padval & mask;
2449            if maskedval != 0 {
2450                return Err(fidl::Error::NonZeroPadding {
2451                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2452                });
2453            }
2454            fidl::decode!(
2455                BatteryInfo,
2456                fidl::encoding::DefaultFuchsiaResourceDialect,
2457                &mut self.info,
2458                decoder,
2459                offset + 0,
2460                _depth
2461            )?;
2462            fidl::decode!(
2463                fidl::encoding::Optional<
2464                    fidl::encoding::HandleType<
2465                        fidl::EventPair,
2466                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2467                        16387,
2468                    >,
2469                >,
2470                fidl::encoding::DefaultFuchsiaResourceDialect,
2471                &mut self.wake_lease,
2472                decoder,
2473                offset + 16,
2474                _depth
2475            )?;
2476            Ok(())
2477        }
2478    }
2479}