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#[cfg(target_os = "fuchsia")]
156impl fidl::endpoints::FromClient for SourceSynchronousProxy {
157 type Protocol = SourceMarker;
158
159 fn from_client(value: fidl::endpoints::ClientEnd<SourceMarker>) -> Self {
160 Self::new(value.into_channel())
161 }
162}
163
164#[derive(Debug, Clone)]
165pub struct SourceProxy {
166 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
167}
168
169impl fidl::endpoints::Proxy for SourceProxy {
170 type Protocol = SourceMarker;
171
172 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
173 Self::new(inner)
174 }
175
176 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
177 self.client.into_channel().map_err(|client| Self { client })
178 }
179
180 fn as_channel(&self) -> &::fidl::AsyncChannel {
181 self.client.as_channel()
182 }
183}
184
185impl SourceProxy {
186 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
188 let protocol_name = <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
189 Self { client: fidl::client::Client::new(channel, protocol_name) }
190 }
191
192 pub fn take_event_stream(&self) -> SourceEventStream {
198 SourceEventStream { event_receiver: self.client.take_event_receiver() }
199 }
200
201 pub fn r#get_power_info(
203 &self,
204 ) -> fidl::client::QueryResponseFut<
205 (i32, SourceInfo),
206 fidl::encoding::DefaultFuchsiaResourceDialect,
207 > {
208 SourceProxyInterface::r#get_power_info(self)
209 }
210
211 pub fn r#get_state_change_event(
215 &self,
216 ) -> fidl::client::QueryResponseFut<
217 (i32, fidl::Event),
218 fidl::encoding::DefaultFuchsiaResourceDialect,
219 > {
220 SourceProxyInterface::r#get_state_change_event(self)
221 }
222
223 pub fn r#get_battery_info(
225 &self,
226 ) -> fidl::client::QueryResponseFut<
227 (i32, BatteryInfo),
228 fidl::encoding::DefaultFuchsiaResourceDialect,
229 > {
230 SourceProxyInterface::r#get_battery_info(self)
231 }
232}
233
234impl SourceProxyInterface for SourceProxy {
235 type GetPowerInfoResponseFut = fidl::client::QueryResponseFut<
236 (i32, SourceInfo),
237 fidl::encoding::DefaultFuchsiaResourceDialect,
238 >;
239 fn r#get_power_info(&self) -> Self::GetPowerInfoResponseFut {
240 fn _decode(
241 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
242 ) -> Result<(i32, SourceInfo), fidl::Error> {
243 let _response = fidl::client::decode_transaction_body::<
244 SourceGetPowerInfoResponse,
245 fidl::encoding::DefaultFuchsiaResourceDialect,
246 0x2dd7eb1cce18665d,
247 >(_buf?)?;
248 Ok((_response.status, _response.info))
249 }
250 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, SourceInfo)>(
251 (),
252 0x2dd7eb1cce18665d,
253 fidl::encoding::DynamicFlags::empty(),
254 _decode,
255 )
256 }
257
258 type GetStateChangeEventResponseFut = fidl::client::QueryResponseFut<
259 (i32, fidl::Event),
260 fidl::encoding::DefaultFuchsiaResourceDialect,
261 >;
262 fn r#get_state_change_event(&self) -> Self::GetStateChangeEventResponseFut {
263 fn _decode(
264 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
265 ) -> Result<(i32, fidl::Event), fidl::Error> {
266 let _response = fidl::client::decode_transaction_body::<
267 SourceGetStateChangeEventResponse,
268 fidl::encoding::DefaultFuchsiaResourceDialect,
269 0x67842daecf5e7f5e,
270 >(_buf?)?;
271 Ok((_response.status, _response.handle))
272 }
273 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, fidl::Event)>(
274 (),
275 0x67842daecf5e7f5e,
276 fidl::encoding::DynamicFlags::empty(),
277 _decode,
278 )
279 }
280
281 type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
282 (i32, BatteryInfo),
283 fidl::encoding::DefaultFuchsiaResourceDialect,
284 >;
285 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
286 fn _decode(
287 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
288 ) -> Result<(i32, BatteryInfo), fidl::Error> {
289 let _response = fidl::client::decode_transaction_body::<
290 SourceGetBatteryInfoResponse,
291 fidl::encoding::DefaultFuchsiaResourceDialect,
292 0x686f3c82ad2b91cd,
293 >(_buf?)?;
294 Ok((_response.status, _response.info))
295 }
296 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BatteryInfo)>(
297 (),
298 0x686f3c82ad2b91cd,
299 fidl::encoding::DynamicFlags::empty(),
300 _decode,
301 )
302 }
303}
304
305pub struct SourceEventStream {
306 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
307}
308
309impl std::marker::Unpin for SourceEventStream {}
310
311impl futures::stream::FusedStream for SourceEventStream {
312 fn is_terminated(&self) -> bool {
313 self.event_receiver.is_terminated()
314 }
315}
316
317impl futures::Stream for SourceEventStream {
318 type Item = Result<SourceEvent, fidl::Error>;
319
320 fn poll_next(
321 mut self: std::pin::Pin<&mut Self>,
322 cx: &mut std::task::Context<'_>,
323 ) -> std::task::Poll<Option<Self::Item>> {
324 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
325 &mut self.event_receiver,
326 cx
327 )?) {
328 Some(buf) => std::task::Poll::Ready(Some(SourceEvent::decode(buf))),
329 None => std::task::Poll::Ready(None),
330 }
331 }
332}
333
334#[derive(Debug)]
335pub enum SourceEvent {}
336
337impl SourceEvent {
338 fn decode(
340 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
341 ) -> Result<SourceEvent, fidl::Error> {
342 let (bytes, _handles) = buf.split_mut();
343 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
344 debug_assert_eq!(tx_header.tx_id, 0);
345 match tx_header.ordinal {
346 _ => Err(fidl::Error::UnknownOrdinal {
347 ordinal: tx_header.ordinal,
348 protocol_name: <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
349 }),
350 }
351 }
352}
353
354pub struct SourceRequestStream {
356 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
357 is_terminated: bool,
358}
359
360impl std::marker::Unpin for SourceRequestStream {}
361
362impl futures::stream::FusedStream for SourceRequestStream {
363 fn is_terminated(&self) -> bool {
364 self.is_terminated
365 }
366}
367
368impl fidl::endpoints::RequestStream for SourceRequestStream {
369 type Protocol = SourceMarker;
370 type ControlHandle = SourceControlHandle;
371
372 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
373 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
374 }
375
376 fn control_handle(&self) -> Self::ControlHandle {
377 SourceControlHandle { inner: self.inner.clone() }
378 }
379
380 fn into_inner(
381 self,
382 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
383 {
384 (self.inner, self.is_terminated)
385 }
386
387 fn from_inner(
388 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
389 is_terminated: bool,
390 ) -> Self {
391 Self { inner, is_terminated }
392 }
393}
394
395impl futures::Stream for SourceRequestStream {
396 type Item = Result<SourceRequest, fidl::Error>;
397
398 fn poll_next(
399 mut self: std::pin::Pin<&mut Self>,
400 cx: &mut std::task::Context<'_>,
401 ) -> std::task::Poll<Option<Self::Item>> {
402 let this = &mut *self;
403 if this.inner.check_shutdown(cx) {
404 this.is_terminated = true;
405 return std::task::Poll::Ready(None);
406 }
407 if this.is_terminated {
408 panic!("polled SourceRequestStream after completion");
409 }
410 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
411 |bytes, handles| {
412 match this.inner.channel().read_etc(cx, bytes, handles) {
413 std::task::Poll::Ready(Ok(())) => {}
414 std::task::Poll::Pending => return std::task::Poll::Pending,
415 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
416 this.is_terminated = true;
417 return std::task::Poll::Ready(None);
418 }
419 std::task::Poll::Ready(Err(e)) => {
420 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
421 e.into(),
422 ))))
423 }
424 }
425
426 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
428
429 std::task::Poll::Ready(Some(match header.ordinal {
430 0x2dd7eb1cce18665d => {
431 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
432 let mut req = fidl::new_empty!(
433 fidl::encoding::EmptyPayload,
434 fidl::encoding::DefaultFuchsiaResourceDialect
435 );
436 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
437 let control_handle = SourceControlHandle { inner: this.inner.clone() };
438 Ok(SourceRequest::GetPowerInfo {
439 responder: SourceGetPowerInfoResponder {
440 control_handle: std::mem::ManuallyDrop::new(control_handle),
441 tx_id: header.tx_id,
442 },
443 })
444 }
445 0x67842daecf5e7f5e => {
446 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
447 let mut req = fidl::new_empty!(
448 fidl::encoding::EmptyPayload,
449 fidl::encoding::DefaultFuchsiaResourceDialect
450 );
451 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
452 let control_handle = SourceControlHandle { inner: this.inner.clone() };
453 Ok(SourceRequest::GetStateChangeEvent {
454 responder: SourceGetStateChangeEventResponder {
455 control_handle: std::mem::ManuallyDrop::new(control_handle),
456 tx_id: header.tx_id,
457 },
458 })
459 }
460 0x686f3c82ad2b91cd => {
461 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
462 let mut req = fidl::new_empty!(
463 fidl::encoding::EmptyPayload,
464 fidl::encoding::DefaultFuchsiaResourceDialect
465 );
466 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
467 let control_handle = SourceControlHandle { inner: this.inner.clone() };
468 Ok(SourceRequest::GetBatteryInfo {
469 responder: SourceGetBatteryInfoResponder {
470 control_handle: std::mem::ManuallyDrop::new(control_handle),
471 tx_id: header.tx_id,
472 },
473 })
474 }
475 _ => Err(fidl::Error::UnknownOrdinal {
476 ordinal: header.ordinal,
477 protocol_name:
478 <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
479 }),
480 }))
481 },
482 )
483 }
484}
485
486#[derive(Debug)]
487pub enum SourceRequest {
488 GetPowerInfo { responder: SourceGetPowerInfoResponder },
490 GetStateChangeEvent { responder: SourceGetStateChangeEventResponder },
494 GetBatteryInfo { responder: SourceGetBatteryInfoResponder },
496}
497
498impl SourceRequest {
499 #[allow(irrefutable_let_patterns)]
500 pub fn into_get_power_info(self) -> Option<(SourceGetPowerInfoResponder)> {
501 if let SourceRequest::GetPowerInfo { responder } = self {
502 Some((responder))
503 } else {
504 None
505 }
506 }
507
508 #[allow(irrefutable_let_patterns)]
509 pub fn into_get_state_change_event(self) -> Option<(SourceGetStateChangeEventResponder)> {
510 if let SourceRequest::GetStateChangeEvent { responder } = self {
511 Some((responder))
512 } else {
513 None
514 }
515 }
516
517 #[allow(irrefutable_let_patterns)]
518 pub fn into_get_battery_info(self) -> Option<(SourceGetBatteryInfoResponder)> {
519 if let SourceRequest::GetBatteryInfo { responder } = self {
520 Some((responder))
521 } else {
522 None
523 }
524 }
525
526 pub fn method_name(&self) -> &'static str {
528 match *self {
529 SourceRequest::GetPowerInfo { .. } => "get_power_info",
530 SourceRequest::GetStateChangeEvent { .. } => "get_state_change_event",
531 SourceRequest::GetBatteryInfo { .. } => "get_battery_info",
532 }
533 }
534}
535
536#[derive(Debug, Clone)]
537pub struct SourceControlHandle {
538 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
539}
540
541impl fidl::endpoints::ControlHandle for SourceControlHandle {
542 fn shutdown(&self) {
543 self.inner.shutdown()
544 }
545 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
546 self.inner.shutdown_with_epitaph(status)
547 }
548
549 fn is_closed(&self) -> bool {
550 self.inner.channel().is_closed()
551 }
552 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
553 self.inner.channel().on_closed()
554 }
555
556 #[cfg(target_os = "fuchsia")]
557 fn signal_peer(
558 &self,
559 clear_mask: zx::Signals,
560 set_mask: zx::Signals,
561 ) -> Result<(), zx_status::Status> {
562 use fidl::Peered;
563 self.inner.channel().signal_peer(clear_mask, set_mask)
564 }
565}
566
567impl SourceControlHandle {}
568
569#[must_use = "FIDL methods require a response to be sent"]
570#[derive(Debug)]
571pub struct SourceGetPowerInfoResponder {
572 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
573 tx_id: u32,
574}
575
576impl std::ops::Drop for SourceGetPowerInfoResponder {
580 fn drop(&mut self) {
581 self.control_handle.shutdown();
582 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
584 }
585}
586
587impl fidl::endpoints::Responder for SourceGetPowerInfoResponder {
588 type ControlHandle = SourceControlHandle;
589
590 fn control_handle(&self) -> &SourceControlHandle {
591 &self.control_handle
592 }
593
594 fn drop_without_shutdown(mut self) {
595 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
597 std::mem::forget(self);
599 }
600}
601
602impl SourceGetPowerInfoResponder {
603 pub fn send(self, mut status: i32, mut info: &SourceInfo) -> Result<(), fidl::Error> {
607 let _result = self.send_raw(status, info);
608 if _result.is_err() {
609 self.control_handle.shutdown();
610 }
611 self.drop_without_shutdown();
612 _result
613 }
614
615 pub fn send_no_shutdown_on_err(
617 self,
618 mut status: i32,
619 mut info: &SourceInfo,
620 ) -> Result<(), fidl::Error> {
621 let _result = self.send_raw(status, info);
622 self.drop_without_shutdown();
623 _result
624 }
625
626 fn send_raw(&self, mut status: i32, mut info: &SourceInfo) -> Result<(), fidl::Error> {
627 self.control_handle.inner.send::<SourceGetPowerInfoResponse>(
628 (status, info),
629 self.tx_id,
630 0x2dd7eb1cce18665d,
631 fidl::encoding::DynamicFlags::empty(),
632 )
633 }
634}
635
636#[must_use = "FIDL methods require a response to be sent"]
637#[derive(Debug)]
638pub struct SourceGetStateChangeEventResponder {
639 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
640 tx_id: u32,
641}
642
643impl std::ops::Drop for SourceGetStateChangeEventResponder {
647 fn drop(&mut self) {
648 self.control_handle.shutdown();
649 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
651 }
652}
653
654impl fidl::endpoints::Responder for SourceGetStateChangeEventResponder {
655 type ControlHandle = SourceControlHandle;
656
657 fn control_handle(&self) -> &SourceControlHandle {
658 &self.control_handle
659 }
660
661 fn drop_without_shutdown(mut self) {
662 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
664 std::mem::forget(self);
666 }
667}
668
669impl SourceGetStateChangeEventResponder {
670 pub fn send(self, mut status: i32, mut handle: fidl::Event) -> Result<(), fidl::Error> {
674 let _result = self.send_raw(status, handle);
675 if _result.is_err() {
676 self.control_handle.shutdown();
677 }
678 self.drop_without_shutdown();
679 _result
680 }
681
682 pub fn send_no_shutdown_on_err(
684 self,
685 mut status: i32,
686 mut handle: fidl::Event,
687 ) -> Result<(), fidl::Error> {
688 let _result = self.send_raw(status, handle);
689 self.drop_without_shutdown();
690 _result
691 }
692
693 fn send_raw(&self, mut status: i32, mut handle: fidl::Event) -> Result<(), fidl::Error> {
694 self.control_handle.inner.send::<SourceGetStateChangeEventResponse>(
695 (status, handle),
696 self.tx_id,
697 0x67842daecf5e7f5e,
698 fidl::encoding::DynamicFlags::empty(),
699 )
700 }
701}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct SourceGetBatteryInfoResponder {
706 control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
707 tx_id: u32,
708}
709
710impl std::ops::Drop for SourceGetBatteryInfoResponder {
714 fn drop(&mut self) {
715 self.control_handle.shutdown();
716 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718 }
719}
720
721impl fidl::endpoints::Responder for SourceGetBatteryInfoResponder {
722 type ControlHandle = SourceControlHandle;
723
724 fn control_handle(&self) -> &SourceControlHandle {
725 &self.control_handle
726 }
727
728 fn drop_without_shutdown(mut self) {
729 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731 std::mem::forget(self);
733 }
734}
735
736impl SourceGetBatteryInfoResponder {
737 pub fn send(self, mut status: i32, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
741 let _result = self.send_raw(status, info);
742 if _result.is_err() {
743 self.control_handle.shutdown();
744 }
745 self.drop_without_shutdown();
746 _result
747 }
748
749 pub fn send_no_shutdown_on_err(
751 self,
752 mut status: i32,
753 mut info: &BatteryInfo,
754 ) -> Result<(), fidl::Error> {
755 let _result = self.send_raw(status, info);
756 self.drop_without_shutdown();
757 _result
758 }
759
760 fn send_raw(&self, mut status: i32, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
761 self.control_handle.inner.send::<SourceGetBatteryInfoResponse>(
762 (status, info),
763 self.tx_id,
764 0x686f3c82ad2b91cd,
765 fidl::encoding::DynamicFlags::empty(),
766 )
767 }
768}
769
770#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
771pub struct ServiceMarker;
772
773#[cfg(target_os = "fuchsia")]
774impl fidl::endpoints::ServiceMarker for ServiceMarker {
775 type Proxy = ServiceProxy;
776 type Request = ServiceRequest;
777 const SERVICE_NAME: &'static str = "fuchsia.hardware.powersource.Service";
778}
779
780#[cfg(target_os = "fuchsia")]
783pub enum ServiceRequest {
784 Source(SourceRequestStream),
785}
786
787#[cfg(target_os = "fuchsia")]
788impl fidl::endpoints::ServiceRequest for ServiceRequest {
789 type Service = ServiceMarker;
790
791 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
792 match name {
793 "source" => Self::Source(
794 <SourceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
795 ),
796 _ => panic!("no such member protocol name for service Service"),
797 }
798 }
799
800 fn member_names() -> &'static [&'static str] {
801 &["source"]
802 }
803}
804#[cfg(target_os = "fuchsia")]
805pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
806
807#[cfg(target_os = "fuchsia")]
808impl fidl::endpoints::ServiceProxy for ServiceProxy {
809 type Service = ServiceMarker;
810
811 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
812 Self(opener)
813 }
814}
815
816#[cfg(target_os = "fuchsia")]
817impl ServiceProxy {
818 pub fn connect_to_source(&self) -> Result<SourceProxy, fidl::Error> {
819 let (proxy, server_end) = fidl::endpoints::create_proxy::<SourceMarker>();
820 self.connect_channel_to_source(server_end)?;
821 Ok(proxy)
822 }
823
824 pub fn connect_to_source_sync(&self) -> Result<SourceSynchronousProxy, fidl::Error> {
827 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SourceMarker>();
828 self.connect_channel_to_source(server_end)?;
829 Ok(proxy)
830 }
831
832 pub fn connect_channel_to_source(
835 &self,
836 server_end: fidl::endpoints::ServerEnd<SourceMarker>,
837 ) -> Result<(), fidl::Error> {
838 self.0.open_member("source", server_end.into_channel())
839 }
840
841 pub fn instance_name(&self) -> &str {
842 self.0.instance_name()
843 }
844}
845
846mod internal {
847 use super::*;
848
849 impl fidl::encoding::ResourceTypeMarker for SourceGetStateChangeEventResponse {
850 type Borrowed<'a> = &'a mut Self;
851 fn take_or_borrow<'a>(
852 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
853 ) -> Self::Borrowed<'a> {
854 value
855 }
856 }
857
858 unsafe impl fidl::encoding::TypeMarker for SourceGetStateChangeEventResponse {
859 type Owned = Self;
860
861 #[inline(always)]
862 fn inline_align(_context: fidl::encoding::Context) -> usize {
863 4
864 }
865
866 #[inline(always)]
867 fn inline_size(_context: fidl::encoding::Context) -> usize {
868 8
869 }
870 }
871
872 unsafe impl
873 fidl::encoding::Encode<
874 SourceGetStateChangeEventResponse,
875 fidl::encoding::DefaultFuchsiaResourceDialect,
876 > for &mut SourceGetStateChangeEventResponse
877 {
878 #[inline]
879 unsafe fn encode(
880 self,
881 encoder: &mut fidl::encoding::Encoder<
882 '_,
883 fidl::encoding::DefaultFuchsiaResourceDialect,
884 >,
885 offset: usize,
886 _depth: fidl::encoding::Depth,
887 ) -> fidl::Result<()> {
888 encoder.debug_check_bounds::<SourceGetStateChangeEventResponse>(offset);
889 fidl::encoding::Encode::<
891 SourceGetStateChangeEventResponse,
892 fidl::encoding::DefaultFuchsiaResourceDialect,
893 >::encode(
894 (
895 <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
896 <fidl::encoding::HandleType<
897 fidl::Event,
898 { fidl::ObjectType::EVENT.into_raw() },
899 16384,
900 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
901 &mut self.handle
902 ),
903 ),
904 encoder,
905 offset,
906 _depth,
907 )
908 }
909 }
910 unsafe impl<
911 T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
912 T1: fidl::encoding::Encode<
913 fidl::encoding::HandleType<
914 fidl::Event,
915 { fidl::ObjectType::EVENT.into_raw() },
916 16384,
917 >,
918 fidl::encoding::DefaultFuchsiaResourceDialect,
919 >,
920 >
921 fidl::encoding::Encode<
922 SourceGetStateChangeEventResponse,
923 fidl::encoding::DefaultFuchsiaResourceDialect,
924 > for (T0, T1)
925 {
926 #[inline]
927 unsafe fn encode(
928 self,
929 encoder: &mut fidl::encoding::Encoder<
930 '_,
931 fidl::encoding::DefaultFuchsiaResourceDialect,
932 >,
933 offset: usize,
934 depth: fidl::encoding::Depth,
935 ) -> fidl::Result<()> {
936 encoder.debug_check_bounds::<SourceGetStateChangeEventResponse>(offset);
937 self.0.encode(encoder, offset + 0, depth)?;
941 self.1.encode(encoder, offset + 4, depth)?;
942 Ok(())
943 }
944 }
945
946 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
947 for SourceGetStateChangeEventResponse
948 {
949 #[inline(always)]
950 fn new_empty() -> Self {
951 Self {
952 status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
953 handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 16384>, fidl::encoding::DefaultFuchsiaResourceDialect),
954 }
955 }
956
957 #[inline]
958 unsafe fn decode(
959 &mut self,
960 decoder: &mut fidl::encoding::Decoder<
961 '_,
962 fidl::encoding::DefaultFuchsiaResourceDialect,
963 >,
964 offset: usize,
965 _depth: fidl::encoding::Depth,
966 ) -> fidl::Result<()> {
967 decoder.debug_check_bounds::<Self>(offset);
968 fidl::decode!(
970 i32,
971 fidl::encoding::DefaultFuchsiaResourceDialect,
972 &mut self.status,
973 decoder,
974 offset + 0,
975 _depth
976 )?;
977 fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 16384>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.handle, decoder, offset + 4, _depth)?;
978 Ok(())
979 }
980 }
981}