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_hardware_power_charger_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ChargerWatchRequest {
16 pub lease: Option<fidl::EventPair>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ChargerWatchRequest {}
20
21#[derive(Debug, PartialEq)]
22pub struct ChargerWatchResponse {
23 pub status: Status,
24 pub wake_lease: Option<fidl::EventPair>,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ChargerWatchResponse {}
28
29#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
30pub struct ChargerMarker;
31
32impl fidl::endpoints::ProtocolMarker for ChargerMarker {
33 type Proxy = ChargerProxy;
34 type RequestStream = ChargerRequestStream;
35 #[cfg(target_os = "fuchsia")]
36 type SynchronousProxy = ChargerSynchronousProxy;
37
38 const DEBUG_NAME: &'static str = "fuchsia.hardware.power.charger.Charger";
39}
40impl fidl::endpoints::DiscoverableProtocolMarker for ChargerMarker {}
41pub type ChargerGetSpecResult = Result<Spec, Error>;
42pub type ChargerGetStatusResult = Result<Status, Error>;
43pub type ChargerConfigureWatchResult = Result<WatchOptions, Error>;
44pub type ChargerWatchResult = Result<(Status, Option<fidl::EventPair>), Error>;
45
46pub trait ChargerProxyInterface: Send + Sync {
47 type GetSpecResponseFut: std::future::Future<Output = Result<ChargerGetSpecResult, fidl::Error>>
48 + Send;
49 fn r#get_spec(&self) -> Self::GetSpecResponseFut;
50 type GetStatusResponseFut: std::future::Future<Output = Result<ChargerGetStatusResult, fidl::Error>>
51 + Send;
52 fn r#get_status(&self) -> Self::GetStatusResponseFut;
53 type ConfigureWatchResponseFut: std::future::Future<Output = Result<ChargerConfigureWatchResult, fidl::Error>>
54 + Send;
55 fn r#configure_watch(&self, options: &WatchOptions) -> Self::ConfigureWatchResponseFut;
56 type WatchResponseFut: std::future::Future<Output = Result<ChargerWatchResult, fidl::Error>>
57 + Send;
58 fn r#watch(&self, lease: Option<fidl::EventPair>) -> Self::WatchResponseFut;
59}
60#[derive(Debug)]
61#[cfg(target_os = "fuchsia")]
62pub struct ChargerSynchronousProxy {
63 client: fidl::client::sync::Client,
64}
65
66#[cfg(target_os = "fuchsia")]
67impl fidl::endpoints::SynchronousProxy for ChargerSynchronousProxy {
68 type Proxy = ChargerProxy;
69 type Protocol = ChargerMarker;
70
71 fn from_channel(inner: fidl::Channel) -> Self {
72 Self::new(inner)
73 }
74
75 fn into_channel(self) -> fidl::Channel {
76 self.client.into_channel()
77 }
78
79 fn as_channel(&self) -> &fidl::Channel {
80 self.client.as_channel()
81 }
82}
83
84#[cfg(target_os = "fuchsia")]
85impl ChargerSynchronousProxy {
86 pub fn new(channel: fidl::Channel) -> Self {
87 Self { client: fidl::client::sync::Client::new(channel) }
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<ChargerEvent, fidl::Error> {
100 ChargerEvent::decode(self.client.wait_for_event::<ChargerMarker>(deadline)?)
101 }
102
103 pub fn r#get_spec(
113 &self,
114 ___deadline: zx::MonotonicInstant,
115 ) -> Result<ChargerGetSpecResult, fidl::Error> {
116 let _response = self.client.send_query::<
117 fidl::encoding::EmptyPayload,
118 fidl::encoding::FlexibleResultType<ChargerGetSpecResponse, Error>,
119 ChargerMarker,
120 >(
121 (),
122 0x4f1a5fc6df415db3,
123 fidl::encoding::DynamicFlags::FLEXIBLE,
124 ___deadline,
125 )?
126 .into_result::<ChargerMarker>("get_spec")?;
127 Ok(_response.map(|x| x.spec))
128 }
129
130 pub fn r#get_status(
139 &self,
140 ___deadline: zx::MonotonicInstant,
141 ) -> Result<ChargerGetStatusResult, fidl::Error> {
142 let _response = self.client.send_query::<
143 fidl::encoding::EmptyPayload,
144 fidl::encoding::FlexibleResultType<ChargerGetStatusResponse, Error>,
145 ChargerMarker,
146 >(
147 (),
148 0x3c67651b7ec14d5e,
149 fidl::encoding::DynamicFlags::FLEXIBLE,
150 ___deadline,
151 )?
152 .into_result::<ChargerMarker>("get_status")?;
153 Ok(_response.map(|x| x.status))
154 }
155
156 pub fn r#configure_watch(
190 &self,
191 mut options: &WatchOptions,
192 ___deadline: zx::MonotonicInstant,
193 ) -> Result<ChargerConfigureWatchResult, fidl::Error> {
194 let _response = self.client.send_query::<
195 ChargerConfigureWatchRequest,
196 fidl::encoding::FlexibleResultType<ChargerConfigureWatchResponse, Error>,
197 ChargerMarker,
198 >(
199 (options,),
200 0x739a314e3494d695,
201 fidl::encoding::DynamicFlags::FLEXIBLE,
202 ___deadline,
203 )?
204 .into_result::<ChargerMarker>("configure_watch")?;
205 Ok(_response.map(|x| x.effective_options))
206 }
207
208 pub fn r#watch(
236 &self,
237 mut lease: Option<fidl::EventPair>,
238 ___deadline: zx::MonotonicInstant,
239 ) -> Result<ChargerWatchResult, fidl::Error> {
240 let _response = self.client.send_query::<
241 ChargerWatchRequest,
242 fidl::encoding::FlexibleResultType<ChargerWatchResponse, Error>,
243 ChargerMarker,
244 >(
245 (lease,),
246 0x5a52d95d33d7c66e,
247 fidl::encoding::DynamicFlags::FLEXIBLE,
248 ___deadline,
249 )?
250 .into_result::<ChargerMarker>("watch")?;
251 Ok(_response.map(|x| (x.status, x.wake_lease)))
252 }
253}
254
255#[cfg(target_os = "fuchsia")]
256impl From<ChargerSynchronousProxy> for zx::NullableHandle {
257 fn from(value: ChargerSynchronousProxy) -> Self {
258 value.into_channel().into()
259 }
260}
261
262#[cfg(target_os = "fuchsia")]
263impl From<fidl::Channel> for ChargerSynchronousProxy {
264 fn from(value: fidl::Channel) -> Self {
265 Self::new(value)
266 }
267}
268
269#[cfg(target_os = "fuchsia")]
270impl fidl::endpoints::FromClient for ChargerSynchronousProxy {
271 type Protocol = ChargerMarker;
272
273 fn from_client(value: fidl::endpoints::ClientEnd<ChargerMarker>) -> Self {
274 Self::new(value.into_channel())
275 }
276}
277
278#[derive(Debug, Clone)]
279pub struct ChargerProxy {
280 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
281}
282
283impl fidl::endpoints::Proxy for ChargerProxy {
284 type Protocol = ChargerMarker;
285
286 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
287 Self::new(inner)
288 }
289
290 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
291 self.client.into_channel().map_err(|client| Self { client })
292 }
293
294 fn as_channel(&self) -> &::fidl::AsyncChannel {
295 self.client.as_channel()
296 }
297}
298
299impl ChargerProxy {
300 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
302 let protocol_name = <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
303 Self { client: fidl::client::Client::new(channel, protocol_name) }
304 }
305
306 pub fn take_event_stream(&self) -> ChargerEventStream {
312 ChargerEventStream { event_receiver: self.client.take_event_receiver() }
313 }
314
315 pub fn r#get_spec(
325 &self,
326 ) -> fidl::client::QueryResponseFut<
327 ChargerGetSpecResult,
328 fidl::encoding::DefaultFuchsiaResourceDialect,
329 > {
330 ChargerProxyInterface::r#get_spec(self)
331 }
332
333 pub fn r#get_status(
342 &self,
343 ) -> fidl::client::QueryResponseFut<
344 ChargerGetStatusResult,
345 fidl::encoding::DefaultFuchsiaResourceDialect,
346 > {
347 ChargerProxyInterface::r#get_status(self)
348 }
349
350 pub fn r#configure_watch(
384 &self,
385 mut options: &WatchOptions,
386 ) -> fidl::client::QueryResponseFut<
387 ChargerConfigureWatchResult,
388 fidl::encoding::DefaultFuchsiaResourceDialect,
389 > {
390 ChargerProxyInterface::r#configure_watch(self, options)
391 }
392
393 pub fn r#watch(
421 &self,
422 mut lease: Option<fidl::EventPair>,
423 ) -> fidl::client::QueryResponseFut<
424 ChargerWatchResult,
425 fidl::encoding::DefaultFuchsiaResourceDialect,
426 > {
427 ChargerProxyInterface::r#watch(self, lease)
428 }
429}
430
431impl ChargerProxyInterface for ChargerProxy {
432 type GetSpecResponseFut = fidl::client::QueryResponseFut<
433 ChargerGetSpecResult,
434 fidl::encoding::DefaultFuchsiaResourceDialect,
435 >;
436 fn r#get_spec(&self) -> Self::GetSpecResponseFut {
437 fn _decode(
438 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
439 ) -> Result<ChargerGetSpecResult, fidl::Error> {
440 let _response = fidl::client::decode_transaction_body::<
441 fidl::encoding::FlexibleResultType<ChargerGetSpecResponse, Error>,
442 fidl::encoding::DefaultFuchsiaResourceDialect,
443 0x4f1a5fc6df415db3,
444 >(_buf?)?
445 .into_result::<ChargerMarker>("get_spec")?;
446 Ok(_response.map(|x| x.spec))
447 }
448 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChargerGetSpecResult>(
449 (),
450 0x4f1a5fc6df415db3,
451 fidl::encoding::DynamicFlags::FLEXIBLE,
452 _decode,
453 )
454 }
455
456 type GetStatusResponseFut = fidl::client::QueryResponseFut<
457 ChargerGetStatusResult,
458 fidl::encoding::DefaultFuchsiaResourceDialect,
459 >;
460 fn r#get_status(&self) -> Self::GetStatusResponseFut {
461 fn _decode(
462 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
463 ) -> Result<ChargerGetStatusResult, fidl::Error> {
464 let _response = fidl::client::decode_transaction_body::<
465 fidl::encoding::FlexibleResultType<ChargerGetStatusResponse, Error>,
466 fidl::encoding::DefaultFuchsiaResourceDialect,
467 0x3c67651b7ec14d5e,
468 >(_buf?)?
469 .into_result::<ChargerMarker>("get_status")?;
470 Ok(_response.map(|x| x.status))
471 }
472 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChargerGetStatusResult>(
473 (),
474 0x3c67651b7ec14d5e,
475 fidl::encoding::DynamicFlags::FLEXIBLE,
476 _decode,
477 )
478 }
479
480 type ConfigureWatchResponseFut = fidl::client::QueryResponseFut<
481 ChargerConfigureWatchResult,
482 fidl::encoding::DefaultFuchsiaResourceDialect,
483 >;
484 fn r#configure_watch(&self, mut options: &WatchOptions) -> Self::ConfigureWatchResponseFut {
485 fn _decode(
486 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
487 ) -> Result<ChargerConfigureWatchResult, fidl::Error> {
488 let _response = fidl::client::decode_transaction_body::<
489 fidl::encoding::FlexibleResultType<ChargerConfigureWatchResponse, Error>,
490 fidl::encoding::DefaultFuchsiaResourceDialect,
491 0x739a314e3494d695,
492 >(_buf?)?
493 .into_result::<ChargerMarker>("configure_watch")?;
494 Ok(_response.map(|x| x.effective_options))
495 }
496 self.client
497 .send_query_and_decode::<ChargerConfigureWatchRequest, ChargerConfigureWatchResult>(
498 (options,),
499 0x739a314e3494d695,
500 fidl::encoding::DynamicFlags::FLEXIBLE,
501 _decode,
502 )
503 }
504
505 type WatchResponseFut = fidl::client::QueryResponseFut<
506 ChargerWatchResult,
507 fidl::encoding::DefaultFuchsiaResourceDialect,
508 >;
509 fn r#watch(&self, mut lease: Option<fidl::EventPair>) -> Self::WatchResponseFut {
510 fn _decode(
511 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
512 ) -> Result<ChargerWatchResult, fidl::Error> {
513 let _response = fidl::client::decode_transaction_body::<
514 fidl::encoding::FlexibleResultType<ChargerWatchResponse, Error>,
515 fidl::encoding::DefaultFuchsiaResourceDialect,
516 0x5a52d95d33d7c66e,
517 >(_buf?)?
518 .into_result::<ChargerMarker>("watch")?;
519 Ok(_response.map(|x| (x.status, x.wake_lease)))
520 }
521 self.client.send_query_and_decode::<ChargerWatchRequest, ChargerWatchResult>(
522 (lease,),
523 0x5a52d95d33d7c66e,
524 fidl::encoding::DynamicFlags::FLEXIBLE,
525 _decode,
526 )
527 }
528}
529
530pub struct ChargerEventStream {
531 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
532}
533
534impl std::marker::Unpin for ChargerEventStream {}
535
536impl futures::stream::FusedStream for ChargerEventStream {
537 fn is_terminated(&self) -> bool {
538 self.event_receiver.is_terminated()
539 }
540}
541
542impl futures::Stream for ChargerEventStream {
543 type Item = Result<ChargerEvent, fidl::Error>;
544
545 fn poll_next(
546 mut self: std::pin::Pin<&mut Self>,
547 cx: &mut std::task::Context<'_>,
548 ) -> std::task::Poll<Option<Self::Item>> {
549 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
550 &mut self.event_receiver,
551 cx
552 )?) {
553 Some(buf) => std::task::Poll::Ready(Some(ChargerEvent::decode(buf))),
554 None => std::task::Poll::Ready(None),
555 }
556 }
557}
558
559#[derive(Debug)]
560pub enum ChargerEvent {
561 #[non_exhaustive]
562 _UnknownEvent {
563 ordinal: u64,
565 },
566}
567
568impl ChargerEvent {
569 fn decode(
571 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
572 ) -> Result<ChargerEvent, fidl::Error> {
573 let (bytes, _handles) = buf.split_mut();
574 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
575 debug_assert_eq!(tx_header.tx_id, 0);
576 match tx_header.ordinal {
577 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
578 Ok(ChargerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
579 }
580 _ => Err(fidl::Error::UnknownOrdinal {
581 ordinal: tx_header.ordinal,
582 protocol_name: <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
583 }),
584 }
585 }
586}
587
588pub struct ChargerRequestStream {
590 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
591 is_terminated: bool,
592}
593
594impl std::marker::Unpin for ChargerRequestStream {}
595
596impl futures::stream::FusedStream for ChargerRequestStream {
597 fn is_terminated(&self) -> bool {
598 self.is_terminated
599 }
600}
601
602impl fidl::endpoints::RequestStream for ChargerRequestStream {
603 type Protocol = ChargerMarker;
604 type ControlHandle = ChargerControlHandle;
605
606 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
607 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
608 }
609
610 fn control_handle(&self) -> Self::ControlHandle {
611 ChargerControlHandle { inner: self.inner.clone() }
612 }
613
614 fn into_inner(
615 self,
616 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
617 {
618 (self.inner, self.is_terminated)
619 }
620
621 fn from_inner(
622 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
623 is_terminated: bool,
624 ) -> Self {
625 Self { inner, is_terminated }
626 }
627}
628
629impl futures::Stream for ChargerRequestStream {
630 type Item = Result<ChargerRequest, fidl::Error>;
631
632 fn poll_next(
633 mut self: std::pin::Pin<&mut Self>,
634 cx: &mut std::task::Context<'_>,
635 ) -> std::task::Poll<Option<Self::Item>> {
636 let this = &mut *self;
637 if this.inner.check_shutdown(cx) {
638 this.is_terminated = true;
639 return std::task::Poll::Ready(None);
640 }
641 if this.is_terminated {
642 panic!("polled ChargerRequestStream after completion");
643 }
644 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
645 |bytes, handles| {
646 match this.inner.channel().read_etc(cx, bytes, handles) {
647 std::task::Poll::Ready(Ok(())) => {}
648 std::task::Poll::Pending => return std::task::Poll::Pending,
649 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
650 this.is_terminated = true;
651 return std::task::Poll::Ready(None);
652 }
653 std::task::Poll::Ready(Err(e)) => {
654 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
655 e.into(),
656 ))));
657 }
658 }
659
660 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
662
663 std::task::Poll::Ready(Some(match header.ordinal {
664 0x4f1a5fc6df415db3 => {
665 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
666 let mut req = fidl::new_empty!(
667 fidl::encoding::EmptyPayload,
668 fidl::encoding::DefaultFuchsiaResourceDialect
669 );
670 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
671 let control_handle = ChargerControlHandle { inner: this.inner.clone() };
672 Ok(ChargerRequest::GetSpec {
673 responder: ChargerGetSpecResponder {
674 control_handle: std::mem::ManuallyDrop::new(control_handle),
675 tx_id: header.tx_id,
676 },
677 })
678 }
679 0x3c67651b7ec14d5e => {
680 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
681 let mut req = fidl::new_empty!(
682 fidl::encoding::EmptyPayload,
683 fidl::encoding::DefaultFuchsiaResourceDialect
684 );
685 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
686 let control_handle = ChargerControlHandle { inner: this.inner.clone() };
687 Ok(ChargerRequest::GetStatus {
688 responder: ChargerGetStatusResponder {
689 control_handle: std::mem::ManuallyDrop::new(control_handle),
690 tx_id: header.tx_id,
691 },
692 })
693 }
694 0x739a314e3494d695 => {
695 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
696 let mut req = fidl::new_empty!(
697 ChargerConfigureWatchRequest,
698 fidl::encoding::DefaultFuchsiaResourceDialect
699 );
700 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChargerConfigureWatchRequest>(&header, _body_bytes, handles, &mut req)?;
701 let control_handle = ChargerControlHandle { inner: this.inner.clone() };
702 Ok(ChargerRequest::ConfigureWatch {
703 options: req.options,
704
705 responder: ChargerConfigureWatchResponder {
706 control_handle: std::mem::ManuallyDrop::new(control_handle),
707 tx_id: header.tx_id,
708 },
709 })
710 }
711 0x5a52d95d33d7c66e => {
712 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
713 let mut req = fidl::new_empty!(
714 ChargerWatchRequest,
715 fidl::encoding::DefaultFuchsiaResourceDialect
716 );
717 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ChargerWatchRequest>(&header, _body_bytes, handles, &mut req)?;
718 let control_handle = ChargerControlHandle { inner: this.inner.clone() };
719 Ok(ChargerRequest::Watch {
720 lease: req.lease,
721
722 responder: ChargerWatchResponder {
723 control_handle: std::mem::ManuallyDrop::new(control_handle),
724 tx_id: header.tx_id,
725 },
726 })
727 }
728 _ if header.tx_id == 0
729 && header
730 .dynamic_flags()
731 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
732 {
733 Ok(ChargerRequest::_UnknownMethod {
734 ordinal: header.ordinal,
735 control_handle: ChargerControlHandle { inner: this.inner.clone() },
736 method_type: fidl::MethodType::OneWay,
737 })
738 }
739 _ if header
740 .dynamic_flags()
741 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
742 {
743 this.inner.send_framework_err(
744 fidl::encoding::FrameworkErr::UnknownMethod,
745 header.tx_id,
746 header.ordinal,
747 header.dynamic_flags(),
748 (bytes, handles),
749 )?;
750 Ok(ChargerRequest::_UnknownMethod {
751 ordinal: header.ordinal,
752 control_handle: ChargerControlHandle { inner: this.inner.clone() },
753 method_type: fidl::MethodType::TwoWay,
754 })
755 }
756 _ => Err(fidl::Error::UnknownOrdinal {
757 ordinal: header.ordinal,
758 protocol_name:
759 <ChargerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
760 }),
761 }))
762 },
763 )
764 }
765}
766
767#[derive(Debug)]
771pub enum ChargerRequest {
772 GetSpec { responder: ChargerGetSpecResponder },
782 GetStatus { responder: ChargerGetStatusResponder },
791 ConfigureWatch { options: WatchOptions, responder: ChargerConfigureWatchResponder },
825 Watch { lease: Option<fidl::EventPair>, responder: ChargerWatchResponder },
853 #[non_exhaustive]
855 _UnknownMethod {
856 ordinal: u64,
858 control_handle: ChargerControlHandle,
859 method_type: fidl::MethodType,
860 },
861}
862
863impl ChargerRequest {
864 #[allow(irrefutable_let_patterns)]
865 pub fn into_get_spec(self) -> Option<(ChargerGetSpecResponder)> {
866 if let ChargerRequest::GetSpec { responder } = self { Some((responder)) } else { None }
867 }
868
869 #[allow(irrefutable_let_patterns)]
870 pub fn into_get_status(self) -> Option<(ChargerGetStatusResponder)> {
871 if let ChargerRequest::GetStatus { responder } = self { Some((responder)) } else { None }
872 }
873
874 #[allow(irrefutable_let_patterns)]
875 pub fn into_configure_watch(self) -> Option<(WatchOptions, ChargerConfigureWatchResponder)> {
876 if let ChargerRequest::ConfigureWatch { options, responder } = self {
877 Some((options, responder))
878 } else {
879 None
880 }
881 }
882
883 #[allow(irrefutable_let_patterns)]
884 pub fn into_watch(self) -> Option<(Option<fidl::EventPair>, ChargerWatchResponder)> {
885 if let ChargerRequest::Watch { lease, responder } = self {
886 Some((lease, responder))
887 } else {
888 None
889 }
890 }
891
892 pub fn method_name(&self) -> &'static str {
894 match *self {
895 ChargerRequest::GetSpec { .. } => "get_spec",
896 ChargerRequest::GetStatus { .. } => "get_status",
897 ChargerRequest::ConfigureWatch { .. } => "configure_watch",
898 ChargerRequest::Watch { .. } => "watch",
899 ChargerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
900 "unknown one-way method"
901 }
902 ChargerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
903 "unknown two-way method"
904 }
905 }
906 }
907}
908
909#[derive(Debug, Clone)]
910pub struct ChargerControlHandle {
911 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
912}
913
914impl ChargerControlHandle {
915 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
916 self.inner.shutdown_with_epitaph(status.into())
917 }
918}
919
920impl fidl::endpoints::ControlHandle for ChargerControlHandle {
921 fn shutdown(&self) {
922 self.inner.shutdown()
923 }
924
925 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
926 self.inner.shutdown_with_epitaph(status)
927 }
928
929 fn is_closed(&self) -> bool {
930 self.inner.channel().is_closed()
931 }
932 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
933 self.inner.channel().on_closed()
934 }
935
936 #[cfg(target_os = "fuchsia")]
937 fn signal_peer(
938 &self,
939 clear_mask: zx::Signals,
940 set_mask: zx::Signals,
941 ) -> Result<(), zx_status::Status> {
942 use fidl::Peered;
943 self.inner.channel().signal_peer(clear_mask, set_mask)
944 }
945}
946
947impl ChargerControlHandle {}
948
949#[must_use = "FIDL methods require a response to be sent"]
950#[derive(Debug)]
951pub struct ChargerGetSpecResponder {
952 control_handle: std::mem::ManuallyDrop<ChargerControlHandle>,
953 tx_id: u32,
954}
955
956impl std::ops::Drop for ChargerGetSpecResponder {
960 fn drop(&mut self) {
961 self.control_handle.shutdown();
962 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
964 }
965}
966
967impl fidl::endpoints::Responder for ChargerGetSpecResponder {
968 type ControlHandle = ChargerControlHandle;
969
970 fn control_handle(&self) -> &ChargerControlHandle {
971 &self.control_handle
972 }
973
974 fn drop_without_shutdown(mut self) {
975 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
977 std::mem::forget(self);
979 }
980}
981
982impl ChargerGetSpecResponder {
983 pub fn send(self, mut result: Result<&Spec, Error>) -> Result<(), fidl::Error> {
987 let _result = self.send_raw(result);
988 if _result.is_err() {
989 self.control_handle.shutdown();
990 }
991 self.drop_without_shutdown();
992 _result
993 }
994
995 pub fn send_no_shutdown_on_err(
997 self,
998 mut result: Result<&Spec, Error>,
999 ) -> Result<(), fidl::Error> {
1000 let _result = self.send_raw(result);
1001 self.drop_without_shutdown();
1002 _result
1003 }
1004
1005 fn send_raw(&self, mut result: Result<&Spec, Error>) -> Result<(), fidl::Error> {
1006 self.control_handle
1007 .inner
1008 .send::<fidl::encoding::FlexibleResultType<ChargerGetSpecResponse, Error>>(
1009 fidl::encoding::FlexibleResult::new(result.map(|spec| (spec,))),
1010 self.tx_id,
1011 0x4f1a5fc6df415db3,
1012 fidl::encoding::DynamicFlags::FLEXIBLE,
1013 )
1014 }
1015}
1016
1017#[must_use = "FIDL methods require a response to be sent"]
1018#[derive(Debug)]
1019pub struct ChargerGetStatusResponder {
1020 control_handle: std::mem::ManuallyDrop<ChargerControlHandle>,
1021 tx_id: u32,
1022}
1023
1024impl std::ops::Drop for ChargerGetStatusResponder {
1028 fn drop(&mut self) {
1029 self.control_handle.shutdown();
1030 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1032 }
1033}
1034
1035impl fidl::endpoints::Responder for ChargerGetStatusResponder {
1036 type ControlHandle = ChargerControlHandle;
1037
1038 fn control_handle(&self) -> &ChargerControlHandle {
1039 &self.control_handle
1040 }
1041
1042 fn drop_without_shutdown(mut self) {
1043 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1045 std::mem::forget(self);
1047 }
1048}
1049
1050impl ChargerGetStatusResponder {
1051 pub fn send(self, mut result: Result<&Status, Error>) -> Result<(), fidl::Error> {
1055 let _result = self.send_raw(result);
1056 if _result.is_err() {
1057 self.control_handle.shutdown();
1058 }
1059 self.drop_without_shutdown();
1060 _result
1061 }
1062
1063 pub fn send_no_shutdown_on_err(
1065 self,
1066 mut result: Result<&Status, Error>,
1067 ) -> Result<(), fidl::Error> {
1068 let _result = self.send_raw(result);
1069 self.drop_without_shutdown();
1070 _result
1071 }
1072
1073 fn send_raw(&self, mut result: Result<&Status, Error>) -> Result<(), fidl::Error> {
1074 self.control_handle
1075 .inner
1076 .send::<fidl::encoding::FlexibleResultType<ChargerGetStatusResponse, Error>>(
1077 fidl::encoding::FlexibleResult::new(result.map(|status| (status,))),
1078 self.tx_id,
1079 0x3c67651b7ec14d5e,
1080 fidl::encoding::DynamicFlags::FLEXIBLE,
1081 )
1082 }
1083}
1084
1085#[must_use = "FIDL methods require a response to be sent"]
1086#[derive(Debug)]
1087pub struct ChargerConfigureWatchResponder {
1088 control_handle: std::mem::ManuallyDrop<ChargerControlHandle>,
1089 tx_id: u32,
1090}
1091
1092impl std::ops::Drop for ChargerConfigureWatchResponder {
1096 fn drop(&mut self) {
1097 self.control_handle.shutdown();
1098 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1100 }
1101}
1102
1103impl fidl::endpoints::Responder for ChargerConfigureWatchResponder {
1104 type ControlHandle = ChargerControlHandle;
1105
1106 fn control_handle(&self) -> &ChargerControlHandle {
1107 &self.control_handle
1108 }
1109
1110 fn drop_without_shutdown(mut self) {
1111 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1113 std::mem::forget(self);
1115 }
1116}
1117
1118impl ChargerConfigureWatchResponder {
1119 pub fn send(self, mut result: Result<&WatchOptions, Error>) -> Result<(), fidl::Error> {
1123 let _result = self.send_raw(result);
1124 if _result.is_err() {
1125 self.control_handle.shutdown();
1126 }
1127 self.drop_without_shutdown();
1128 _result
1129 }
1130
1131 pub fn send_no_shutdown_on_err(
1133 self,
1134 mut result: Result<&WatchOptions, Error>,
1135 ) -> Result<(), fidl::Error> {
1136 let _result = self.send_raw(result);
1137 self.drop_without_shutdown();
1138 _result
1139 }
1140
1141 fn send_raw(&self, mut result: Result<&WatchOptions, Error>) -> Result<(), fidl::Error> {
1142 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1143 ChargerConfigureWatchResponse,
1144 Error,
1145 >>(
1146 fidl::encoding::FlexibleResult::new(
1147 result.map(|effective_options| (effective_options,)),
1148 ),
1149 self.tx_id,
1150 0x739a314e3494d695,
1151 fidl::encoding::DynamicFlags::FLEXIBLE,
1152 )
1153 }
1154}
1155
1156#[must_use = "FIDL methods require a response to be sent"]
1157#[derive(Debug)]
1158pub struct ChargerWatchResponder {
1159 control_handle: std::mem::ManuallyDrop<ChargerControlHandle>,
1160 tx_id: u32,
1161}
1162
1163impl std::ops::Drop for ChargerWatchResponder {
1167 fn drop(&mut self) {
1168 self.control_handle.shutdown();
1169 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1171 }
1172}
1173
1174impl fidl::endpoints::Responder for ChargerWatchResponder {
1175 type ControlHandle = ChargerControlHandle;
1176
1177 fn control_handle(&self) -> &ChargerControlHandle {
1178 &self.control_handle
1179 }
1180
1181 fn drop_without_shutdown(mut self) {
1182 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1184 std::mem::forget(self);
1186 }
1187}
1188
1189impl ChargerWatchResponder {
1190 pub fn send(
1194 self,
1195 mut result: Result<(&Status, Option<fidl::EventPair>), Error>,
1196 ) -> Result<(), fidl::Error> {
1197 let _result = self.send_raw(result);
1198 if _result.is_err() {
1199 self.control_handle.shutdown();
1200 }
1201 self.drop_without_shutdown();
1202 _result
1203 }
1204
1205 pub fn send_no_shutdown_on_err(
1207 self,
1208 mut result: Result<(&Status, Option<fidl::EventPair>), Error>,
1209 ) -> Result<(), fidl::Error> {
1210 let _result = self.send_raw(result);
1211 self.drop_without_shutdown();
1212 _result
1213 }
1214
1215 fn send_raw(
1216 &self,
1217 mut result: Result<(&Status, Option<fidl::EventPair>), Error>,
1218 ) -> Result<(), fidl::Error> {
1219 self.control_handle
1220 .inner
1221 .send::<fidl::encoding::FlexibleResultType<ChargerWatchResponse, Error>>(
1222 fidl::encoding::FlexibleResult::new(result),
1223 self.tx_id,
1224 0x5a52d95d33d7c66e,
1225 fidl::encoding::DynamicFlags::FLEXIBLE,
1226 )
1227 }
1228}
1229
1230#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1231pub struct ControllerMarker;
1232
1233impl fidl::endpoints::ProtocolMarker for ControllerMarker {
1234 type Proxy = ControllerProxy;
1235 type RequestStream = ControllerRequestStream;
1236 #[cfg(target_os = "fuchsia")]
1237 type SynchronousProxy = ControllerSynchronousProxy;
1238
1239 const DEBUG_NAME: &'static str = "fuchsia.hardware.power.charger.Controller";
1240}
1241impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
1242pub type ControllerSetControlResult = Result<(), Error>;
1243pub type ControllerClearControlResult = Result<(), Error>;
1244
1245pub trait ControllerProxyInterface: Send + Sync {
1246 type SetControlResponseFut: std::future::Future<Output = Result<ControllerSetControlResult, fidl::Error>>
1247 + Send;
1248 fn r#set_control(&self, options: &ControlOptions) -> Self::SetControlResponseFut;
1249 type ClearControlResponseFut: std::future::Future<Output = Result<ControllerClearControlResult, fidl::Error>>
1250 + Send;
1251 fn r#clear_control(&self, options: &ControlOptions) -> Self::ClearControlResponseFut;
1252}
1253#[derive(Debug)]
1254#[cfg(target_os = "fuchsia")]
1255pub struct ControllerSynchronousProxy {
1256 client: fidl::client::sync::Client,
1257}
1258
1259#[cfg(target_os = "fuchsia")]
1260impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
1261 type Proxy = ControllerProxy;
1262 type Protocol = ControllerMarker;
1263
1264 fn from_channel(inner: fidl::Channel) -> Self {
1265 Self::new(inner)
1266 }
1267
1268 fn into_channel(self) -> fidl::Channel {
1269 self.client.into_channel()
1270 }
1271
1272 fn as_channel(&self) -> &fidl::Channel {
1273 self.client.as_channel()
1274 }
1275}
1276
1277#[cfg(target_os = "fuchsia")]
1278impl ControllerSynchronousProxy {
1279 pub fn new(channel: fidl::Channel) -> Self {
1280 Self { client: fidl::client::sync::Client::new(channel) }
1281 }
1282
1283 pub fn into_channel(self) -> fidl::Channel {
1284 self.client.into_channel()
1285 }
1286
1287 pub fn wait_for_event(
1290 &self,
1291 deadline: zx::MonotonicInstant,
1292 ) -> Result<ControllerEvent, fidl::Error> {
1293 ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
1294 }
1295
1296 pub fn r#set_control(
1317 &self,
1318 mut options: &ControlOptions,
1319 ___deadline: zx::MonotonicInstant,
1320 ) -> Result<ControllerSetControlResult, fidl::Error> {
1321 let _response = self.client.send_query::<
1322 ControllerSetControlRequest,
1323 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1324 ControllerMarker,
1325 >(
1326 (options,),
1327 0x363a64b0c8d45594,
1328 fidl::encoding::DynamicFlags::FLEXIBLE,
1329 ___deadline,
1330 )?
1331 .into_result::<ControllerMarker>("set_control")?;
1332 Ok(_response.map(|x| x))
1333 }
1334
1335 pub fn r#clear_control(
1358 &self,
1359 mut options: &ControlOptions,
1360 ___deadline: zx::MonotonicInstant,
1361 ) -> Result<ControllerClearControlResult, fidl::Error> {
1362 let _response = self.client.send_query::<
1363 ControllerClearControlRequest,
1364 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1365 ControllerMarker,
1366 >(
1367 (options,),
1368 0x2b2a45d9fa0cd3c1,
1369 fidl::encoding::DynamicFlags::FLEXIBLE,
1370 ___deadline,
1371 )?
1372 .into_result::<ControllerMarker>("clear_control")?;
1373 Ok(_response.map(|x| x))
1374 }
1375}
1376
1377#[cfg(target_os = "fuchsia")]
1378impl From<ControllerSynchronousProxy> for zx::NullableHandle {
1379 fn from(value: ControllerSynchronousProxy) -> Self {
1380 value.into_channel().into()
1381 }
1382}
1383
1384#[cfg(target_os = "fuchsia")]
1385impl From<fidl::Channel> for ControllerSynchronousProxy {
1386 fn from(value: fidl::Channel) -> Self {
1387 Self::new(value)
1388 }
1389}
1390
1391#[cfg(target_os = "fuchsia")]
1392impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
1393 type Protocol = ControllerMarker;
1394
1395 fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
1396 Self::new(value.into_channel())
1397 }
1398}
1399
1400#[derive(Debug, Clone)]
1401pub struct ControllerProxy {
1402 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1403}
1404
1405impl fidl::endpoints::Proxy for ControllerProxy {
1406 type Protocol = ControllerMarker;
1407
1408 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1409 Self::new(inner)
1410 }
1411
1412 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1413 self.client.into_channel().map_err(|client| Self { client })
1414 }
1415
1416 fn as_channel(&self) -> &::fidl::AsyncChannel {
1417 self.client.as_channel()
1418 }
1419}
1420
1421impl ControllerProxy {
1422 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1424 let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1425 Self { client: fidl::client::Client::new(channel, protocol_name) }
1426 }
1427
1428 pub fn take_event_stream(&self) -> ControllerEventStream {
1434 ControllerEventStream { event_receiver: self.client.take_event_receiver() }
1435 }
1436
1437 pub fn r#set_control(
1458 &self,
1459 mut options: &ControlOptions,
1460 ) -> fidl::client::QueryResponseFut<
1461 ControllerSetControlResult,
1462 fidl::encoding::DefaultFuchsiaResourceDialect,
1463 > {
1464 ControllerProxyInterface::r#set_control(self, options)
1465 }
1466
1467 pub fn r#clear_control(
1490 &self,
1491 mut options: &ControlOptions,
1492 ) -> fidl::client::QueryResponseFut<
1493 ControllerClearControlResult,
1494 fidl::encoding::DefaultFuchsiaResourceDialect,
1495 > {
1496 ControllerProxyInterface::r#clear_control(self, options)
1497 }
1498}
1499
1500impl ControllerProxyInterface for ControllerProxy {
1501 type SetControlResponseFut = fidl::client::QueryResponseFut<
1502 ControllerSetControlResult,
1503 fidl::encoding::DefaultFuchsiaResourceDialect,
1504 >;
1505 fn r#set_control(&self, mut options: &ControlOptions) -> Self::SetControlResponseFut {
1506 fn _decode(
1507 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1508 ) -> Result<ControllerSetControlResult, fidl::Error> {
1509 let _response = fidl::client::decode_transaction_body::<
1510 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1511 fidl::encoding::DefaultFuchsiaResourceDialect,
1512 0x363a64b0c8d45594,
1513 >(_buf?)?
1514 .into_result::<ControllerMarker>("set_control")?;
1515 Ok(_response.map(|x| x))
1516 }
1517 self.client
1518 .send_query_and_decode::<ControllerSetControlRequest, ControllerSetControlResult>(
1519 (options,),
1520 0x363a64b0c8d45594,
1521 fidl::encoding::DynamicFlags::FLEXIBLE,
1522 _decode,
1523 )
1524 }
1525
1526 type ClearControlResponseFut = fidl::client::QueryResponseFut<
1527 ControllerClearControlResult,
1528 fidl::encoding::DefaultFuchsiaResourceDialect,
1529 >;
1530 fn r#clear_control(&self, mut options: &ControlOptions) -> Self::ClearControlResponseFut {
1531 fn _decode(
1532 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1533 ) -> Result<ControllerClearControlResult, fidl::Error> {
1534 let _response = fidl::client::decode_transaction_body::<
1535 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
1536 fidl::encoding::DefaultFuchsiaResourceDialect,
1537 0x2b2a45d9fa0cd3c1,
1538 >(_buf?)?
1539 .into_result::<ControllerMarker>("clear_control")?;
1540 Ok(_response.map(|x| x))
1541 }
1542 self.client
1543 .send_query_and_decode::<ControllerClearControlRequest, ControllerClearControlResult>(
1544 (options,),
1545 0x2b2a45d9fa0cd3c1,
1546 fidl::encoding::DynamicFlags::FLEXIBLE,
1547 _decode,
1548 )
1549 }
1550}
1551
1552pub struct ControllerEventStream {
1553 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1554}
1555
1556impl std::marker::Unpin for ControllerEventStream {}
1557
1558impl futures::stream::FusedStream for ControllerEventStream {
1559 fn is_terminated(&self) -> bool {
1560 self.event_receiver.is_terminated()
1561 }
1562}
1563
1564impl futures::Stream for ControllerEventStream {
1565 type Item = Result<ControllerEvent, fidl::Error>;
1566
1567 fn poll_next(
1568 mut self: std::pin::Pin<&mut Self>,
1569 cx: &mut std::task::Context<'_>,
1570 ) -> std::task::Poll<Option<Self::Item>> {
1571 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1572 &mut self.event_receiver,
1573 cx
1574 )?) {
1575 Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
1576 None => std::task::Poll::Ready(None),
1577 }
1578 }
1579}
1580
1581#[derive(Debug)]
1582pub enum ControllerEvent {
1583 #[non_exhaustive]
1584 _UnknownEvent {
1585 ordinal: u64,
1587 },
1588}
1589
1590impl ControllerEvent {
1591 fn decode(
1593 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1594 ) -> Result<ControllerEvent, fidl::Error> {
1595 let (bytes, _handles) = buf.split_mut();
1596 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1597 debug_assert_eq!(tx_header.tx_id, 0);
1598 match tx_header.ordinal {
1599 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1600 Ok(ControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1601 }
1602 _ => Err(fidl::Error::UnknownOrdinal {
1603 ordinal: tx_header.ordinal,
1604 protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1605 }),
1606 }
1607 }
1608}
1609
1610pub struct ControllerRequestStream {
1612 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1613 is_terminated: bool,
1614}
1615
1616impl std::marker::Unpin for ControllerRequestStream {}
1617
1618impl futures::stream::FusedStream for ControllerRequestStream {
1619 fn is_terminated(&self) -> bool {
1620 self.is_terminated
1621 }
1622}
1623
1624impl fidl::endpoints::RequestStream for ControllerRequestStream {
1625 type Protocol = ControllerMarker;
1626 type ControlHandle = ControllerControlHandle;
1627
1628 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1629 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1630 }
1631
1632 fn control_handle(&self) -> Self::ControlHandle {
1633 ControllerControlHandle { inner: self.inner.clone() }
1634 }
1635
1636 fn into_inner(
1637 self,
1638 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1639 {
1640 (self.inner, self.is_terminated)
1641 }
1642
1643 fn from_inner(
1644 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1645 is_terminated: bool,
1646 ) -> Self {
1647 Self { inner, is_terminated }
1648 }
1649}
1650
1651impl futures::Stream for ControllerRequestStream {
1652 type Item = Result<ControllerRequest, fidl::Error>;
1653
1654 fn poll_next(
1655 mut self: std::pin::Pin<&mut Self>,
1656 cx: &mut std::task::Context<'_>,
1657 ) -> std::task::Poll<Option<Self::Item>> {
1658 let this = &mut *self;
1659 if this.inner.check_shutdown(cx) {
1660 this.is_terminated = true;
1661 return std::task::Poll::Ready(None);
1662 }
1663 if this.is_terminated {
1664 panic!("polled ControllerRequestStream after completion");
1665 }
1666 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1667 |bytes, handles| {
1668 match this.inner.channel().read_etc(cx, bytes, handles) {
1669 std::task::Poll::Ready(Ok(())) => {}
1670 std::task::Poll::Pending => return std::task::Poll::Pending,
1671 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1672 this.is_terminated = true;
1673 return std::task::Poll::Ready(None);
1674 }
1675 std::task::Poll::Ready(Err(e)) => {
1676 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1677 e.into(),
1678 ))));
1679 }
1680 }
1681
1682 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1684
1685 std::task::Poll::Ready(Some(match header.ordinal {
1686 0x363a64b0c8d45594 => {
1687 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1688 let mut req = fidl::new_empty!(
1689 ControllerSetControlRequest,
1690 fidl::encoding::DefaultFuchsiaResourceDialect
1691 );
1692 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerSetControlRequest>(&header, _body_bytes, handles, &mut req)?;
1693 let control_handle = ControllerControlHandle { inner: this.inner.clone() };
1694 Ok(ControllerRequest::SetControl {
1695 options: req.options,
1696
1697 responder: ControllerSetControlResponder {
1698 control_handle: std::mem::ManuallyDrop::new(control_handle),
1699 tx_id: header.tx_id,
1700 },
1701 })
1702 }
1703 0x2b2a45d9fa0cd3c1 => {
1704 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1705 let mut req = fidl::new_empty!(
1706 ControllerClearControlRequest,
1707 fidl::encoding::DefaultFuchsiaResourceDialect
1708 );
1709 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerClearControlRequest>(&header, _body_bytes, handles, &mut req)?;
1710 let control_handle = ControllerControlHandle { inner: this.inner.clone() };
1711 Ok(ControllerRequest::ClearControl {
1712 options: req.options,
1713
1714 responder: ControllerClearControlResponder {
1715 control_handle: std::mem::ManuallyDrop::new(control_handle),
1716 tx_id: header.tx_id,
1717 },
1718 })
1719 }
1720 _ if header.tx_id == 0
1721 && header
1722 .dynamic_flags()
1723 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1724 {
1725 Ok(ControllerRequest::_UnknownMethod {
1726 ordinal: header.ordinal,
1727 control_handle: ControllerControlHandle { inner: this.inner.clone() },
1728 method_type: fidl::MethodType::OneWay,
1729 })
1730 }
1731 _ if header
1732 .dynamic_flags()
1733 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1734 {
1735 this.inner.send_framework_err(
1736 fidl::encoding::FrameworkErr::UnknownMethod,
1737 header.tx_id,
1738 header.ordinal,
1739 header.dynamic_flags(),
1740 (bytes, handles),
1741 )?;
1742 Ok(ControllerRequest::_UnknownMethod {
1743 ordinal: header.ordinal,
1744 control_handle: ControllerControlHandle { inner: this.inner.clone() },
1745 method_type: fidl::MethodType::TwoWay,
1746 })
1747 }
1748 _ => Err(fidl::Error::UnknownOrdinal {
1749 ordinal: header.ordinal,
1750 protocol_name:
1751 <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1752 }),
1753 }))
1754 },
1755 )
1756 }
1757}
1758
1759#[derive(Debug)]
1779pub enum ControllerRequest {
1780 SetControl { options: ControlOptions, responder: ControllerSetControlResponder },
1801 ClearControl { options: ControlOptions, responder: ControllerClearControlResponder },
1824 #[non_exhaustive]
1826 _UnknownMethod {
1827 ordinal: u64,
1829 control_handle: ControllerControlHandle,
1830 method_type: fidl::MethodType,
1831 },
1832}
1833
1834impl ControllerRequest {
1835 #[allow(irrefutable_let_patterns)]
1836 pub fn into_set_control(self) -> Option<(ControlOptions, ControllerSetControlResponder)> {
1837 if let ControllerRequest::SetControl { options, responder } = self {
1838 Some((options, responder))
1839 } else {
1840 None
1841 }
1842 }
1843
1844 #[allow(irrefutable_let_patterns)]
1845 pub fn into_clear_control(self) -> Option<(ControlOptions, ControllerClearControlResponder)> {
1846 if let ControllerRequest::ClearControl { options, responder } = self {
1847 Some((options, responder))
1848 } else {
1849 None
1850 }
1851 }
1852
1853 pub fn method_name(&self) -> &'static str {
1855 match *self {
1856 ControllerRequest::SetControl { .. } => "set_control",
1857 ControllerRequest::ClearControl { .. } => "clear_control",
1858 ControllerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1859 "unknown one-way method"
1860 }
1861 ControllerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1862 "unknown two-way method"
1863 }
1864 }
1865 }
1866}
1867
1868#[derive(Debug, Clone)]
1869pub struct ControllerControlHandle {
1870 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1871}
1872
1873impl ControllerControlHandle {
1874 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1875 self.inner.shutdown_with_epitaph(status.into())
1876 }
1877}
1878
1879impl fidl::endpoints::ControlHandle for ControllerControlHandle {
1880 fn shutdown(&self) {
1881 self.inner.shutdown()
1882 }
1883
1884 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1885 self.inner.shutdown_with_epitaph(status)
1886 }
1887
1888 fn is_closed(&self) -> bool {
1889 self.inner.channel().is_closed()
1890 }
1891 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1892 self.inner.channel().on_closed()
1893 }
1894
1895 #[cfg(target_os = "fuchsia")]
1896 fn signal_peer(
1897 &self,
1898 clear_mask: zx::Signals,
1899 set_mask: zx::Signals,
1900 ) -> Result<(), zx_status::Status> {
1901 use fidl::Peered;
1902 self.inner.channel().signal_peer(clear_mask, set_mask)
1903 }
1904}
1905
1906impl ControllerControlHandle {}
1907
1908#[must_use = "FIDL methods require a response to be sent"]
1909#[derive(Debug)]
1910pub struct ControllerSetControlResponder {
1911 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1912 tx_id: u32,
1913}
1914
1915impl std::ops::Drop for ControllerSetControlResponder {
1919 fn drop(&mut self) {
1920 self.control_handle.shutdown();
1921 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1923 }
1924}
1925
1926impl fidl::endpoints::Responder for ControllerSetControlResponder {
1927 type ControlHandle = ControllerControlHandle;
1928
1929 fn control_handle(&self) -> &ControllerControlHandle {
1930 &self.control_handle
1931 }
1932
1933 fn drop_without_shutdown(mut self) {
1934 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1936 std::mem::forget(self);
1938 }
1939}
1940
1941impl ControllerSetControlResponder {
1942 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1946 let _result = self.send_raw(result);
1947 if _result.is_err() {
1948 self.control_handle.shutdown();
1949 }
1950 self.drop_without_shutdown();
1951 _result
1952 }
1953
1954 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1956 let _result = self.send_raw(result);
1957 self.drop_without_shutdown();
1958 _result
1959 }
1960
1961 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1962 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1963 fidl::encoding::EmptyStruct,
1964 Error,
1965 >>(
1966 fidl::encoding::FlexibleResult::new(result),
1967 self.tx_id,
1968 0x363a64b0c8d45594,
1969 fidl::encoding::DynamicFlags::FLEXIBLE,
1970 )
1971 }
1972}
1973
1974#[must_use = "FIDL methods require a response to be sent"]
1975#[derive(Debug)]
1976pub struct ControllerClearControlResponder {
1977 control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1978 tx_id: u32,
1979}
1980
1981impl std::ops::Drop for ControllerClearControlResponder {
1985 fn drop(&mut self) {
1986 self.control_handle.shutdown();
1987 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1989 }
1990}
1991
1992impl fidl::endpoints::Responder for ControllerClearControlResponder {
1993 type ControlHandle = ControllerControlHandle;
1994
1995 fn control_handle(&self) -> &ControllerControlHandle {
1996 &self.control_handle
1997 }
1998
1999 fn drop_without_shutdown(mut self) {
2000 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2002 std::mem::forget(self);
2004 }
2005}
2006
2007impl ControllerClearControlResponder {
2008 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2012 let _result = self.send_raw(result);
2013 if _result.is_err() {
2014 self.control_handle.shutdown();
2015 }
2016 self.drop_without_shutdown();
2017 _result
2018 }
2019
2020 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2022 let _result = self.send_raw(result);
2023 self.drop_without_shutdown();
2024 _result
2025 }
2026
2027 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2028 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2029 fidl::encoding::EmptyStruct,
2030 Error,
2031 >>(
2032 fidl::encoding::FlexibleResult::new(result),
2033 self.tx_id,
2034 0x2b2a45d9fa0cd3c1,
2035 fidl::encoding::DynamicFlags::FLEXIBLE,
2036 )
2037 }
2038}
2039
2040#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2041pub struct DebugMarker;
2042
2043impl fidl::endpoints::ProtocolMarker for DebugMarker {
2044 type Proxy = DebugProxy;
2045 type RequestStream = DebugRequestStream;
2046 #[cfg(target_os = "fuchsia")]
2047 type SynchronousProxy = DebugSynchronousProxy;
2048
2049 const DEBUG_NAME: &'static str = "(anonymous) Debug";
2050}
2051
2052pub trait DebugProxyInterface: Send + Sync {
2053 type SetControlResponseFut: std::future::Future<Output = Result<ControllerSetControlResult, fidl::Error>>
2054 + Send;
2055 fn r#set_control(&self, options: &ControlOptions) -> Self::SetControlResponseFut;
2056 type ClearControlResponseFut: std::future::Future<Output = Result<ControllerClearControlResult, fidl::Error>>
2057 + Send;
2058 fn r#clear_control(&self, options: &ControlOptions) -> Self::ClearControlResponseFut;
2059}
2060#[derive(Debug)]
2061#[cfg(target_os = "fuchsia")]
2062pub struct DebugSynchronousProxy {
2063 client: fidl::client::sync::Client,
2064}
2065
2066#[cfg(target_os = "fuchsia")]
2067impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
2068 type Proxy = DebugProxy;
2069 type Protocol = DebugMarker;
2070
2071 fn from_channel(inner: fidl::Channel) -> Self {
2072 Self::new(inner)
2073 }
2074
2075 fn into_channel(self) -> fidl::Channel {
2076 self.client.into_channel()
2077 }
2078
2079 fn as_channel(&self) -> &fidl::Channel {
2080 self.client.as_channel()
2081 }
2082}
2083
2084#[cfg(target_os = "fuchsia")]
2085impl DebugSynchronousProxy {
2086 pub fn new(channel: fidl::Channel) -> Self {
2087 Self { client: fidl::client::sync::Client::new(channel) }
2088 }
2089
2090 pub fn into_channel(self) -> fidl::Channel {
2091 self.client.into_channel()
2092 }
2093
2094 pub fn wait_for_event(
2097 &self,
2098 deadline: zx::MonotonicInstant,
2099 ) -> Result<DebugEvent, fidl::Error> {
2100 DebugEvent::decode(self.client.wait_for_event::<DebugMarker>(deadline)?)
2101 }
2102
2103 pub fn r#set_control(
2124 &self,
2125 mut options: &ControlOptions,
2126 ___deadline: zx::MonotonicInstant,
2127 ) -> Result<ControllerSetControlResult, fidl::Error> {
2128 let _response = self.client.send_query::<
2129 ControllerSetControlRequest,
2130 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2131 DebugMarker,
2132 >(
2133 (options,),
2134 0x363a64b0c8d45594,
2135 fidl::encoding::DynamicFlags::FLEXIBLE,
2136 ___deadline,
2137 )?
2138 .into_result::<DebugMarker>("set_control")?;
2139 Ok(_response.map(|x| x))
2140 }
2141
2142 pub fn r#clear_control(
2165 &self,
2166 mut options: &ControlOptions,
2167 ___deadline: zx::MonotonicInstant,
2168 ) -> Result<ControllerClearControlResult, fidl::Error> {
2169 let _response = self.client.send_query::<
2170 ControllerClearControlRequest,
2171 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2172 DebugMarker,
2173 >(
2174 (options,),
2175 0x2b2a45d9fa0cd3c1,
2176 fidl::encoding::DynamicFlags::FLEXIBLE,
2177 ___deadline,
2178 )?
2179 .into_result::<DebugMarker>("clear_control")?;
2180 Ok(_response.map(|x| x))
2181 }
2182}
2183
2184#[cfg(target_os = "fuchsia")]
2185impl From<DebugSynchronousProxy> for zx::NullableHandle {
2186 fn from(value: DebugSynchronousProxy) -> Self {
2187 value.into_channel().into()
2188 }
2189}
2190
2191#[cfg(target_os = "fuchsia")]
2192impl From<fidl::Channel> for DebugSynchronousProxy {
2193 fn from(value: fidl::Channel) -> Self {
2194 Self::new(value)
2195 }
2196}
2197
2198#[cfg(target_os = "fuchsia")]
2199impl fidl::endpoints::FromClient for DebugSynchronousProxy {
2200 type Protocol = DebugMarker;
2201
2202 fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
2203 Self::new(value.into_channel())
2204 }
2205}
2206
2207#[derive(Debug, Clone)]
2208pub struct DebugProxy {
2209 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2210}
2211
2212impl fidl::endpoints::Proxy for DebugProxy {
2213 type Protocol = DebugMarker;
2214
2215 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2216 Self::new(inner)
2217 }
2218
2219 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2220 self.client.into_channel().map_err(|client| Self { client })
2221 }
2222
2223 fn as_channel(&self) -> &::fidl::AsyncChannel {
2224 self.client.as_channel()
2225 }
2226}
2227
2228impl DebugProxy {
2229 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2231 let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2232 Self { client: fidl::client::Client::new(channel, protocol_name) }
2233 }
2234
2235 pub fn take_event_stream(&self) -> DebugEventStream {
2241 DebugEventStream { event_receiver: self.client.take_event_receiver() }
2242 }
2243
2244 pub fn r#set_control(
2265 &self,
2266 mut options: &ControlOptions,
2267 ) -> fidl::client::QueryResponseFut<
2268 ControllerSetControlResult,
2269 fidl::encoding::DefaultFuchsiaResourceDialect,
2270 > {
2271 DebugProxyInterface::r#set_control(self, options)
2272 }
2273
2274 pub fn r#clear_control(
2297 &self,
2298 mut options: &ControlOptions,
2299 ) -> fidl::client::QueryResponseFut<
2300 ControllerClearControlResult,
2301 fidl::encoding::DefaultFuchsiaResourceDialect,
2302 > {
2303 DebugProxyInterface::r#clear_control(self, options)
2304 }
2305}
2306
2307impl DebugProxyInterface for DebugProxy {
2308 type SetControlResponseFut = fidl::client::QueryResponseFut<
2309 ControllerSetControlResult,
2310 fidl::encoding::DefaultFuchsiaResourceDialect,
2311 >;
2312 fn r#set_control(&self, mut options: &ControlOptions) -> Self::SetControlResponseFut {
2313 fn _decode(
2314 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2315 ) -> Result<ControllerSetControlResult, fidl::Error> {
2316 let _response = fidl::client::decode_transaction_body::<
2317 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2318 fidl::encoding::DefaultFuchsiaResourceDialect,
2319 0x363a64b0c8d45594,
2320 >(_buf?)?
2321 .into_result::<DebugMarker>("set_control")?;
2322 Ok(_response.map(|x| x))
2323 }
2324 self.client
2325 .send_query_and_decode::<ControllerSetControlRequest, ControllerSetControlResult>(
2326 (options,),
2327 0x363a64b0c8d45594,
2328 fidl::encoding::DynamicFlags::FLEXIBLE,
2329 _decode,
2330 )
2331 }
2332
2333 type ClearControlResponseFut = fidl::client::QueryResponseFut<
2334 ControllerClearControlResult,
2335 fidl::encoding::DefaultFuchsiaResourceDialect,
2336 >;
2337 fn r#clear_control(&self, mut options: &ControlOptions) -> Self::ClearControlResponseFut {
2338 fn _decode(
2339 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2340 ) -> Result<ControllerClearControlResult, fidl::Error> {
2341 let _response = fidl::client::decode_transaction_body::<
2342 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2343 fidl::encoding::DefaultFuchsiaResourceDialect,
2344 0x2b2a45d9fa0cd3c1,
2345 >(_buf?)?
2346 .into_result::<DebugMarker>("clear_control")?;
2347 Ok(_response.map(|x| x))
2348 }
2349 self.client
2350 .send_query_and_decode::<ControllerClearControlRequest, ControllerClearControlResult>(
2351 (options,),
2352 0x2b2a45d9fa0cd3c1,
2353 fidl::encoding::DynamicFlags::FLEXIBLE,
2354 _decode,
2355 )
2356 }
2357}
2358
2359pub struct DebugEventStream {
2360 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2361}
2362
2363impl std::marker::Unpin for DebugEventStream {}
2364
2365impl futures::stream::FusedStream for DebugEventStream {
2366 fn is_terminated(&self) -> bool {
2367 self.event_receiver.is_terminated()
2368 }
2369}
2370
2371impl futures::Stream for DebugEventStream {
2372 type Item = Result<DebugEvent, fidl::Error>;
2373
2374 fn poll_next(
2375 mut self: std::pin::Pin<&mut Self>,
2376 cx: &mut std::task::Context<'_>,
2377 ) -> std::task::Poll<Option<Self::Item>> {
2378 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2379 &mut self.event_receiver,
2380 cx
2381 )?) {
2382 Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
2383 None => std::task::Poll::Ready(None),
2384 }
2385 }
2386}
2387
2388#[derive(Debug)]
2389pub enum DebugEvent {
2390 #[non_exhaustive]
2391 _UnknownEvent {
2392 ordinal: u64,
2394 },
2395}
2396
2397impl DebugEvent {
2398 fn decode(
2400 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2401 ) -> Result<DebugEvent, fidl::Error> {
2402 let (bytes, _handles) = buf.split_mut();
2403 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2404 debug_assert_eq!(tx_header.tx_id, 0);
2405 match tx_header.ordinal {
2406 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2407 Ok(DebugEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2408 }
2409 _ => Err(fidl::Error::UnknownOrdinal {
2410 ordinal: tx_header.ordinal,
2411 protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2412 }),
2413 }
2414 }
2415}
2416
2417pub struct DebugRequestStream {
2419 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2420 is_terminated: bool,
2421}
2422
2423impl std::marker::Unpin for DebugRequestStream {}
2424
2425impl futures::stream::FusedStream for DebugRequestStream {
2426 fn is_terminated(&self) -> bool {
2427 self.is_terminated
2428 }
2429}
2430
2431impl fidl::endpoints::RequestStream for DebugRequestStream {
2432 type Protocol = DebugMarker;
2433 type ControlHandle = DebugControlHandle;
2434
2435 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2436 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2437 }
2438
2439 fn control_handle(&self) -> Self::ControlHandle {
2440 DebugControlHandle { inner: self.inner.clone() }
2441 }
2442
2443 fn into_inner(
2444 self,
2445 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2446 {
2447 (self.inner, self.is_terminated)
2448 }
2449
2450 fn from_inner(
2451 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2452 is_terminated: bool,
2453 ) -> Self {
2454 Self { inner, is_terminated }
2455 }
2456}
2457
2458impl futures::Stream for DebugRequestStream {
2459 type Item = Result<DebugRequest, fidl::Error>;
2460
2461 fn poll_next(
2462 mut self: std::pin::Pin<&mut Self>,
2463 cx: &mut std::task::Context<'_>,
2464 ) -> std::task::Poll<Option<Self::Item>> {
2465 let this = &mut *self;
2466 if this.inner.check_shutdown(cx) {
2467 this.is_terminated = true;
2468 return std::task::Poll::Ready(None);
2469 }
2470 if this.is_terminated {
2471 panic!("polled DebugRequestStream after completion");
2472 }
2473 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2474 |bytes, handles| {
2475 match this.inner.channel().read_etc(cx, bytes, handles) {
2476 std::task::Poll::Ready(Ok(())) => {}
2477 std::task::Poll::Pending => return std::task::Poll::Pending,
2478 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2479 this.is_terminated = true;
2480 return std::task::Poll::Ready(None);
2481 }
2482 std::task::Poll::Ready(Err(e)) => {
2483 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2484 e.into(),
2485 ))));
2486 }
2487 }
2488
2489 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2491
2492 std::task::Poll::Ready(Some(match header.ordinal {
2493 0x363a64b0c8d45594 => {
2494 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2495 let mut req = fidl::new_empty!(
2496 ControllerSetControlRequest,
2497 fidl::encoding::DefaultFuchsiaResourceDialect
2498 );
2499 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerSetControlRequest>(&header, _body_bytes, handles, &mut req)?;
2500 let control_handle = DebugControlHandle { inner: this.inner.clone() };
2501 Ok(DebugRequest::SetControl {
2502 options: req.options,
2503
2504 responder: DebugSetControlResponder {
2505 control_handle: std::mem::ManuallyDrop::new(control_handle),
2506 tx_id: header.tx_id,
2507 },
2508 })
2509 }
2510 0x2b2a45d9fa0cd3c1 => {
2511 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2512 let mut req = fidl::new_empty!(
2513 ControllerClearControlRequest,
2514 fidl::encoding::DefaultFuchsiaResourceDialect
2515 );
2516 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerClearControlRequest>(&header, _body_bytes, handles, &mut req)?;
2517 let control_handle = DebugControlHandle { inner: this.inner.clone() };
2518 Ok(DebugRequest::ClearControl {
2519 options: req.options,
2520
2521 responder: DebugClearControlResponder {
2522 control_handle: std::mem::ManuallyDrop::new(control_handle),
2523 tx_id: header.tx_id,
2524 },
2525 })
2526 }
2527 _ if header.tx_id == 0
2528 && header
2529 .dynamic_flags()
2530 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2531 {
2532 Ok(DebugRequest::_UnknownMethod {
2533 ordinal: header.ordinal,
2534 control_handle: DebugControlHandle { inner: this.inner.clone() },
2535 method_type: fidl::MethodType::OneWay,
2536 })
2537 }
2538 _ if header
2539 .dynamic_flags()
2540 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2541 {
2542 this.inner.send_framework_err(
2543 fidl::encoding::FrameworkErr::UnknownMethod,
2544 header.tx_id,
2545 header.ordinal,
2546 header.dynamic_flags(),
2547 (bytes, handles),
2548 )?;
2549 Ok(DebugRequest::_UnknownMethod {
2550 ordinal: header.ordinal,
2551 control_handle: DebugControlHandle { inner: this.inner.clone() },
2552 method_type: fidl::MethodType::TwoWay,
2553 })
2554 }
2555 _ => Err(fidl::Error::UnknownOrdinal {
2556 ordinal: header.ordinal,
2557 protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2558 }),
2559 }))
2560 },
2561 )
2562 }
2563}
2564
2565#[derive(Debug)]
2590pub enum DebugRequest {
2591 SetControl { options: ControlOptions, responder: DebugSetControlResponder },
2612 ClearControl { options: ControlOptions, responder: DebugClearControlResponder },
2635 #[non_exhaustive]
2637 _UnknownMethod {
2638 ordinal: u64,
2640 control_handle: DebugControlHandle,
2641 method_type: fidl::MethodType,
2642 },
2643}
2644
2645impl DebugRequest {
2646 #[allow(irrefutable_let_patterns)]
2647 pub fn into_set_control(self) -> Option<(ControlOptions, DebugSetControlResponder)> {
2648 if let DebugRequest::SetControl { options, responder } = self {
2649 Some((options, responder))
2650 } else {
2651 None
2652 }
2653 }
2654
2655 #[allow(irrefutable_let_patterns)]
2656 pub fn into_clear_control(self) -> Option<(ControlOptions, DebugClearControlResponder)> {
2657 if let DebugRequest::ClearControl { options, responder } = self {
2658 Some((options, responder))
2659 } else {
2660 None
2661 }
2662 }
2663
2664 pub fn method_name(&self) -> &'static str {
2666 match *self {
2667 DebugRequest::SetControl { .. } => "set_control",
2668 DebugRequest::ClearControl { .. } => "clear_control",
2669 DebugRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2670 "unknown one-way method"
2671 }
2672 DebugRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2673 "unknown two-way method"
2674 }
2675 }
2676 }
2677}
2678
2679#[derive(Debug, Clone)]
2680pub struct DebugControlHandle {
2681 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2682}
2683
2684impl DebugControlHandle {
2685 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2686 self.inner.shutdown_with_epitaph(status.into())
2687 }
2688}
2689
2690impl fidl::endpoints::ControlHandle for DebugControlHandle {
2691 fn shutdown(&self) {
2692 self.inner.shutdown()
2693 }
2694
2695 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2696 self.inner.shutdown_with_epitaph(status)
2697 }
2698
2699 fn is_closed(&self) -> bool {
2700 self.inner.channel().is_closed()
2701 }
2702 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2703 self.inner.channel().on_closed()
2704 }
2705
2706 #[cfg(target_os = "fuchsia")]
2707 fn signal_peer(
2708 &self,
2709 clear_mask: zx::Signals,
2710 set_mask: zx::Signals,
2711 ) -> Result<(), zx_status::Status> {
2712 use fidl::Peered;
2713 self.inner.channel().signal_peer(clear_mask, set_mask)
2714 }
2715}
2716
2717impl DebugControlHandle {}
2718
2719#[must_use = "FIDL methods require a response to be sent"]
2720#[derive(Debug)]
2721pub struct DebugSetControlResponder {
2722 control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
2723 tx_id: u32,
2724}
2725
2726impl std::ops::Drop for DebugSetControlResponder {
2730 fn drop(&mut self) {
2731 self.control_handle.shutdown();
2732 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2734 }
2735}
2736
2737impl fidl::endpoints::Responder for DebugSetControlResponder {
2738 type ControlHandle = DebugControlHandle;
2739
2740 fn control_handle(&self) -> &DebugControlHandle {
2741 &self.control_handle
2742 }
2743
2744 fn drop_without_shutdown(mut self) {
2745 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2747 std::mem::forget(self);
2749 }
2750}
2751
2752impl DebugSetControlResponder {
2753 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2757 let _result = self.send_raw(result);
2758 if _result.is_err() {
2759 self.control_handle.shutdown();
2760 }
2761 self.drop_without_shutdown();
2762 _result
2763 }
2764
2765 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2767 let _result = self.send_raw(result);
2768 self.drop_without_shutdown();
2769 _result
2770 }
2771
2772 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2773 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2774 fidl::encoding::EmptyStruct,
2775 Error,
2776 >>(
2777 fidl::encoding::FlexibleResult::new(result),
2778 self.tx_id,
2779 0x363a64b0c8d45594,
2780 fidl::encoding::DynamicFlags::FLEXIBLE,
2781 )
2782 }
2783}
2784
2785#[must_use = "FIDL methods require a response to be sent"]
2786#[derive(Debug)]
2787pub struct DebugClearControlResponder {
2788 control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
2789 tx_id: u32,
2790}
2791
2792impl std::ops::Drop for DebugClearControlResponder {
2796 fn drop(&mut self) {
2797 self.control_handle.shutdown();
2798 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2800 }
2801}
2802
2803impl fidl::endpoints::Responder for DebugClearControlResponder {
2804 type ControlHandle = DebugControlHandle;
2805
2806 fn control_handle(&self) -> &DebugControlHandle {
2807 &self.control_handle
2808 }
2809
2810 fn drop_without_shutdown(mut self) {
2811 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2813 std::mem::forget(self);
2815 }
2816}
2817
2818impl DebugClearControlResponder {
2819 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2823 let _result = self.send_raw(result);
2824 if _result.is_err() {
2825 self.control_handle.shutdown();
2826 }
2827 self.drop_without_shutdown();
2828 _result
2829 }
2830
2831 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2833 let _result = self.send_raw(result);
2834 self.drop_without_shutdown();
2835 _result
2836 }
2837
2838 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2839 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2840 fidl::encoding::EmptyStruct,
2841 Error,
2842 >>(
2843 fidl::encoding::FlexibleResult::new(result),
2844 self.tx_id,
2845 0x2b2a45d9fa0cd3c1,
2846 fidl::encoding::DynamicFlags::FLEXIBLE,
2847 )
2848 }
2849}
2850
2851#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2852pub struct DebugServiceMarker;
2853
2854#[cfg(target_os = "fuchsia")]
2855impl fidl::endpoints::ServiceMarker for DebugServiceMarker {
2856 type Proxy = DebugServiceProxy;
2857 type Request = DebugServiceRequest;
2858 const SERVICE_NAME: &'static str = "fuchsia.hardware.power.charger.DebugService";
2859}
2860
2861#[cfg(target_os = "fuchsia")]
2868pub enum DebugServiceRequest {
2869 Debug(DebugRequestStream),
2870}
2871
2872#[cfg(target_os = "fuchsia")]
2873impl fidl::endpoints::ServiceRequest for DebugServiceRequest {
2874 type Service = DebugServiceMarker;
2875
2876 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2877 match name {
2878 "debug" => Self::Debug(
2879 <DebugRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2880 ),
2881 _ => panic!("no such member protocol name for service DebugService"),
2882 }
2883 }
2884
2885 fn member_names() -> &'static [&'static str] {
2886 &["debug"]
2887 }
2888}
2889#[cfg(target_os = "fuchsia")]
2894pub struct DebugServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2895
2896#[cfg(target_os = "fuchsia")]
2897impl fidl::endpoints::ServiceProxy for DebugServiceProxy {
2898 type Service = DebugServiceMarker;
2899
2900 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2901 Self(opener)
2902 }
2903}
2904
2905#[cfg(target_os = "fuchsia")]
2906impl DebugServiceProxy {
2907 pub fn connect_to_debug(&self) -> Result<DebugProxy, fidl::Error> {
2908 let (proxy, server_end) = fidl::endpoints::create_proxy::<DebugMarker>();
2909 self.connect_channel_to_debug(server_end)?;
2910 Ok(proxy)
2911 }
2912
2913 pub fn connect_to_debug_sync(&self) -> Result<DebugSynchronousProxy, fidl::Error> {
2916 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DebugMarker>();
2917 self.connect_channel_to_debug(server_end)?;
2918 Ok(proxy)
2919 }
2920
2921 pub fn connect_channel_to_debug(
2924 &self,
2925 server_end: fidl::endpoints::ServerEnd<DebugMarker>,
2926 ) -> Result<(), fidl::Error> {
2927 self.0.open_member("debug", server_end.into_channel())
2928 }
2929
2930 pub fn instance_name(&self) -> &str {
2931 self.0.instance_name()
2932 }
2933}
2934
2935#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2936pub struct ServiceMarker;
2937
2938#[cfg(target_os = "fuchsia")]
2939impl fidl::endpoints::ServiceMarker for ServiceMarker {
2940 type Proxy = ServiceProxy;
2941 type Request = ServiceRequest;
2942 const SERVICE_NAME: &'static str = "fuchsia.hardware.power.charger.Service";
2943}
2944
2945#[cfg(target_os = "fuchsia")]
2948pub enum ServiceRequest {
2949 Charger(ChargerRequestStream),
2950 Controller(ControllerRequestStream),
2951}
2952
2953#[cfg(target_os = "fuchsia")]
2954impl fidl::endpoints::ServiceRequest for ServiceRequest {
2955 type Service = ServiceMarker;
2956
2957 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2958 match name {
2959 "charger" => Self::Charger(
2960 <ChargerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2961 ),
2962 "controller" => Self::Controller(
2963 <ControllerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2964 ),
2965 _ => panic!("no such member protocol name for service Service"),
2966 }
2967 }
2968
2969 fn member_names() -> &'static [&'static str] {
2970 &["charger", "controller"]
2971 }
2972}
2973#[cfg(target_os = "fuchsia")]
2974pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2975
2976#[cfg(target_os = "fuchsia")]
2977impl fidl::endpoints::ServiceProxy for ServiceProxy {
2978 type Service = ServiceMarker;
2979
2980 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2981 Self(opener)
2982 }
2983}
2984
2985#[cfg(target_os = "fuchsia")]
2986impl ServiceProxy {
2987 pub fn connect_to_charger(&self) -> Result<ChargerProxy, fidl::Error> {
2988 let (proxy, server_end) = fidl::endpoints::create_proxy::<ChargerMarker>();
2989 self.connect_channel_to_charger(server_end)?;
2990 Ok(proxy)
2991 }
2992
2993 pub fn connect_to_charger_sync(&self) -> Result<ChargerSynchronousProxy, fidl::Error> {
2996 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ChargerMarker>();
2997 self.connect_channel_to_charger(server_end)?;
2998 Ok(proxy)
2999 }
3000
3001 pub fn connect_channel_to_charger(
3004 &self,
3005 server_end: fidl::endpoints::ServerEnd<ChargerMarker>,
3006 ) -> Result<(), fidl::Error> {
3007 self.0.open_member("charger", server_end.into_channel())
3008 }
3009 pub fn connect_to_controller(&self) -> Result<ControllerProxy, fidl::Error> {
3010 let (proxy, server_end) = fidl::endpoints::create_proxy::<ControllerMarker>();
3011 self.connect_channel_to_controller(server_end)?;
3012 Ok(proxy)
3013 }
3014
3015 pub fn connect_to_controller_sync(&self) -> Result<ControllerSynchronousProxy, fidl::Error> {
3018 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControllerMarker>();
3019 self.connect_channel_to_controller(server_end)?;
3020 Ok(proxy)
3021 }
3022
3023 pub fn connect_channel_to_controller(
3026 &self,
3027 server_end: fidl::endpoints::ServerEnd<ControllerMarker>,
3028 ) -> Result<(), fidl::Error> {
3029 self.0.open_member("controller", server_end.into_channel())
3030 }
3031
3032 pub fn instance_name(&self) -> &str {
3033 self.0.instance_name()
3034 }
3035}
3036
3037mod internal {
3038 use super::*;
3039
3040 impl fidl::encoding::ResourceTypeMarker for ChargerWatchRequest {
3041 type Borrowed<'a> = &'a mut Self;
3042 fn take_or_borrow<'a>(
3043 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3044 ) -> Self::Borrowed<'a> {
3045 value
3046 }
3047 }
3048
3049 unsafe impl fidl::encoding::TypeMarker for ChargerWatchRequest {
3050 type Owned = Self;
3051
3052 #[inline(always)]
3053 fn inline_align(_context: fidl::encoding::Context) -> usize {
3054 4
3055 }
3056
3057 #[inline(always)]
3058 fn inline_size(_context: fidl::encoding::Context) -> usize {
3059 4
3060 }
3061 }
3062
3063 unsafe impl
3064 fidl::encoding::Encode<ChargerWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3065 for &mut ChargerWatchRequest
3066 {
3067 #[inline]
3068 unsafe fn encode(
3069 self,
3070 encoder: &mut fidl::encoding::Encoder<
3071 '_,
3072 fidl::encoding::DefaultFuchsiaResourceDialect,
3073 >,
3074 offset: usize,
3075 _depth: fidl::encoding::Depth,
3076 ) -> fidl::Result<()> {
3077 encoder.debug_check_bounds::<ChargerWatchRequest>(offset);
3078 fidl::encoding::Encode::<
3080 ChargerWatchRequest,
3081 fidl::encoding::DefaultFuchsiaResourceDialect,
3082 >::encode(
3083 (<fidl::encoding::Optional<
3084 fidl::encoding::HandleType<
3085 fidl::EventPair,
3086 { fidl::ObjectType::EVENTPAIR.into_raw() },
3087 16387,
3088 >,
3089 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3090 &mut self.lease
3091 ),),
3092 encoder,
3093 offset,
3094 _depth,
3095 )
3096 }
3097 }
3098 unsafe impl<
3099 T0: fidl::encoding::Encode<
3100 fidl::encoding::Optional<
3101 fidl::encoding::HandleType<
3102 fidl::EventPair,
3103 { fidl::ObjectType::EVENTPAIR.into_raw() },
3104 16387,
3105 >,
3106 >,
3107 fidl::encoding::DefaultFuchsiaResourceDialect,
3108 >,
3109 > fidl::encoding::Encode<ChargerWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3110 for (T0,)
3111 {
3112 #[inline]
3113 unsafe fn encode(
3114 self,
3115 encoder: &mut fidl::encoding::Encoder<
3116 '_,
3117 fidl::encoding::DefaultFuchsiaResourceDialect,
3118 >,
3119 offset: usize,
3120 depth: fidl::encoding::Depth,
3121 ) -> fidl::Result<()> {
3122 encoder.debug_check_bounds::<ChargerWatchRequest>(offset);
3123 self.0.encode(encoder, offset + 0, depth)?;
3127 Ok(())
3128 }
3129 }
3130
3131 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3132 for ChargerWatchRequest
3133 {
3134 #[inline(always)]
3135 fn new_empty() -> Self {
3136 Self {
3137 lease: fidl::new_empty!(
3138 fidl::encoding::Optional<
3139 fidl::encoding::HandleType<
3140 fidl::EventPair,
3141 { fidl::ObjectType::EVENTPAIR.into_raw() },
3142 16387,
3143 >,
3144 >,
3145 fidl::encoding::DefaultFuchsiaResourceDialect
3146 ),
3147 }
3148 }
3149
3150 #[inline]
3151 unsafe fn decode(
3152 &mut self,
3153 decoder: &mut fidl::encoding::Decoder<
3154 '_,
3155 fidl::encoding::DefaultFuchsiaResourceDialect,
3156 >,
3157 offset: usize,
3158 _depth: fidl::encoding::Depth,
3159 ) -> fidl::Result<()> {
3160 decoder.debug_check_bounds::<Self>(offset);
3161 fidl::decode!(
3163 fidl::encoding::Optional<
3164 fidl::encoding::HandleType<
3165 fidl::EventPair,
3166 { fidl::ObjectType::EVENTPAIR.into_raw() },
3167 16387,
3168 >,
3169 >,
3170 fidl::encoding::DefaultFuchsiaResourceDialect,
3171 &mut self.lease,
3172 decoder,
3173 offset + 0,
3174 _depth
3175 )?;
3176 Ok(())
3177 }
3178 }
3179
3180 impl fidl::encoding::ResourceTypeMarker for ChargerWatchResponse {
3181 type Borrowed<'a> = &'a mut Self;
3182 fn take_or_borrow<'a>(
3183 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3184 ) -> Self::Borrowed<'a> {
3185 value
3186 }
3187 }
3188
3189 unsafe impl fidl::encoding::TypeMarker for ChargerWatchResponse {
3190 type Owned = Self;
3191
3192 #[inline(always)]
3193 fn inline_align(_context: fidl::encoding::Context) -> usize {
3194 8
3195 }
3196
3197 #[inline(always)]
3198 fn inline_size(_context: fidl::encoding::Context) -> usize {
3199 24
3200 }
3201 }
3202
3203 unsafe impl
3204 fidl::encoding::Encode<ChargerWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
3205 for &mut ChargerWatchResponse
3206 {
3207 #[inline]
3208 unsafe fn encode(
3209 self,
3210 encoder: &mut fidl::encoding::Encoder<
3211 '_,
3212 fidl::encoding::DefaultFuchsiaResourceDialect,
3213 >,
3214 offset: usize,
3215 _depth: fidl::encoding::Depth,
3216 ) -> fidl::Result<()> {
3217 encoder.debug_check_bounds::<ChargerWatchResponse>(offset);
3218 fidl::encoding::Encode::<
3220 ChargerWatchResponse,
3221 fidl::encoding::DefaultFuchsiaResourceDialect,
3222 >::encode(
3223 (
3224 <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
3225 <fidl::encoding::Optional<
3226 fidl::encoding::HandleType<
3227 fidl::EventPair,
3228 { fidl::ObjectType::EVENTPAIR.into_raw() },
3229 16387,
3230 >,
3231 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3232 &mut self.wake_lease
3233 ),
3234 ),
3235 encoder,
3236 offset,
3237 _depth,
3238 )
3239 }
3240 }
3241 unsafe impl<
3242 T0: fidl::encoding::Encode<Status, fidl::encoding::DefaultFuchsiaResourceDialect>,
3243 T1: fidl::encoding::Encode<
3244 fidl::encoding::Optional<
3245 fidl::encoding::HandleType<
3246 fidl::EventPair,
3247 { fidl::ObjectType::EVENTPAIR.into_raw() },
3248 16387,
3249 >,
3250 >,
3251 fidl::encoding::DefaultFuchsiaResourceDialect,
3252 >,
3253 >
3254 fidl::encoding::Encode<ChargerWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
3255 for (T0, T1)
3256 {
3257 #[inline]
3258 unsafe fn encode(
3259 self,
3260 encoder: &mut fidl::encoding::Encoder<
3261 '_,
3262 fidl::encoding::DefaultFuchsiaResourceDialect,
3263 >,
3264 offset: usize,
3265 depth: fidl::encoding::Depth,
3266 ) -> fidl::Result<()> {
3267 encoder.debug_check_bounds::<ChargerWatchResponse>(offset);
3268 unsafe {
3271 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3272 (ptr as *mut u64).write_unaligned(0);
3273 }
3274 self.0.encode(encoder, offset + 0, depth)?;
3276 self.1.encode(encoder, offset + 16, depth)?;
3277 Ok(())
3278 }
3279 }
3280
3281 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3282 for ChargerWatchResponse
3283 {
3284 #[inline(always)]
3285 fn new_empty() -> Self {
3286 Self {
3287 status: fidl::new_empty!(Status, fidl::encoding::DefaultFuchsiaResourceDialect),
3288 wake_lease: fidl::new_empty!(
3289 fidl::encoding::Optional<
3290 fidl::encoding::HandleType<
3291 fidl::EventPair,
3292 { fidl::ObjectType::EVENTPAIR.into_raw() },
3293 16387,
3294 >,
3295 >,
3296 fidl::encoding::DefaultFuchsiaResourceDialect
3297 ),
3298 }
3299 }
3300
3301 #[inline]
3302 unsafe fn decode(
3303 &mut self,
3304 decoder: &mut fidl::encoding::Decoder<
3305 '_,
3306 fidl::encoding::DefaultFuchsiaResourceDialect,
3307 >,
3308 offset: usize,
3309 _depth: fidl::encoding::Depth,
3310 ) -> fidl::Result<()> {
3311 decoder.debug_check_bounds::<Self>(offset);
3312 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3314 let padval = unsafe { (ptr as *const u64).read_unaligned() };
3315 let mask = 0xffffffff00000000u64;
3316 let maskedval = padval & mask;
3317 if maskedval != 0 {
3318 return Err(fidl::Error::NonZeroPadding {
3319 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3320 });
3321 }
3322 fidl::decode!(
3323 Status,
3324 fidl::encoding::DefaultFuchsiaResourceDialect,
3325 &mut self.status,
3326 decoder,
3327 offset + 0,
3328 _depth
3329 )?;
3330 fidl::decode!(
3331 fidl::encoding::Optional<
3332 fidl::encoding::HandleType<
3333 fidl::EventPair,
3334 { fidl::ObjectType::EVENTPAIR.into_raw() },
3335 16387,
3336 >,
3337 >,
3338 fidl::encoding::DefaultFuchsiaResourceDialect,
3339 &mut self.wake_lease,
3340 decoder,
3341 offset + 16,
3342 _depth
3343 )?;
3344 Ok(())
3345 }
3346 }
3347}