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