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_powersource_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct SourceGetStateChangeEventResponse {
16 pub status: i32,
17 pub handle: fidl::Event,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for SourceGetStateChangeEventResponse
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct SourceMarker;
27
28impl fidl::endpoints::ProtocolMarker for SourceMarker {
29 type Proxy = SourceProxy;
30 type RequestStream = SourceRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = SourceSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "(anonymous) Source";
35}
36
37pub trait SourceProxyInterface: Send + Sync {
38 type GetPowerInfoResponseFut: std::future::Future<Output = Result<(i32, SourceInfo), fidl::Error>>
39 + Send;
40 fn r#get_power_info(&self) -> Self::GetPowerInfoResponseFut;
41 type GetStateChangeEventResponseFut: std::future::Future<Output = Result<(i32, fidl::Event), fidl::Error>>
42 + Send;
43 fn r#get_state_change_event(&self) -> Self::GetStateChangeEventResponseFut;
44 type GetBatteryInfoResponseFut: std::future::Future<Output = Result<(i32, BatteryInfo), fidl::Error>>
45 + Send;
46 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
47}
48#[derive(Debug)]
49#[cfg(target_os = "fuchsia")]
50pub struct SourceSynchronousProxy {
51 client: fidl::client::sync::Client,
52}
53
54#[cfg(target_os = "fuchsia")]
55impl fidl::endpoints::SynchronousProxy for SourceSynchronousProxy {
56 type Proxy = SourceProxy;
57 type Protocol = SourceMarker;
58
59 fn from_channel(inner: fidl::Channel) -> Self {
60 Self::new(inner)
61 }
62
63 fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 fn as_channel(&self) -> &fidl::Channel {
68 self.client.as_channel()
69 }
70}
71
72#[cfg(target_os = "fuchsia")]
73impl SourceSynchronousProxy {
74 pub fn new(channel: fidl::Channel) -> Self {
75 let protocol_name = <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
76 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
77 }
78
79 pub fn into_channel(self) -> fidl::Channel {
80 self.client.into_channel()
81 }
82
83 pub fn wait_for_event(
86 &self,
87 deadline: zx::MonotonicInstant,
88 ) -> Result<SourceEvent, fidl::Error> {
89 SourceEvent::decode(self.client.wait_for_event(deadline)?)
90 }
91
92 pub fn r#get_power_info(
94 &self,
95 ___deadline: zx::MonotonicInstant,
96 ) -> Result<(i32, SourceInfo), fidl::Error> {
97 let _response =
98 self.client.send_query::<fidl::encoding::EmptyPayload, SourceGetPowerInfoResponse>(
99 (),
100 0x2dd7eb1cce18665d,
101 fidl::encoding::DynamicFlags::empty(),
102 ___deadline,
103 )?;
104 Ok((_response.status, _response.info))
105 }
106
107 pub fn r#get_state_change_event(
111 &self,
112 ___deadline: zx::MonotonicInstant,
113 ) -> Result<(i32, fidl::Event), fidl::Error> {
114 let _response = self
115 .client
116 .send_query::<fidl::encoding::EmptyPayload, SourceGetStateChangeEventResponse>(
117 (),
118 0x67842daecf5e7f5e,
119 fidl::encoding::DynamicFlags::empty(),
120 ___deadline,
121 )?;
122 Ok((_response.status, _response.handle))
123 }
124
125 pub fn r#get_battery_info(
127 &self,
128 ___deadline: zx::MonotonicInstant,
129 ) -> Result<(i32, BatteryInfo), fidl::Error> {
130 let _response =
131 self.client.send_query::<fidl::encoding::EmptyPayload, SourceGetBatteryInfoResponse>(
132 (),
133 0x686f3c82ad2b91cd,
134 fidl::encoding::DynamicFlags::empty(),
135 ___deadline,
136 )?;
137 Ok((_response.status, _response.info))
138 }
139}
140
141#[cfg(target_os = "fuchsia")]
142impl From<SourceSynchronousProxy> for zx::Handle {
143 fn from(value: SourceSynchronousProxy) -> Self {
144 value.into_channel().into()
145 }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl From<fidl::Channel> for SourceSynchronousProxy {
150 fn from(value: fidl::Channel) -> Self {
151 Self::new(value)
152 }
153}
154
155#[derive(Debug, Clone)]
156pub struct SourceProxy {
157 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
158}
159
160impl fidl::endpoints::Proxy for SourceProxy {
161 type Protocol = SourceMarker;
162
163 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
164 Self::new(inner)
165 }
166
167 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
168 self.client.into_channel().map_err(|client| Self { client })
169 }
170
171 fn as_channel(&self) -> &::fidl::AsyncChannel {
172 self.client.as_channel()
173 }
174}
175
176impl SourceProxy {
177 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
179 let protocol_name = <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
180 Self { client: fidl::client::Client::new(channel, protocol_name) }
181 }
182
183 pub fn take_event_stream(&self) -> SourceEventStream {
189 SourceEventStream { event_receiver: self.client.take_event_receiver() }
190 }
191
192 pub fn r#get_power_info(
194 &self,
195 ) -> fidl::client::QueryResponseFut<
196 (i32, SourceInfo),
197 fidl::encoding::DefaultFuchsiaResourceDialect,
198 > {
199 SourceProxyInterface::r#get_power_info(self)
200 }
201
202 pub fn r#get_state_change_event(
206 &self,
207 ) -> fidl::client::QueryResponseFut<
208 (i32, fidl::Event),
209 fidl::encoding::DefaultFuchsiaResourceDialect,
210 > {
211 SourceProxyInterface::r#get_state_change_event(self)
212 }
213
214 pub fn r#get_battery_info(
216 &self,
217 ) -> fidl::client::QueryResponseFut<
218 (i32, BatteryInfo),
219 fidl::encoding::DefaultFuchsiaResourceDialect,
220 > {
221 SourceProxyInterface::r#get_battery_info(self)
222 }
223}
224
225impl SourceProxyInterface for SourceProxy {
226 type GetPowerInfoResponseFut = fidl::client::QueryResponseFut<
227 (i32, SourceInfo),
228 fidl::encoding::DefaultFuchsiaResourceDialect,
229 >;
230 fn r#get_power_info(&self) -> Self::GetPowerInfoResponseFut {
231 fn _decode(
232 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
233 ) -> Result<(i32, SourceInfo), fidl::Error> {
234 let _response = fidl::client::decode_transaction_body::<
235 SourceGetPowerInfoResponse,
236 fidl::encoding::DefaultFuchsiaResourceDialect,
237 0x2dd7eb1cce18665d,
238 >(_buf?)?;
239 Ok((_response.status, _response.info))
240 }
241 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, SourceInfo)>(
242 (),
243 0x2dd7eb1cce18665d,
244 fidl::encoding::DynamicFlags::empty(),
245 _decode,
246 )
247 }
248
249 type GetStateChangeEventResponseFut = fidl::client::QueryResponseFut<
250 (i32, fidl::Event),
251 fidl::encoding::DefaultFuchsiaResourceDialect,
252 >;
253 fn r#get_state_change_event(&self) -> Self::GetStateChangeEventResponseFut {
254 fn _decode(
255 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
256 ) -> Result<(i32, fidl::Event), fidl::Error> {
257 let _response = fidl::client::decode_transaction_body::<
258 SourceGetStateChangeEventResponse,
259 fidl::encoding::DefaultFuchsiaResourceDialect,
260 0x67842daecf5e7f5e,
261 >(_buf?)?;
262 Ok((_response.status, _response.handle))
263 }
264 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, fidl::Event)>(
265 (),
266 0x67842daecf5e7f5e,
267 fidl::encoding::DynamicFlags::empty(),
268 _decode,
269 )
270 }
271
272 type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
273 (i32, BatteryInfo),
274 fidl::encoding::DefaultFuchsiaResourceDialect,
275 >;
276 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
277 fn _decode(
278 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
279 ) -> Result<(i32, BatteryInfo), fidl::Error> {
280 let _response = fidl::client::decode_transaction_body::<
281 SourceGetBatteryInfoResponse,
282 fidl::encoding::DefaultFuchsiaResourceDialect,
283 0x686f3c82ad2b91cd,
284 >(_buf?)?;
285 Ok((_response.status, _response.info))
286 }
287 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BatteryInfo)>(
288 (),
289 0x686f3c82ad2b91cd,
290 fidl::encoding::DynamicFlags::empty(),
291 _decode,
292 )
293 }
294}
295
296pub struct SourceEventStream {
297 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
298}
299
300impl std::marker::Unpin for SourceEventStream {}
301
302impl futures::stream::FusedStream for SourceEventStream {
303 fn is_terminated(&self) -> bool {
304 self.event_receiver.is_terminated()
305 }
306}
307
308impl futures::Stream for SourceEventStream {
309 type Item = Result<SourceEvent, fidl::Error>;
310
311 fn poll_next(
312 mut self: std::pin::Pin<&mut Self>,
313 cx: &mut std::task::Context<'_>,
314 ) -> std::task::Poll<Option<Self::Item>> {
315 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
316 &mut self.event_receiver,
317 cx
318 )?) {
319 Some(buf) => std::task::Poll::Ready(Some(SourceEvent::decode(buf))),
320 None => std::task::Poll::Ready(None),
321 }
322 }
323}
324
325#[derive(Debug)]
326pub enum SourceEvent {}
327
328impl SourceEvent {
329 fn decode(
331 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
332 ) -> Result<SourceEvent, fidl::Error> {
333 let (bytes, _handles) = buf.split_mut();
334 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
335 debug_assert_eq!(tx_header.tx_id, 0);
336 match tx_header.ordinal {
337 _ => Err(fidl::Error::UnknownOrdinal {
338 ordinal: tx_header.ordinal,
339 protocol_name: <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
340 }),
341 }
342 }
343}
344
345pub struct SourceRequestStream {
347 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
348 is_terminated: bool,
349}
350
351impl std::marker::Unpin for SourceRequestStream {}
352
353impl futures::stream::FusedStream for SourceRequestStream {
354 fn is_terminated(&self) -> bool {
355 self.is_terminated
356 }
357}
358
359impl fidl::endpoints::RequestStream for SourceRequestStream {
360 type Protocol = SourceMarker;
361 type ControlHandle = SourceControlHandle;
362
363 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
364 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
365 }
366
367 fn control_handle(&self) -> Self::ControlHandle {
368 SourceControlHandle { inner: self.inner.clone() }
369 }
370
371 fn into_inner(
372 self,
373 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
374 {
375 (self.inner, self.is_terminated)
376 }
377
378 fn from_inner(
379 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
380 is_terminated: bool,
381 ) -> Self {
382 Self { inner, is_terminated }
383 }
384}
385
386impl futures::Stream for SourceRequestStream {
387 type Item = Result<SourceRequest, fidl::Error>;
388
389 fn poll_next(
390 mut self: std::pin::Pin<&mut Self>,
391 cx: &mut std::task::Context<'_>,
392 ) -> std::task::Poll<Option<Self::Item>> {
393 let this = &mut *self;
394 if this.inner.check_shutdown(cx) {
395 this.is_terminated = true;
396 return std::task::Poll::Ready(None);
397 }
398 if this.is_terminated {
399 panic!("polled SourceRequestStream after completion");
400 }
401 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
402 |bytes, handles| {
403 match this.inner.channel().read_etc(cx, bytes, handles) {
404 std::task::Poll::Ready(Ok(())) => {}
405 std::task::Poll::Pending => return std::task::Poll::Pending,
406 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
407 this.is_terminated = true;
408 return std::task::Poll::Ready(None);
409 }
410 std::task::Poll::Ready(Err(e)) => {
411 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
412 e.into(),
413 ))))
414 }
415 }
416
417 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
419
420 std::task::Poll::Ready(Some(match header.ordinal {
421 0x2dd7eb1cce18665d => {
422 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
423 let mut req = fidl::new_empty!(
424 fidl::encoding::EmptyPayload,
425 fidl::encoding::DefaultFuchsiaResourceDialect
426 );
427 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
428 let control_handle = SourceControlHandle { inner: this.inner.clone() };
429 Ok(SourceRequest::GetPowerInfo {
430 responder: SourceGetPowerInfoResponder {
431 control_handle: std::mem::ManuallyDrop::new(control_handle),
432 tx_id: header.tx_id,
433 },
434 })
435 }
436 0x67842daecf5e7f5e => {
437 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
438 let mut req = fidl::new_empty!(
439 fidl::encoding::EmptyPayload,
440 fidl::encoding::DefaultFuchsiaResourceDialect
441 );
442 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
443 let control_handle = SourceControlHandle { inner: this.inner.clone() };
444 Ok(SourceRequest::GetStateChangeEvent {
445 responder: SourceGetStateChangeEventResponder {
446 control_handle: std::mem::ManuallyDrop::new(control_handle),
447 tx_id: header.tx_id,
448 },
449 })
450 }
451 0x686f3c82ad2b91cd => {
452 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
453 let mut req = fidl::new_empty!(
454 fidl::encoding::EmptyPayload,
455 fidl::encoding::DefaultFuchsiaResourceDialect
456 );
457 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
458 let control_handle = SourceControlHandle { inner: this.inner.clone() };
459 Ok(SourceRequest::GetBatteryInfo {
460 responder: SourceGetBatteryInfoResponder {
461 control_handle: std::mem::ManuallyDrop::new(control_handle),
462 tx_id: header.tx_id,
463 },
464 })
465 }
466 _ => Err(fidl::Error::UnknownOrdinal {
467 ordinal: header.ordinal,
468 protocol_name:
469 <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
470 }),
471 }))
472 },
473 )
474 }
475}
476
477#[derive(Debug)]
478pub enum SourceRequest {
479 GetPowerInfo { responder: SourceGetPowerInfoResponder },
481 GetStateChangeEvent { responder: SourceGetStateChangeEventResponder },
485 GetBatteryInfo { responder: SourceGetBatteryInfoResponder },
487}
488
489impl SourceRequest {
490 #[allow(irrefutable_let_patterns)]
491 pub fn into_get_power_info(self) -> Option<(SourceGetPowerInfoResponder)> {
492 if let SourceRequest::GetPowerInfo { responder } = self {
493 Some((responder))
494 } else {
495 None
496 }
497 }
498
499 #[allow(irrefutable_let_patterns)]
500 pub fn into_get_state_change_event(self) -> Option<(SourceGetStateChangeEventResponder)> {
501 if let SourceRequest::GetStateChangeEvent { responder } = self {
502 Some((responder))
503 } else {
504 None
505 }
506 }
507
508 #[allow(irrefutable_let_patterns)]
509 pub fn into_get_battery_info(self) -> Option<(SourceGetBatteryInfoResponder)> {
510 if let SourceRequest::GetBatteryInfo { responder } = self {
511 Some((responder))
512 } else {
513 None
514 }
515 }
516
517 pub fn method_name(&self) -> &'static str {
519 match *self {
520 SourceRequest::GetPowerInfo { .. } => "get_power_info",
521 SourceRequest::GetStateChangeEvent { .. } => "get_state_change_event",
522 SourceRequest::GetBatteryInfo { .. } => "get_battery_info",
523 }
524 }
525}
526
527#[derive(Debug, Clone)]
528pub struct SourceControlHandle {
529 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
530}
531
532impl fidl::endpoints::ControlHandle for SourceControlHandle {
533 fn shutdown(&self) {
534 self.inner.shutdown()
535 }
536 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
537 self.inner.shutdown_with_epitaph(status)
538 }
539
540 fn is_closed(&self) -> bool {
541 self.inner.channel().is_closed()
542 }
543 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
544 self.inner.channel().on_closed()
545 }
546
547 #[cfg(target_os = "fuchsia")]
548 fn signal_peer(
549 &self,
550 clear_mask: zx::Signals,
551 set_mask: zx::Signals,
552 ) -> Result<(), zx_status::Status> {
553 use fidl::Peered;
554 self.inner.channel().signal_peer(clear_mask, set_mask)
555 }
556}
557
558impl SourceControlHandle {}
559
560#[must_use = "FIDL methods require a response to be sent"]
561#[derive(Debug)]
562pub struct SourceGetPowerInfoResponder {
563 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
564 tx_id: u32,
565}
566
567impl std::ops::Drop for SourceGetPowerInfoResponder {
571 fn drop(&mut self) {
572 self.control_handle.shutdown();
573 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
575 }
576}
577
578impl fidl::endpoints::Responder for SourceGetPowerInfoResponder {
579 type ControlHandle = SourceControlHandle;
580
581 fn control_handle(&self) -> &SourceControlHandle {
582 &self.control_handle
583 }
584
585 fn drop_without_shutdown(mut self) {
586 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
588 std::mem::forget(self);
590 }
591}
592
593impl SourceGetPowerInfoResponder {
594 pub fn send(self, mut status: i32, mut info: &SourceInfo) -> Result<(), fidl::Error> {
598 let _result = self.send_raw(status, info);
599 if _result.is_err() {
600 self.control_handle.shutdown();
601 }
602 self.drop_without_shutdown();
603 _result
604 }
605
606 pub fn send_no_shutdown_on_err(
608 self,
609 mut status: i32,
610 mut info: &SourceInfo,
611 ) -> Result<(), fidl::Error> {
612 let _result = self.send_raw(status, info);
613 self.drop_without_shutdown();
614 _result
615 }
616
617 fn send_raw(&self, mut status: i32, mut info: &SourceInfo) -> Result<(), fidl::Error> {
618 self.control_handle.inner.send::<SourceGetPowerInfoResponse>(
619 (status, info),
620 self.tx_id,
621 0x2dd7eb1cce18665d,
622 fidl::encoding::DynamicFlags::empty(),
623 )
624 }
625}
626
627#[must_use = "FIDL methods require a response to be sent"]
628#[derive(Debug)]
629pub struct SourceGetStateChangeEventResponder {
630 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
631 tx_id: u32,
632}
633
634impl std::ops::Drop for SourceGetStateChangeEventResponder {
638 fn drop(&mut self) {
639 self.control_handle.shutdown();
640 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
642 }
643}
644
645impl fidl::endpoints::Responder for SourceGetStateChangeEventResponder {
646 type ControlHandle = SourceControlHandle;
647
648 fn control_handle(&self) -> &SourceControlHandle {
649 &self.control_handle
650 }
651
652 fn drop_without_shutdown(mut self) {
653 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
655 std::mem::forget(self);
657 }
658}
659
660impl SourceGetStateChangeEventResponder {
661 pub fn send(self, mut status: i32, mut handle: fidl::Event) -> Result<(), fidl::Error> {
665 let _result = self.send_raw(status, handle);
666 if _result.is_err() {
667 self.control_handle.shutdown();
668 }
669 self.drop_without_shutdown();
670 _result
671 }
672
673 pub fn send_no_shutdown_on_err(
675 self,
676 mut status: i32,
677 mut handle: fidl::Event,
678 ) -> Result<(), fidl::Error> {
679 let _result = self.send_raw(status, handle);
680 self.drop_without_shutdown();
681 _result
682 }
683
684 fn send_raw(&self, mut status: i32, mut handle: fidl::Event) -> Result<(), fidl::Error> {
685 self.control_handle.inner.send::<SourceGetStateChangeEventResponse>(
686 (status, handle),
687 self.tx_id,
688 0x67842daecf5e7f5e,
689 fidl::encoding::DynamicFlags::empty(),
690 )
691 }
692}
693
694#[must_use = "FIDL methods require a response to be sent"]
695#[derive(Debug)]
696pub struct SourceGetBatteryInfoResponder {
697 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
698 tx_id: u32,
699}
700
701impl std::ops::Drop for SourceGetBatteryInfoResponder {
705 fn drop(&mut self) {
706 self.control_handle.shutdown();
707 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
709 }
710}
711
712impl fidl::endpoints::Responder for SourceGetBatteryInfoResponder {
713 type ControlHandle = SourceControlHandle;
714
715 fn control_handle(&self) -> &SourceControlHandle {
716 &self.control_handle
717 }
718
719 fn drop_without_shutdown(mut self) {
720 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
722 std::mem::forget(self);
724 }
725}
726
727impl SourceGetBatteryInfoResponder {
728 pub fn send(self, mut status: i32, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
732 let _result = self.send_raw(status, info);
733 if _result.is_err() {
734 self.control_handle.shutdown();
735 }
736 self.drop_without_shutdown();
737 _result
738 }
739
740 pub fn send_no_shutdown_on_err(
742 self,
743 mut status: i32,
744 mut info: &BatteryInfo,
745 ) -> Result<(), fidl::Error> {
746 let _result = self.send_raw(status, info);
747 self.drop_without_shutdown();
748 _result
749 }
750
751 fn send_raw(&self, mut status: i32, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
752 self.control_handle.inner.send::<SourceGetBatteryInfoResponse>(
753 (status, info),
754 self.tx_id,
755 0x686f3c82ad2b91cd,
756 fidl::encoding::DynamicFlags::empty(),
757 )
758 }
759}
760
761#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
762pub struct ServiceMarker;
763
764#[cfg(target_os = "fuchsia")]
765impl fidl::endpoints::ServiceMarker for ServiceMarker {
766 type Proxy = ServiceProxy;
767 type Request = ServiceRequest;
768 const SERVICE_NAME: &'static str = "fuchsia.hardware.powersource.Service";
769}
770
771#[cfg(target_os = "fuchsia")]
774pub enum ServiceRequest {
775 Source(SourceRequestStream),
776}
777
778#[cfg(target_os = "fuchsia")]
779impl fidl::endpoints::ServiceRequest for ServiceRequest {
780 type Service = ServiceMarker;
781
782 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
783 match name {
784 "source" => Self::Source(
785 <SourceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
786 ),
787 _ => panic!("no such member protocol name for service Service"),
788 }
789 }
790
791 fn member_names() -> &'static [&'static str] {
792 &["source"]
793 }
794}
795#[cfg(target_os = "fuchsia")]
796pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
797
798#[cfg(target_os = "fuchsia")]
799impl fidl::endpoints::ServiceProxy for ServiceProxy {
800 type Service = ServiceMarker;
801
802 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
803 Self(opener)
804 }
805}
806
807#[cfg(target_os = "fuchsia")]
808impl ServiceProxy {
809 pub fn connect_to_source(&self) -> Result<SourceProxy, fidl::Error> {
810 let (proxy, server_end) = fidl::endpoints::create_proxy::<SourceMarker>();
811 self.connect_channel_to_source(server_end)?;
812 Ok(proxy)
813 }
814
815 pub fn connect_to_source_sync(&self) -> Result<SourceSynchronousProxy, fidl::Error> {
818 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SourceMarker>();
819 self.connect_channel_to_source(server_end)?;
820 Ok(proxy)
821 }
822
823 pub fn connect_channel_to_source(
826 &self,
827 server_end: fidl::endpoints::ServerEnd<SourceMarker>,
828 ) -> Result<(), fidl::Error> {
829 self.0.open_member("source", server_end.into_channel())
830 }
831
832 pub fn instance_name(&self) -> &str {
833 self.0.instance_name()
834 }
835}
836
837mod internal {
838 use super::*;
839
840 impl fidl::encoding::ResourceTypeMarker for SourceGetStateChangeEventResponse {
841 type Borrowed<'a> = &'a mut Self;
842 fn take_or_borrow<'a>(
843 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
844 ) -> Self::Borrowed<'a> {
845 value
846 }
847 }
848
849 unsafe impl fidl::encoding::TypeMarker for SourceGetStateChangeEventResponse {
850 type Owned = Self;
851
852 #[inline(always)]
853 fn inline_align(_context: fidl::encoding::Context) -> usize {
854 4
855 }
856
857 #[inline(always)]
858 fn inline_size(_context: fidl::encoding::Context) -> usize {
859 8
860 }
861 }
862
863 unsafe impl
864 fidl::encoding::Encode<
865 SourceGetStateChangeEventResponse,
866 fidl::encoding::DefaultFuchsiaResourceDialect,
867 > for &mut SourceGetStateChangeEventResponse
868 {
869 #[inline]
870 unsafe fn encode(
871 self,
872 encoder: &mut fidl::encoding::Encoder<
873 '_,
874 fidl::encoding::DefaultFuchsiaResourceDialect,
875 >,
876 offset: usize,
877 _depth: fidl::encoding::Depth,
878 ) -> fidl::Result<()> {
879 encoder.debug_check_bounds::<SourceGetStateChangeEventResponse>(offset);
880 fidl::encoding::Encode::<
882 SourceGetStateChangeEventResponse,
883 fidl::encoding::DefaultFuchsiaResourceDialect,
884 >::encode(
885 (
886 <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
887 <fidl::encoding::HandleType<
888 fidl::Event,
889 { fidl::ObjectType::EVENT.into_raw() },
890 16384,
891 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
892 &mut self.handle
893 ),
894 ),
895 encoder,
896 offset,
897 _depth,
898 )
899 }
900 }
901 unsafe impl<
902 T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
903 T1: fidl::encoding::Encode<
904 fidl::encoding::HandleType<
905 fidl::Event,
906 { fidl::ObjectType::EVENT.into_raw() },
907 16384,
908 >,
909 fidl::encoding::DefaultFuchsiaResourceDialect,
910 >,
911 >
912 fidl::encoding::Encode<
913 SourceGetStateChangeEventResponse,
914 fidl::encoding::DefaultFuchsiaResourceDialect,
915 > for (T0, T1)
916 {
917 #[inline]
918 unsafe fn encode(
919 self,
920 encoder: &mut fidl::encoding::Encoder<
921 '_,
922 fidl::encoding::DefaultFuchsiaResourceDialect,
923 >,
924 offset: usize,
925 depth: fidl::encoding::Depth,
926 ) -> fidl::Result<()> {
927 encoder.debug_check_bounds::<SourceGetStateChangeEventResponse>(offset);
928 self.0.encode(encoder, offset + 0, depth)?;
932 self.1.encode(encoder, offset + 4, depth)?;
933 Ok(())
934 }
935 }
936
937 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
938 for SourceGetStateChangeEventResponse
939 {
940 #[inline(always)]
941 fn new_empty() -> Self {
942 Self {
943 status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
944 handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 16384>, fidl::encoding::DefaultFuchsiaResourceDialect),
945 }
946 }
947
948 #[inline]
949 unsafe fn decode(
950 &mut self,
951 decoder: &mut fidl::encoding::Decoder<
952 '_,
953 fidl::encoding::DefaultFuchsiaResourceDialect,
954 >,
955 offset: usize,
956 _depth: fidl::encoding::Depth,
957 ) -> fidl::Result<()> {
958 decoder.debug_check_bounds::<Self>(offset);
959 fidl::decode!(
961 i32,
962 fidl::encoding::DefaultFuchsiaResourceDialect,
963 &mut self.status,
964 decoder,
965 offset + 0,
966 _depth
967 )?;
968 fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 16384>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.handle, decoder, offset + 4, _depth)?;
969 Ok(())
970 }
971 }
972}