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