1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_power_battery_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct BatterySimulatorMarker;
16
17impl fidl::endpoints::ProtocolMarker for BatterySimulatorMarker {
18 type Proxy = BatterySimulatorProxy;
19 type RequestStream = BatterySimulatorRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = BatterySimulatorSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.power.battery.test.BatterySimulator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for BatterySimulatorMarker {}
26
27pub trait BatterySimulatorProxyInterface: Send + Sync {
28 type GetBatteryInfoResponseFut: std::future::Future<Output = Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error>>
29 + Send;
30 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
31 fn r#set_battery_status(
32 &self,
33 battery_status: fidl_fuchsia_power_battery::BatteryStatus,
34 ) -> Result<(), fidl::Error>;
35 fn r#set_charge_status(
36 &self,
37 charge_status: fidl_fuchsia_power_battery::ChargeStatus,
38 ) -> Result<(), fidl::Error>;
39 fn r#set_charge_source(
40 &self,
41 charge_source: fidl_fuchsia_power_battery::ChargeSource,
42 ) -> Result<(), fidl::Error>;
43 fn r#set_battery_percentage(&self, percent: f32) -> Result<(), fidl::Error>;
44 fn r#set_level_status(
45 &self,
46 level_status: fidl_fuchsia_power_battery::LevelStatus,
47 ) -> Result<(), fidl::Error>;
48 fn r#set_time_remaining(&self, duration: i64) -> Result<(), fidl::Error>;
49 fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error>;
50 type IsSimulatingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
51 fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut;
52 fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error>;
53 fn r#set_present_voltage_mv(&self, voltage: u32) -> Result<(), fidl::Error>;
54 fn r#set_remaining_capacity_uah(&self, capacity: u32) -> Result<(), fidl::Error>;
55 fn r#set_battery_spec(
56 &self,
57 spec: &fidl_fuchsia_power_battery::BatterySpec,
58 ) -> Result<(), fidl::Error>;
59}
60#[derive(Debug)]
61#[cfg(target_os = "fuchsia")]
62pub struct BatterySimulatorSynchronousProxy {
63 client: fidl::client::sync::Client,
64}
65
66#[cfg(target_os = "fuchsia")]
67impl fidl::endpoints::SynchronousProxy for BatterySimulatorSynchronousProxy {
68 type Proxy = BatterySimulatorProxy;
69 type Protocol = BatterySimulatorMarker;
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 BatterySimulatorSynchronousProxy {
86 pub fn new(channel: fidl::Channel) -> Self {
87 let protocol_name = <BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
88 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
89 }
90
91 pub fn into_channel(self) -> fidl::Channel {
92 self.client.into_channel()
93 }
94
95 pub fn wait_for_event(
98 &self,
99 deadline: zx::MonotonicInstant,
100 ) -> Result<BatterySimulatorEvent, fidl::Error> {
101 BatterySimulatorEvent::decode(self.client.wait_for_event(deadline)?)
102 }
103
104 pub fn r#get_battery_info(
107 &self,
108 ___deadline: zx::MonotonicInstant,
109 ) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
110 let _response = self.client.send_query::<
111 fidl::encoding::EmptyPayload,
112 BatterySimulatorControllerGetBatteryInfoResponse,
113 >(
114 (),
115 0x4a20d3731366aaf8,
116 fidl::encoding::DynamicFlags::empty(),
117 ___deadline,
118 )?;
119 Ok(_response.info)
120 }
121
122 pub fn r#set_battery_status(
125 &self,
126 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
127 ) -> Result<(), fidl::Error> {
128 self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
129 (battery_status,),
130 0x2343eb65038c8b34,
131 fidl::encoding::DynamicFlags::empty(),
132 )
133 }
134
135 pub fn r#set_charge_status(
138 &self,
139 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
140 ) -> Result<(), fidl::Error> {
141 self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
142 (charge_status,),
143 0x79b2bf1a387acd85,
144 fidl::encoding::DynamicFlags::empty(),
145 )
146 }
147
148 pub fn r#set_charge_source(
151 &self,
152 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
153 ) -> Result<(), fidl::Error> {
154 self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
155 (charge_source,),
156 0xb40433f42c33527,
157 fidl::encoding::DynamicFlags::empty(),
158 )
159 }
160
161 pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
164 self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
165 (percent,),
166 0x64a9d96eb7a45a9f,
167 fidl::encoding::DynamicFlags::empty(),
168 )
169 }
170
171 pub fn r#set_level_status(
174 &self,
175 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
176 ) -> Result<(), fidl::Error> {
177 self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
178 (level_status,),
179 0x577fc3314f7a48a4,
180 fidl::encoding::DynamicFlags::empty(),
181 )
182 }
183
184 pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
187 self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
188 (duration,),
189 0x7427251c9d2a794e,
190 fidl::encoding::DynamicFlags::empty(),
191 )
192 }
193
194 pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
196 self.client.send::<fidl::encoding::EmptyPayload>(
197 (),
198 0x75588eae6b9b67e3,
199 fidl::encoding::DynamicFlags::empty(),
200 )
201 }
202
203 pub fn r#is_simulating(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
205 let _response = self.client.send_query::<
206 fidl::encoding::EmptyPayload,
207 BatterySimulatorControllerIsSimulatingResponse,
208 >(
209 (),
210 0x4bf85cfe3476975d,
211 fidl::encoding::DynamicFlags::empty(),
212 ___deadline,
213 )?;
214 Ok(_response.simulation_state)
215 }
216
217 pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
220 self.client.send::<fidl::encoding::EmptyPayload>(
221 (),
222 0x18306690352d9dfa,
223 fidl::encoding::DynamicFlags::empty(),
224 )
225 }
226
227 pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
230 self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
231 (voltage,),
232 0x5462c9e9f947b8ce,
233 fidl::encoding::DynamicFlags::empty(),
234 )
235 }
236
237 pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
240 self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
241 (capacity,),
242 0x38054049fe8c26ab,
243 fidl::encoding::DynamicFlags::empty(),
244 )
245 }
246
247 pub fn r#set_battery_spec(
249 &self,
250 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
251 ) -> Result<(), fidl::Error> {
252 self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
253 (spec,),
254 0x7324672546976583,
255 fidl::encoding::DynamicFlags::empty(),
256 )
257 }
258}
259
260#[cfg(target_os = "fuchsia")]
261impl From<BatterySimulatorSynchronousProxy> for zx::Handle {
262 fn from(value: BatterySimulatorSynchronousProxy) -> Self {
263 value.into_channel().into()
264 }
265}
266
267#[cfg(target_os = "fuchsia")]
268impl From<fidl::Channel> for BatterySimulatorSynchronousProxy {
269 fn from(value: fidl::Channel) -> Self {
270 Self::new(value)
271 }
272}
273
274#[derive(Debug, Clone)]
275pub struct BatterySimulatorProxy {
276 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
277}
278
279impl fidl::endpoints::Proxy for BatterySimulatorProxy {
280 type Protocol = BatterySimulatorMarker;
281
282 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
283 Self::new(inner)
284 }
285
286 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
287 self.client.into_channel().map_err(|client| Self { client })
288 }
289
290 fn as_channel(&self) -> &::fidl::AsyncChannel {
291 self.client.as_channel()
292 }
293}
294
295impl BatterySimulatorProxy {
296 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
298 let protocol_name = <BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
299 Self { client: fidl::client::Client::new(channel, protocol_name) }
300 }
301
302 pub fn take_event_stream(&self) -> BatterySimulatorEventStream {
308 BatterySimulatorEventStream { event_receiver: self.client.take_event_receiver() }
309 }
310
311 pub fn r#get_battery_info(
314 &self,
315 ) -> fidl::client::QueryResponseFut<
316 fidl_fuchsia_power_battery::BatteryInfo,
317 fidl::encoding::DefaultFuchsiaResourceDialect,
318 > {
319 BatterySimulatorProxyInterface::r#get_battery_info(self)
320 }
321
322 pub fn r#set_battery_status(
325 &self,
326 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
327 ) -> Result<(), fidl::Error> {
328 BatterySimulatorProxyInterface::r#set_battery_status(self, battery_status)
329 }
330
331 pub fn r#set_charge_status(
334 &self,
335 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
336 ) -> Result<(), fidl::Error> {
337 BatterySimulatorProxyInterface::r#set_charge_status(self, charge_status)
338 }
339
340 pub fn r#set_charge_source(
343 &self,
344 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
345 ) -> Result<(), fidl::Error> {
346 BatterySimulatorProxyInterface::r#set_charge_source(self, charge_source)
347 }
348
349 pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
352 BatterySimulatorProxyInterface::r#set_battery_percentage(self, percent)
353 }
354
355 pub fn r#set_level_status(
358 &self,
359 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
360 ) -> Result<(), fidl::Error> {
361 BatterySimulatorProxyInterface::r#set_level_status(self, level_status)
362 }
363
364 pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
367 BatterySimulatorProxyInterface::r#set_time_remaining(self, duration)
368 }
369
370 pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
372 BatterySimulatorProxyInterface::r#disconnect_real_battery(self)
373 }
374
375 pub fn r#is_simulating(
377 &self,
378 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
379 BatterySimulatorProxyInterface::r#is_simulating(self)
380 }
381
382 pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
385 BatterySimulatorProxyInterface::r#reconnect_real_battery(self)
386 }
387
388 pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
391 BatterySimulatorProxyInterface::r#set_present_voltage_mv(self, voltage)
392 }
393
394 pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
397 BatterySimulatorProxyInterface::r#set_remaining_capacity_uah(self, capacity)
398 }
399
400 pub fn r#set_battery_spec(
402 &self,
403 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
404 ) -> Result<(), fidl::Error> {
405 BatterySimulatorProxyInterface::r#set_battery_spec(self, spec)
406 }
407}
408
409impl BatterySimulatorProxyInterface for BatterySimulatorProxy {
410 type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
411 fidl_fuchsia_power_battery::BatteryInfo,
412 fidl::encoding::DefaultFuchsiaResourceDialect,
413 >;
414 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
415 fn _decode(
416 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
417 ) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
418 let _response = fidl::client::decode_transaction_body::<
419 BatterySimulatorControllerGetBatteryInfoResponse,
420 fidl::encoding::DefaultFuchsiaResourceDialect,
421 0x4a20d3731366aaf8,
422 >(_buf?)?;
423 Ok(_response.info)
424 }
425 self.client.send_query_and_decode::<
426 fidl::encoding::EmptyPayload,
427 fidl_fuchsia_power_battery::BatteryInfo,
428 >(
429 (),
430 0x4a20d3731366aaf8,
431 fidl::encoding::DynamicFlags::empty(),
432 _decode,
433 )
434 }
435
436 fn r#set_battery_status(
437 &self,
438 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
439 ) -> Result<(), fidl::Error> {
440 self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
441 (battery_status,),
442 0x2343eb65038c8b34,
443 fidl::encoding::DynamicFlags::empty(),
444 )
445 }
446
447 fn r#set_charge_status(
448 &self,
449 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
450 ) -> Result<(), fidl::Error> {
451 self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
452 (charge_status,),
453 0x79b2bf1a387acd85,
454 fidl::encoding::DynamicFlags::empty(),
455 )
456 }
457
458 fn r#set_charge_source(
459 &self,
460 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
461 ) -> Result<(), fidl::Error> {
462 self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
463 (charge_source,),
464 0xb40433f42c33527,
465 fidl::encoding::DynamicFlags::empty(),
466 )
467 }
468
469 fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
470 self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
471 (percent,),
472 0x64a9d96eb7a45a9f,
473 fidl::encoding::DynamicFlags::empty(),
474 )
475 }
476
477 fn r#set_level_status(
478 &self,
479 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
480 ) -> Result<(), fidl::Error> {
481 self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
482 (level_status,),
483 0x577fc3314f7a48a4,
484 fidl::encoding::DynamicFlags::empty(),
485 )
486 }
487
488 fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
489 self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
490 (duration,),
491 0x7427251c9d2a794e,
492 fidl::encoding::DynamicFlags::empty(),
493 )
494 }
495
496 fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
497 self.client.send::<fidl::encoding::EmptyPayload>(
498 (),
499 0x75588eae6b9b67e3,
500 fidl::encoding::DynamicFlags::empty(),
501 )
502 }
503
504 type IsSimulatingResponseFut =
505 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
506 fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut {
507 fn _decode(
508 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
509 ) -> Result<bool, fidl::Error> {
510 let _response = fidl::client::decode_transaction_body::<
511 BatterySimulatorControllerIsSimulatingResponse,
512 fidl::encoding::DefaultFuchsiaResourceDialect,
513 0x4bf85cfe3476975d,
514 >(_buf?)?;
515 Ok(_response.simulation_state)
516 }
517 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
518 (),
519 0x4bf85cfe3476975d,
520 fidl::encoding::DynamicFlags::empty(),
521 _decode,
522 )
523 }
524
525 fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
526 self.client.send::<fidl::encoding::EmptyPayload>(
527 (),
528 0x18306690352d9dfa,
529 fidl::encoding::DynamicFlags::empty(),
530 )
531 }
532
533 fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
534 self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
535 (voltage,),
536 0x5462c9e9f947b8ce,
537 fidl::encoding::DynamicFlags::empty(),
538 )
539 }
540
541 fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
542 self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
543 (capacity,),
544 0x38054049fe8c26ab,
545 fidl::encoding::DynamicFlags::empty(),
546 )
547 }
548
549 fn r#set_battery_spec(
550 &self,
551 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
552 ) -> Result<(), fidl::Error> {
553 self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
554 (spec,),
555 0x7324672546976583,
556 fidl::encoding::DynamicFlags::empty(),
557 )
558 }
559}
560
561pub struct BatterySimulatorEventStream {
562 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
563}
564
565impl std::marker::Unpin for BatterySimulatorEventStream {}
566
567impl futures::stream::FusedStream for BatterySimulatorEventStream {
568 fn is_terminated(&self) -> bool {
569 self.event_receiver.is_terminated()
570 }
571}
572
573impl futures::Stream for BatterySimulatorEventStream {
574 type Item = Result<BatterySimulatorEvent, fidl::Error>;
575
576 fn poll_next(
577 mut self: std::pin::Pin<&mut Self>,
578 cx: &mut std::task::Context<'_>,
579 ) -> std::task::Poll<Option<Self::Item>> {
580 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
581 &mut self.event_receiver,
582 cx
583 )?) {
584 Some(buf) => std::task::Poll::Ready(Some(BatterySimulatorEvent::decode(buf))),
585 None => std::task::Poll::Ready(None),
586 }
587 }
588}
589
590#[derive(Debug)]
591pub enum BatterySimulatorEvent {}
592
593impl BatterySimulatorEvent {
594 fn decode(
596 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
597 ) -> Result<BatterySimulatorEvent, fidl::Error> {
598 let (bytes, _handles) = buf.split_mut();
599 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
600 debug_assert_eq!(tx_header.tx_id, 0);
601 match tx_header.ordinal {
602 _ => Err(fidl::Error::UnknownOrdinal {
603 ordinal: tx_header.ordinal,
604 protocol_name:
605 <BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
606 }),
607 }
608 }
609}
610
611pub struct BatterySimulatorRequestStream {
613 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
614 is_terminated: bool,
615}
616
617impl std::marker::Unpin for BatterySimulatorRequestStream {}
618
619impl futures::stream::FusedStream for BatterySimulatorRequestStream {
620 fn is_terminated(&self) -> bool {
621 self.is_terminated
622 }
623}
624
625impl fidl::endpoints::RequestStream for BatterySimulatorRequestStream {
626 type Protocol = BatterySimulatorMarker;
627 type ControlHandle = BatterySimulatorControlHandle;
628
629 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
630 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
631 }
632
633 fn control_handle(&self) -> Self::ControlHandle {
634 BatterySimulatorControlHandle { inner: self.inner.clone() }
635 }
636
637 fn into_inner(
638 self,
639 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
640 {
641 (self.inner, self.is_terminated)
642 }
643
644 fn from_inner(
645 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
646 is_terminated: bool,
647 ) -> Self {
648 Self { inner, is_terminated }
649 }
650}
651
652impl futures::Stream for BatterySimulatorRequestStream {
653 type Item = Result<BatterySimulatorRequest, fidl::Error>;
654
655 fn poll_next(
656 mut self: std::pin::Pin<&mut Self>,
657 cx: &mut std::task::Context<'_>,
658 ) -> std::task::Poll<Option<Self::Item>> {
659 let this = &mut *self;
660 if this.inner.check_shutdown(cx) {
661 this.is_terminated = true;
662 return std::task::Poll::Ready(None);
663 }
664 if this.is_terminated {
665 panic!("polled BatterySimulatorRequestStream after completion");
666 }
667 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
668 |bytes, handles| {
669 match this.inner.channel().read_etc(cx, bytes, handles) {
670 std::task::Poll::Ready(Ok(())) => {}
671 std::task::Poll::Pending => return std::task::Poll::Pending,
672 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
673 this.is_terminated = true;
674 return std::task::Poll::Ready(None);
675 }
676 std::task::Poll::Ready(Err(e)) => {
677 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
678 e.into(),
679 ))))
680 }
681 }
682
683 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
685
686 std::task::Poll::Ready(Some(match header.ordinal {
687 0x4a20d3731366aaf8 => {
688 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
689 let mut req = fidl::new_empty!(
690 fidl::encoding::EmptyPayload,
691 fidl::encoding::DefaultFuchsiaResourceDialect
692 );
693 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
694 let control_handle =
695 BatterySimulatorControlHandle { inner: this.inner.clone() };
696 Ok(BatterySimulatorRequest::GetBatteryInfo {
697 responder: BatterySimulatorGetBatteryInfoResponder {
698 control_handle: std::mem::ManuallyDrop::new(control_handle),
699 tx_id: header.tx_id,
700 },
701 })
702 }
703 0x2343eb65038c8b34 => {
704 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
705 let mut req = fidl::new_empty!(
706 BatterySimulatorControllerSetBatteryStatusRequest,
707 fidl::encoding::DefaultFuchsiaResourceDialect
708 );
709 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryStatusRequest>(&header, _body_bytes, handles, &mut req)?;
710 let control_handle =
711 BatterySimulatorControlHandle { inner: this.inner.clone() };
712 Ok(BatterySimulatorRequest::SetBatteryStatus {
713 battery_status: req.battery_status,
714
715 control_handle,
716 })
717 }
718 0x79b2bf1a387acd85 => {
719 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
720 let mut req = fidl::new_empty!(
721 BatterySimulatorControllerSetChargeStatusRequest,
722 fidl::encoding::DefaultFuchsiaResourceDialect
723 );
724 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeStatusRequest>(&header, _body_bytes, handles, &mut req)?;
725 let control_handle =
726 BatterySimulatorControlHandle { inner: this.inner.clone() };
727 Ok(BatterySimulatorRequest::SetChargeStatus {
728 charge_status: req.charge_status,
729
730 control_handle,
731 })
732 }
733 0xb40433f42c33527 => {
734 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
735 let mut req = fidl::new_empty!(
736 BatterySimulatorControllerSetChargeSourceRequest,
737 fidl::encoding::DefaultFuchsiaResourceDialect
738 );
739 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
740 let control_handle =
741 BatterySimulatorControlHandle { inner: this.inner.clone() };
742 Ok(BatterySimulatorRequest::SetChargeSource {
743 charge_source: req.charge_source,
744
745 control_handle,
746 })
747 }
748 0x64a9d96eb7a45a9f => {
749 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
750 let mut req = fidl::new_empty!(
751 BatterySimulatorControllerSetBatteryPercentageRequest,
752 fidl::encoding::DefaultFuchsiaResourceDialect
753 );
754 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryPercentageRequest>(&header, _body_bytes, handles, &mut req)?;
755 let control_handle =
756 BatterySimulatorControlHandle { inner: this.inner.clone() };
757 Ok(BatterySimulatorRequest::SetBatteryPercentage {
758 percent: req.percent,
759
760 control_handle,
761 })
762 }
763 0x577fc3314f7a48a4 => {
764 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
765 let mut req = fidl::new_empty!(
766 BatterySimulatorControllerSetLevelStatusRequest,
767 fidl::encoding::DefaultFuchsiaResourceDialect
768 );
769 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetLevelStatusRequest>(&header, _body_bytes, handles, &mut req)?;
770 let control_handle =
771 BatterySimulatorControlHandle { inner: this.inner.clone() };
772 Ok(BatterySimulatorRequest::SetLevelStatus {
773 level_status: req.level_status,
774
775 control_handle,
776 })
777 }
778 0x7427251c9d2a794e => {
779 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
780 let mut req = fidl::new_empty!(
781 BatterySimulatorControllerSetTimeRemainingRequest,
782 fidl::encoding::DefaultFuchsiaResourceDialect
783 );
784 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetTimeRemainingRequest>(&header, _body_bytes, handles, &mut req)?;
785 let control_handle =
786 BatterySimulatorControlHandle { inner: this.inner.clone() };
787 Ok(BatterySimulatorRequest::SetTimeRemaining {
788 duration: req.duration,
789
790 control_handle,
791 })
792 }
793 0x75588eae6b9b67e3 => {
794 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
795 let mut req = fidl::new_empty!(
796 fidl::encoding::EmptyPayload,
797 fidl::encoding::DefaultFuchsiaResourceDialect
798 );
799 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
800 let control_handle =
801 BatterySimulatorControlHandle { inner: this.inner.clone() };
802 Ok(BatterySimulatorRequest::DisconnectRealBattery { control_handle })
803 }
804 0x4bf85cfe3476975d => {
805 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
806 let mut req = fidl::new_empty!(
807 fidl::encoding::EmptyPayload,
808 fidl::encoding::DefaultFuchsiaResourceDialect
809 );
810 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
811 let control_handle =
812 BatterySimulatorControlHandle { inner: this.inner.clone() };
813 Ok(BatterySimulatorRequest::IsSimulating {
814 responder: BatterySimulatorIsSimulatingResponder {
815 control_handle: std::mem::ManuallyDrop::new(control_handle),
816 tx_id: header.tx_id,
817 },
818 })
819 }
820 0x18306690352d9dfa => {
821 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
822 let mut req = fidl::new_empty!(
823 fidl::encoding::EmptyPayload,
824 fidl::encoding::DefaultFuchsiaResourceDialect
825 );
826 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
827 let control_handle =
828 BatterySimulatorControlHandle { inner: this.inner.clone() };
829 Ok(BatterySimulatorRequest::ReconnectRealBattery { control_handle })
830 }
831 0x5462c9e9f947b8ce => {
832 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
833 let mut req = fidl::new_empty!(
834 BatterySimulatorControllerSetPresentVoltageMvRequest,
835 fidl::encoding::DefaultFuchsiaResourceDialect
836 );
837 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetPresentVoltageMvRequest>(&header, _body_bytes, handles, &mut req)?;
838 let control_handle =
839 BatterySimulatorControlHandle { inner: this.inner.clone() };
840 Ok(BatterySimulatorRequest::SetPresentVoltageMv {
841 voltage: req.voltage,
842
843 control_handle,
844 })
845 }
846 0x38054049fe8c26ab => {
847 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
848 let mut req = fidl::new_empty!(
849 BatterySimulatorControllerSetRemainingCapacityUahRequest,
850 fidl::encoding::DefaultFuchsiaResourceDialect
851 );
852 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(&header, _body_bytes, handles, &mut req)?;
853 let control_handle =
854 BatterySimulatorControlHandle { inner: this.inner.clone() };
855 Ok(BatterySimulatorRequest::SetRemainingCapacityUah {
856 capacity: req.capacity,
857
858 control_handle,
859 })
860 }
861 0x7324672546976583 => {
862 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
863 let mut req = fidl::new_empty!(
864 BatterySimulatorControllerSetBatterySpecRequest,
865 fidl::encoding::DefaultFuchsiaResourceDialect
866 );
867 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatterySpecRequest>(&header, _body_bytes, handles, &mut req)?;
868 let control_handle =
869 BatterySimulatorControlHandle { inner: this.inner.clone() };
870 Ok(BatterySimulatorRequest::SetBatterySpec {
871 spec: req.spec,
872
873 control_handle,
874 })
875 }
876 _ => Err(fidl::Error::UnknownOrdinal {
877 ordinal: header.ordinal,
878 protocol_name:
879 <BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
880 }),
881 }))
882 },
883 )
884 }
885}
886
887#[derive(Debug)]
889pub enum BatterySimulatorRequest {
890 GetBatteryInfo { responder: BatterySimulatorGetBatteryInfoResponder },
893 SetBatteryStatus {
896 battery_status: fidl_fuchsia_power_battery::BatteryStatus,
897 control_handle: BatterySimulatorControlHandle,
898 },
899 SetChargeStatus {
902 charge_status: fidl_fuchsia_power_battery::ChargeStatus,
903 control_handle: BatterySimulatorControlHandle,
904 },
905 SetChargeSource {
908 charge_source: fidl_fuchsia_power_battery::ChargeSource,
909 control_handle: BatterySimulatorControlHandle,
910 },
911 SetBatteryPercentage { percent: f32, control_handle: BatterySimulatorControlHandle },
914 SetLevelStatus {
917 level_status: fidl_fuchsia_power_battery::LevelStatus,
918 control_handle: BatterySimulatorControlHandle,
919 },
920 SetTimeRemaining { duration: i64, control_handle: BatterySimulatorControlHandle },
923 DisconnectRealBattery { control_handle: BatterySimulatorControlHandle },
925 IsSimulating { responder: BatterySimulatorIsSimulatingResponder },
927 ReconnectRealBattery { control_handle: BatterySimulatorControlHandle },
930 SetPresentVoltageMv { voltage: u32, control_handle: BatterySimulatorControlHandle },
933 SetRemainingCapacityUah { capacity: u32, control_handle: BatterySimulatorControlHandle },
936 SetBatterySpec {
938 spec: fidl_fuchsia_power_battery::BatterySpec,
939 control_handle: BatterySimulatorControlHandle,
940 },
941}
942
943impl BatterySimulatorRequest {
944 #[allow(irrefutable_let_patterns)]
945 pub fn into_get_battery_info(self) -> Option<(BatterySimulatorGetBatteryInfoResponder)> {
946 if let BatterySimulatorRequest::GetBatteryInfo { responder } = self {
947 Some((responder))
948 } else {
949 None
950 }
951 }
952
953 #[allow(irrefutable_let_patterns)]
954 pub fn into_set_battery_status(
955 self,
956 ) -> Option<(fidl_fuchsia_power_battery::BatteryStatus, BatterySimulatorControlHandle)> {
957 if let BatterySimulatorRequest::SetBatteryStatus { battery_status, control_handle } = self {
958 Some((battery_status, control_handle))
959 } else {
960 None
961 }
962 }
963
964 #[allow(irrefutable_let_patterns)]
965 pub fn into_set_charge_status(
966 self,
967 ) -> Option<(fidl_fuchsia_power_battery::ChargeStatus, BatterySimulatorControlHandle)> {
968 if let BatterySimulatorRequest::SetChargeStatus { charge_status, control_handle } = self {
969 Some((charge_status, control_handle))
970 } else {
971 None
972 }
973 }
974
975 #[allow(irrefutable_let_patterns)]
976 pub fn into_set_charge_source(
977 self,
978 ) -> Option<(fidl_fuchsia_power_battery::ChargeSource, BatterySimulatorControlHandle)> {
979 if let BatterySimulatorRequest::SetChargeSource { charge_source, control_handle } = self {
980 Some((charge_source, control_handle))
981 } else {
982 None
983 }
984 }
985
986 #[allow(irrefutable_let_patterns)]
987 pub fn into_set_battery_percentage(self) -> Option<(f32, BatterySimulatorControlHandle)> {
988 if let BatterySimulatorRequest::SetBatteryPercentage { percent, control_handle } = self {
989 Some((percent, control_handle))
990 } else {
991 None
992 }
993 }
994
995 #[allow(irrefutable_let_patterns)]
996 pub fn into_set_level_status(
997 self,
998 ) -> Option<(fidl_fuchsia_power_battery::LevelStatus, BatterySimulatorControlHandle)> {
999 if let BatterySimulatorRequest::SetLevelStatus { level_status, control_handle } = self {
1000 Some((level_status, control_handle))
1001 } else {
1002 None
1003 }
1004 }
1005
1006 #[allow(irrefutable_let_patterns)]
1007 pub fn into_set_time_remaining(self) -> Option<(i64, BatterySimulatorControlHandle)> {
1008 if let BatterySimulatorRequest::SetTimeRemaining { duration, control_handle } = self {
1009 Some((duration, control_handle))
1010 } else {
1011 None
1012 }
1013 }
1014
1015 #[allow(irrefutable_let_patterns)]
1016 pub fn into_disconnect_real_battery(self) -> Option<(BatterySimulatorControlHandle)> {
1017 if let BatterySimulatorRequest::DisconnectRealBattery { control_handle } = self {
1018 Some((control_handle))
1019 } else {
1020 None
1021 }
1022 }
1023
1024 #[allow(irrefutable_let_patterns)]
1025 pub fn into_is_simulating(self) -> Option<(BatterySimulatorIsSimulatingResponder)> {
1026 if let BatterySimulatorRequest::IsSimulating { responder } = self {
1027 Some((responder))
1028 } else {
1029 None
1030 }
1031 }
1032
1033 #[allow(irrefutable_let_patterns)]
1034 pub fn into_reconnect_real_battery(self) -> Option<(BatterySimulatorControlHandle)> {
1035 if let BatterySimulatorRequest::ReconnectRealBattery { control_handle } = self {
1036 Some((control_handle))
1037 } else {
1038 None
1039 }
1040 }
1041
1042 #[allow(irrefutable_let_patterns)]
1043 pub fn into_set_present_voltage_mv(self) -> Option<(u32, BatterySimulatorControlHandle)> {
1044 if let BatterySimulatorRequest::SetPresentVoltageMv { voltage, control_handle } = self {
1045 Some((voltage, control_handle))
1046 } else {
1047 None
1048 }
1049 }
1050
1051 #[allow(irrefutable_let_patterns)]
1052 pub fn into_set_remaining_capacity_uah(self) -> Option<(u32, BatterySimulatorControlHandle)> {
1053 if let BatterySimulatorRequest::SetRemainingCapacityUah { capacity, control_handle } = self
1054 {
1055 Some((capacity, control_handle))
1056 } else {
1057 None
1058 }
1059 }
1060
1061 #[allow(irrefutable_let_patterns)]
1062 pub fn into_set_battery_spec(
1063 self,
1064 ) -> Option<(fidl_fuchsia_power_battery::BatterySpec, BatterySimulatorControlHandle)> {
1065 if let BatterySimulatorRequest::SetBatterySpec { spec, control_handle } = self {
1066 Some((spec, control_handle))
1067 } else {
1068 None
1069 }
1070 }
1071
1072 pub fn method_name(&self) -> &'static str {
1074 match *self {
1075 BatterySimulatorRequest::GetBatteryInfo { .. } => "get_battery_info",
1076 BatterySimulatorRequest::SetBatteryStatus { .. } => "set_battery_status",
1077 BatterySimulatorRequest::SetChargeStatus { .. } => "set_charge_status",
1078 BatterySimulatorRequest::SetChargeSource { .. } => "set_charge_source",
1079 BatterySimulatorRequest::SetBatteryPercentage { .. } => "set_battery_percentage",
1080 BatterySimulatorRequest::SetLevelStatus { .. } => "set_level_status",
1081 BatterySimulatorRequest::SetTimeRemaining { .. } => "set_time_remaining",
1082 BatterySimulatorRequest::DisconnectRealBattery { .. } => "disconnect_real_battery",
1083 BatterySimulatorRequest::IsSimulating { .. } => "is_simulating",
1084 BatterySimulatorRequest::ReconnectRealBattery { .. } => "reconnect_real_battery",
1085 BatterySimulatorRequest::SetPresentVoltageMv { .. } => "set_present_voltage_mv",
1086 BatterySimulatorRequest::SetRemainingCapacityUah { .. } => "set_remaining_capacity_uah",
1087 BatterySimulatorRequest::SetBatterySpec { .. } => "set_battery_spec",
1088 }
1089 }
1090}
1091
1092#[derive(Debug, Clone)]
1093pub struct BatterySimulatorControlHandle {
1094 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1095}
1096
1097impl fidl::endpoints::ControlHandle for BatterySimulatorControlHandle {
1098 fn shutdown(&self) {
1099 self.inner.shutdown()
1100 }
1101 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1102 self.inner.shutdown_with_epitaph(status)
1103 }
1104
1105 fn is_closed(&self) -> bool {
1106 self.inner.channel().is_closed()
1107 }
1108 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1109 self.inner.channel().on_closed()
1110 }
1111
1112 #[cfg(target_os = "fuchsia")]
1113 fn signal_peer(
1114 &self,
1115 clear_mask: zx::Signals,
1116 set_mask: zx::Signals,
1117 ) -> Result<(), zx_status::Status> {
1118 use fidl::Peered;
1119 self.inner.channel().signal_peer(clear_mask, set_mask)
1120 }
1121}
1122
1123impl BatterySimulatorControlHandle {}
1124
1125#[must_use = "FIDL methods require a response to be sent"]
1126#[derive(Debug)]
1127pub struct BatterySimulatorGetBatteryInfoResponder {
1128 control_handle: std::mem::ManuallyDrop<BatterySimulatorControlHandle>,
1129 tx_id: u32,
1130}
1131
1132impl std::ops::Drop for BatterySimulatorGetBatteryInfoResponder {
1136 fn drop(&mut self) {
1137 self.control_handle.shutdown();
1138 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1140 }
1141}
1142
1143impl fidl::endpoints::Responder for BatterySimulatorGetBatteryInfoResponder {
1144 type ControlHandle = BatterySimulatorControlHandle;
1145
1146 fn control_handle(&self) -> &BatterySimulatorControlHandle {
1147 &self.control_handle
1148 }
1149
1150 fn drop_without_shutdown(mut self) {
1151 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1153 std::mem::forget(self);
1155 }
1156}
1157
1158impl BatterySimulatorGetBatteryInfoResponder {
1159 pub fn send(
1163 self,
1164 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
1165 ) -> Result<(), fidl::Error> {
1166 let _result = self.send_raw(info);
1167 if _result.is_err() {
1168 self.control_handle.shutdown();
1169 }
1170 self.drop_without_shutdown();
1171 _result
1172 }
1173
1174 pub fn send_no_shutdown_on_err(
1176 self,
1177 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
1178 ) -> Result<(), fidl::Error> {
1179 let _result = self.send_raw(info);
1180 self.drop_without_shutdown();
1181 _result
1182 }
1183
1184 fn send_raw(
1185 &self,
1186 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
1187 ) -> Result<(), fidl::Error> {
1188 self.control_handle.inner.send::<BatterySimulatorControllerGetBatteryInfoResponse>(
1189 (info,),
1190 self.tx_id,
1191 0x4a20d3731366aaf8,
1192 fidl::encoding::DynamicFlags::empty(),
1193 )
1194 }
1195}
1196
1197#[must_use = "FIDL methods require a response to be sent"]
1198#[derive(Debug)]
1199pub struct BatterySimulatorIsSimulatingResponder {
1200 control_handle: std::mem::ManuallyDrop<BatterySimulatorControlHandle>,
1201 tx_id: u32,
1202}
1203
1204impl std::ops::Drop for BatterySimulatorIsSimulatingResponder {
1208 fn drop(&mut self) {
1209 self.control_handle.shutdown();
1210 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1212 }
1213}
1214
1215impl fidl::endpoints::Responder for BatterySimulatorIsSimulatingResponder {
1216 type ControlHandle = BatterySimulatorControlHandle;
1217
1218 fn control_handle(&self) -> &BatterySimulatorControlHandle {
1219 &self.control_handle
1220 }
1221
1222 fn drop_without_shutdown(mut self) {
1223 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1225 std::mem::forget(self);
1227 }
1228}
1229
1230impl BatterySimulatorIsSimulatingResponder {
1231 pub fn send(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
1235 let _result = self.send_raw(simulation_state);
1236 if _result.is_err() {
1237 self.control_handle.shutdown();
1238 }
1239 self.drop_without_shutdown();
1240 _result
1241 }
1242
1243 pub fn send_no_shutdown_on_err(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
1245 let _result = self.send_raw(simulation_state);
1246 self.drop_without_shutdown();
1247 _result
1248 }
1249
1250 fn send_raw(&self, mut simulation_state: bool) -> Result<(), fidl::Error> {
1251 self.control_handle.inner.send::<BatterySimulatorControllerIsSimulatingResponse>(
1252 (simulation_state,),
1253 self.tx_id,
1254 0x4bf85cfe3476975d,
1255 fidl::encoding::DynamicFlags::empty(),
1256 )
1257 }
1258}
1259
1260#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1261pub struct BatterySimulatorControllerMarker;
1262
1263impl fidl::endpoints::ProtocolMarker for BatterySimulatorControllerMarker {
1264 type Proxy = BatterySimulatorControllerProxy;
1265 type RequestStream = BatterySimulatorControllerRequestStream;
1266 #[cfg(target_os = "fuchsia")]
1267 type SynchronousProxy = BatterySimulatorControllerSynchronousProxy;
1268
1269 const DEBUG_NAME: &'static str = "(anonymous) BatterySimulatorController";
1270}
1271
1272pub trait BatterySimulatorControllerProxyInterface: Send + Sync {
1273 type GetBatteryInfoResponseFut: std::future::Future<Output = Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error>>
1274 + Send;
1275 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
1276 fn r#set_battery_status(
1277 &self,
1278 battery_status: fidl_fuchsia_power_battery::BatteryStatus,
1279 ) -> Result<(), fidl::Error>;
1280 fn r#set_charge_status(
1281 &self,
1282 charge_status: fidl_fuchsia_power_battery::ChargeStatus,
1283 ) -> Result<(), fidl::Error>;
1284 fn r#set_charge_source(
1285 &self,
1286 charge_source: fidl_fuchsia_power_battery::ChargeSource,
1287 ) -> Result<(), fidl::Error>;
1288 fn r#set_battery_percentage(&self, percent: f32) -> Result<(), fidl::Error>;
1289 fn r#set_level_status(
1290 &self,
1291 level_status: fidl_fuchsia_power_battery::LevelStatus,
1292 ) -> Result<(), fidl::Error>;
1293 fn r#set_time_remaining(&self, duration: i64) -> Result<(), fidl::Error>;
1294 fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error>;
1295 type IsSimulatingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
1296 fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut;
1297 fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error>;
1298 fn r#set_present_voltage_mv(&self, voltage: u32) -> Result<(), fidl::Error>;
1299 fn r#set_remaining_capacity_uah(&self, capacity: u32) -> Result<(), fidl::Error>;
1300 fn r#set_battery_spec(
1301 &self,
1302 spec: &fidl_fuchsia_power_battery::BatterySpec,
1303 ) -> Result<(), fidl::Error>;
1304}
1305#[derive(Debug)]
1306#[cfg(target_os = "fuchsia")]
1307pub struct BatterySimulatorControllerSynchronousProxy {
1308 client: fidl::client::sync::Client,
1309}
1310
1311#[cfg(target_os = "fuchsia")]
1312impl fidl::endpoints::SynchronousProxy for BatterySimulatorControllerSynchronousProxy {
1313 type Proxy = BatterySimulatorControllerProxy;
1314 type Protocol = BatterySimulatorControllerMarker;
1315
1316 fn from_channel(inner: fidl::Channel) -> Self {
1317 Self::new(inner)
1318 }
1319
1320 fn into_channel(self) -> fidl::Channel {
1321 self.client.into_channel()
1322 }
1323
1324 fn as_channel(&self) -> &fidl::Channel {
1325 self.client.as_channel()
1326 }
1327}
1328
1329#[cfg(target_os = "fuchsia")]
1330impl BatterySimulatorControllerSynchronousProxy {
1331 pub fn new(channel: fidl::Channel) -> Self {
1332 let protocol_name =
1333 <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1334 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1335 }
1336
1337 pub fn into_channel(self) -> fidl::Channel {
1338 self.client.into_channel()
1339 }
1340
1341 pub fn wait_for_event(
1344 &self,
1345 deadline: zx::MonotonicInstant,
1346 ) -> Result<BatterySimulatorControllerEvent, fidl::Error> {
1347 BatterySimulatorControllerEvent::decode(self.client.wait_for_event(deadline)?)
1348 }
1349
1350 pub fn r#get_battery_info(
1353 &self,
1354 ___deadline: zx::MonotonicInstant,
1355 ) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
1356 let _response = self.client.send_query::<
1357 fidl::encoding::EmptyPayload,
1358 BatterySimulatorControllerGetBatteryInfoResponse,
1359 >(
1360 (),
1361 0x4a20d3731366aaf8,
1362 fidl::encoding::DynamicFlags::empty(),
1363 ___deadline,
1364 )?;
1365 Ok(_response.info)
1366 }
1367
1368 pub fn r#set_battery_status(
1371 &self,
1372 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
1373 ) -> Result<(), fidl::Error> {
1374 self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
1375 (battery_status,),
1376 0x2343eb65038c8b34,
1377 fidl::encoding::DynamicFlags::empty(),
1378 )
1379 }
1380
1381 pub fn r#set_charge_status(
1384 &self,
1385 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
1386 ) -> Result<(), fidl::Error> {
1387 self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
1388 (charge_status,),
1389 0x79b2bf1a387acd85,
1390 fidl::encoding::DynamicFlags::empty(),
1391 )
1392 }
1393
1394 pub fn r#set_charge_source(
1397 &self,
1398 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
1399 ) -> Result<(), fidl::Error> {
1400 self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
1401 (charge_source,),
1402 0xb40433f42c33527,
1403 fidl::encoding::DynamicFlags::empty(),
1404 )
1405 }
1406
1407 pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
1410 self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
1411 (percent,),
1412 0x64a9d96eb7a45a9f,
1413 fidl::encoding::DynamicFlags::empty(),
1414 )
1415 }
1416
1417 pub fn r#set_level_status(
1420 &self,
1421 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
1422 ) -> Result<(), fidl::Error> {
1423 self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
1424 (level_status,),
1425 0x577fc3314f7a48a4,
1426 fidl::encoding::DynamicFlags::empty(),
1427 )
1428 }
1429
1430 pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
1433 self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
1434 (duration,),
1435 0x7427251c9d2a794e,
1436 fidl::encoding::DynamicFlags::empty(),
1437 )
1438 }
1439
1440 pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
1442 self.client.send::<fidl::encoding::EmptyPayload>(
1443 (),
1444 0x75588eae6b9b67e3,
1445 fidl::encoding::DynamicFlags::empty(),
1446 )
1447 }
1448
1449 pub fn r#is_simulating(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
1451 let _response = self.client.send_query::<
1452 fidl::encoding::EmptyPayload,
1453 BatterySimulatorControllerIsSimulatingResponse,
1454 >(
1455 (),
1456 0x4bf85cfe3476975d,
1457 fidl::encoding::DynamicFlags::empty(),
1458 ___deadline,
1459 )?;
1460 Ok(_response.simulation_state)
1461 }
1462
1463 pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
1466 self.client.send::<fidl::encoding::EmptyPayload>(
1467 (),
1468 0x18306690352d9dfa,
1469 fidl::encoding::DynamicFlags::empty(),
1470 )
1471 }
1472
1473 pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
1476 self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
1477 (voltage,),
1478 0x5462c9e9f947b8ce,
1479 fidl::encoding::DynamicFlags::empty(),
1480 )
1481 }
1482
1483 pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
1486 self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
1487 (capacity,),
1488 0x38054049fe8c26ab,
1489 fidl::encoding::DynamicFlags::empty(),
1490 )
1491 }
1492
1493 pub fn r#set_battery_spec(
1495 &self,
1496 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
1497 ) -> Result<(), fidl::Error> {
1498 self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
1499 (spec,),
1500 0x7324672546976583,
1501 fidl::encoding::DynamicFlags::empty(),
1502 )
1503 }
1504}
1505
1506#[cfg(target_os = "fuchsia")]
1507impl From<BatterySimulatorControllerSynchronousProxy> for zx::Handle {
1508 fn from(value: BatterySimulatorControllerSynchronousProxy) -> Self {
1509 value.into_channel().into()
1510 }
1511}
1512
1513#[cfg(target_os = "fuchsia")]
1514impl From<fidl::Channel> for BatterySimulatorControllerSynchronousProxy {
1515 fn from(value: fidl::Channel) -> Self {
1516 Self::new(value)
1517 }
1518}
1519
1520#[derive(Debug, Clone)]
1521pub struct BatterySimulatorControllerProxy {
1522 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1523}
1524
1525impl fidl::endpoints::Proxy for BatterySimulatorControllerProxy {
1526 type Protocol = BatterySimulatorControllerMarker;
1527
1528 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1529 Self::new(inner)
1530 }
1531
1532 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1533 self.client.into_channel().map_err(|client| Self { client })
1534 }
1535
1536 fn as_channel(&self) -> &::fidl::AsyncChannel {
1537 self.client.as_channel()
1538 }
1539}
1540
1541impl BatterySimulatorControllerProxy {
1542 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1544 let protocol_name =
1545 <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1546 Self { client: fidl::client::Client::new(channel, protocol_name) }
1547 }
1548
1549 pub fn take_event_stream(&self) -> BatterySimulatorControllerEventStream {
1555 BatterySimulatorControllerEventStream { event_receiver: self.client.take_event_receiver() }
1556 }
1557
1558 pub fn r#get_battery_info(
1561 &self,
1562 ) -> fidl::client::QueryResponseFut<
1563 fidl_fuchsia_power_battery::BatteryInfo,
1564 fidl::encoding::DefaultFuchsiaResourceDialect,
1565 > {
1566 BatterySimulatorControllerProxyInterface::r#get_battery_info(self)
1567 }
1568
1569 pub fn r#set_battery_status(
1572 &self,
1573 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
1574 ) -> Result<(), fidl::Error> {
1575 BatterySimulatorControllerProxyInterface::r#set_battery_status(self, battery_status)
1576 }
1577
1578 pub fn r#set_charge_status(
1581 &self,
1582 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
1583 ) -> Result<(), fidl::Error> {
1584 BatterySimulatorControllerProxyInterface::r#set_charge_status(self, charge_status)
1585 }
1586
1587 pub fn r#set_charge_source(
1590 &self,
1591 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
1592 ) -> Result<(), fidl::Error> {
1593 BatterySimulatorControllerProxyInterface::r#set_charge_source(self, charge_source)
1594 }
1595
1596 pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
1599 BatterySimulatorControllerProxyInterface::r#set_battery_percentage(self, percent)
1600 }
1601
1602 pub fn r#set_level_status(
1605 &self,
1606 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
1607 ) -> Result<(), fidl::Error> {
1608 BatterySimulatorControllerProxyInterface::r#set_level_status(self, level_status)
1609 }
1610
1611 pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
1614 BatterySimulatorControllerProxyInterface::r#set_time_remaining(self, duration)
1615 }
1616
1617 pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
1619 BatterySimulatorControllerProxyInterface::r#disconnect_real_battery(self)
1620 }
1621
1622 pub fn r#is_simulating(
1624 &self,
1625 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1626 BatterySimulatorControllerProxyInterface::r#is_simulating(self)
1627 }
1628
1629 pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
1632 BatterySimulatorControllerProxyInterface::r#reconnect_real_battery(self)
1633 }
1634
1635 pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
1638 BatterySimulatorControllerProxyInterface::r#set_present_voltage_mv(self, voltage)
1639 }
1640
1641 pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
1644 BatterySimulatorControllerProxyInterface::r#set_remaining_capacity_uah(self, capacity)
1645 }
1646
1647 pub fn r#set_battery_spec(
1649 &self,
1650 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
1651 ) -> Result<(), fidl::Error> {
1652 BatterySimulatorControllerProxyInterface::r#set_battery_spec(self, spec)
1653 }
1654}
1655
1656impl BatterySimulatorControllerProxyInterface for BatterySimulatorControllerProxy {
1657 type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
1658 fidl_fuchsia_power_battery::BatteryInfo,
1659 fidl::encoding::DefaultFuchsiaResourceDialect,
1660 >;
1661 fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
1662 fn _decode(
1663 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1664 ) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
1665 let _response = fidl::client::decode_transaction_body::<
1666 BatterySimulatorControllerGetBatteryInfoResponse,
1667 fidl::encoding::DefaultFuchsiaResourceDialect,
1668 0x4a20d3731366aaf8,
1669 >(_buf?)?;
1670 Ok(_response.info)
1671 }
1672 self.client.send_query_and_decode::<
1673 fidl::encoding::EmptyPayload,
1674 fidl_fuchsia_power_battery::BatteryInfo,
1675 >(
1676 (),
1677 0x4a20d3731366aaf8,
1678 fidl::encoding::DynamicFlags::empty(),
1679 _decode,
1680 )
1681 }
1682
1683 fn r#set_battery_status(
1684 &self,
1685 mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
1686 ) -> Result<(), fidl::Error> {
1687 self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
1688 (battery_status,),
1689 0x2343eb65038c8b34,
1690 fidl::encoding::DynamicFlags::empty(),
1691 )
1692 }
1693
1694 fn r#set_charge_status(
1695 &self,
1696 mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
1697 ) -> Result<(), fidl::Error> {
1698 self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
1699 (charge_status,),
1700 0x79b2bf1a387acd85,
1701 fidl::encoding::DynamicFlags::empty(),
1702 )
1703 }
1704
1705 fn r#set_charge_source(
1706 &self,
1707 mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
1708 ) -> Result<(), fidl::Error> {
1709 self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
1710 (charge_source,),
1711 0xb40433f42c33527,
1712 fidl::encoding::DynamicFlags::empty(),
1713 )
1714 }
1715
1716 fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
1717 self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
1718 (percent,),
1719 0x64a9d96eb7a45a9f,
1720 fidl::encoding::DynamicFlags::empty(),
1721 )
1722 }
1723
1724 fn r#set_level_status(
1725 &self,
1726 mut level_status: fidl_fuchsia_power_battery::LevelStatus,
1727 ) -> Result<(), fidl::Error> {
1728 self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
1729 (level_status,),
1730 0x577fc3314f7a48a4,
1731 fidl::encoding::DynamicFlags::empty(),
1732 )
1733 }
1734
1735 fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
1736 self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
1737 (duration,),
1738 0x7427251c9d2a794e,
1739 fidl::encoding::DynamicFlags::empty(),
1740 )
1741 }
1742
1743 fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
1744 self.client.send::<fidl::encoding::EmptyPayload>(
1745 (),
1746 0x75588eae6b9b67e3,
1747 fidl::encoding::DynamicFlags::empty(),
1748 )
1749 }
1750
1751 type IsSimulatingResponseFut =
1752 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1753 fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut {
1754 fn _decode(
1755 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1756 ) -> Result<bool, fidl::Error> {
1757 let _response = fidl::client::decode_transaction_body::<
1758 BatterySimulatorControllerIsSimulatingResponse,
1759 fidl::encoding::DefaultFuchsiaResourceDialect,
1760 0x4bf85cfe3476975d,
1761 >(_buf?)?;
1762 Ok(_response.simulation_state)
1763 }
1764 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
1765 (),
1766 0x4bf85cfe3476975d,
1767 fidl::encoding::DynamicFlags::empty(),
1768 _decode,
1769 )
1770 }
1771
1772 fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
1773 self.client.send::<fidl::encoding::EmptyPayload>(
1774 (),
1775 0x18306690352d9dfa,
1776 fidl::encoding::DynamicFlags::empty(),
1777 )
1778 }
1779
1780 fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
1781 self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
1782 (voltage,),
1783 0x5462c9e9f947b8ce,
1784 fidl::encoding::DynamicFlags::empty(),
1785 )
1786 }
1787
1788 fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
1789 self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
1790 (capacity,),
1791 0x38054049fe8c26ab,
1792 fidl::encoding::DynamicFlags::empty(),
1793 )
1794 }
1795
1796 fn r#set_battery_spec(
1797 &self,
1798 mut spec: &fidl_fuchsia_power_battery::BatterySpec,
1799 ) -> Result<(), fidl::Error> {
1800 self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
1801 (spec,),
1802 0x7324672546976583,
1803 fidl::encoding::DynamicFlags::empty(),
1804 )
1805 }
1806}
1807
1808pub struct BatterySimulatorControllerEventStream {
1809 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1810}
1811
1812impl std::marker::Unpin for BatterySimulatorControllerEventStream {}
1813
1814impl futures::stream::FusedStream for BatterySimulatorControllerEventStream {
1815 fn is_terminated(&self) -> bool {
1816 self.event_receiver.is_terminated()
1817 }
1818}
1819
1820impl futures::Stream for BatterySimulatorControllerEventStream {
1821 type Item = Result<BatterySimulatorControllerEvent, fidl::Error>;
1822
1823 fn poll_next(
1824 mut self: std::pin::Pin<&mut Self>,
1825 cx: &mut std::task::Context<'_>,
1826 ) -> std::task::Poll<Option<Self::Item>> {
1827 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1828 &mut self.event_receiver,
1829 cx
1830 )?) {
1831 Some(buf) => std::task::Poll::Ready(Some(BatterySimulatorControllerEvent::decode(buf))),
1832 None => std::task::Poll::Ready(None),
1833 }
1834 }
1835}
1836
1837#[derive(Debug)]
1838pub enum BatterySimulatorControllerEvent {}
1839
1840impl BatterySimulatorControllerEvent {
1841 fn decode(
1843 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1844 ) -> Result<BatterySimulatorControllerEvent, fidl::Error> {
1845 let (bytes, _handles) = buf.split_mut();
1846 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1847 debug_assert_eq!(tx_header.tx_id, 0);
1848 match tx_header.ordinal {
1849 _ => Err(fidl::Error::UnknownOrdinal {
1850 ordinal: tx_header.ordinal,
1851 protocol_name: <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1852 })
1853 }
1854 }
1855}
1856
1857pub struct BatterySimulatorControllerRequestStream {
1859 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1860 is_terminated: bool,
1861}
1862
1863impl std::marker::Unpin for BatterySimulatorControllerRequestStream {}
1864
1865impl futures::stream::FusedStream for BatterySimulatorControllerRequestStream {
1866 fn is_terminated(&self) -> bool {
1867 self.is_terminated
1868 }
1869}
1870
1871impl fidl::endpoints::RequestStream for BatterySimulatorControllerRequestStream {
1872 type Protocol = BatterySimulatorControllerMarker;
1873 type ControlHandle = BatterySimulatorControllerControlHandle;
1874
1875 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1876 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1877 }
1878
1879 fn control_handle(&self) -> Self::ControlHandle {
1880 BatterySimulatorControllerControlHandle { inner: self.inner.clone() }
1881 }
1882
1883 fn into_inner(
1884 self,
1885 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1886 {
1887 (self.inner, self.is_terminated)
1888 }
1889
1890 fn from_inner(
1891 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1892 is_terminated: bool,
1893 ) -> Self {
1894 Self { inner, is_terminated }
1895 }
1896}
1897
1898impl futures::Stream for BatterySimulatorControllerRequestStream {
1899 type Item = Result<BatterySimulatorControllerRequest, fidl::Error>;
1900
1901 fn poll_next(
1902 mut self: std::pin::Pin<&mut Self>,
1903 cx: &mut std::task::Context<'_>,
1904 ) -> std::task::Poll<Option<Self::Item>> {
1905 let this = &mut *self;
1906 if this.inner.check_shutdown(cx) {
1907 this.is_terminated = true;
1908 return std::task::Poll::Ready(None);
1909 }
1910 if this.is_terminated {
1911 panic!("polled BatterySimulatorControllerRequestStream after completion");
1912 }
1913 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1914 |bytes, handles| {
1915 match this.inner.channel().read_etc(cx, bytes, handles) {
1916 std::task::Poll::Ready(Ok(())) => {}
1917 std::task::Poll::Pending => return std::task::Poll::Pending,
1918 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1919 this.is_terminated = true;
1920 return std::task::Poll::Ready(None);
1921 }
1922 std::task::Poll::Ready(Err(e)) => {
1923 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1924 e.into(),
1925 ))))
1926 }
1927 }
1928
1929 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1931
1932 std::task::Poll::Ready(Some(match header.ordinal {
1933 0x4a20d3731366aaf8 => {
1934 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1935 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1936 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1937 let control_handle = BatterySimulatorControllerControlHandle {
1938 inner: this.inner.clone(),
1939 };
1940 Ok(BatterySimulatorControllerRequest::GetBatteryInfo {
1941 responder: BatterySimulatorControllerGetBatteryInfoResponder {
1942 control_handle: std::mem::ManuallyDrop::new(control_handle),
1943 tx_id: header.tx_id,
1944 },
1945 })
1946 }
1947 0x2343eb65038c8b34 => {
1948 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1949 let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatteryStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1950 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryStatusRequest>(&header, _body_bytes, handles, &mut req)?;
1951 let control_handle = BatterySimulatorControllerControlHandle {
1952 inner: this.inner.clone(),
1953 };
1954 Ok(BatterySimulatorControllerRequest::SetBatteryStatus {battery_status: req.battery_status,
1955
1956 control_handle,
1957 })
1958 }
1959 0x79b2bf1a387acd85 => {
1960 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1961 let mut req = fidl::new_empty!(BatterySimulatorControllerSetChargeStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1962 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeStatusRequest>(&header, _body_bytes, handles, &mut req)?;
1963 let control_handle = BatterySimulatorControllerControlHandle {
1964 inner: this.inner.clone(),
1965 };
1966 Ok(BatterySimulatorControllerRequest::SetChargeStatus {charge_status: req.charge_status,
1967
1968 control_handle,
1969 })
1970 }
1971 0xb40433f42c33527 => {
1972 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1973 let mut req = fidl::new_empty!(BatterySimulatorControllerSetChargeSourceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1974 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
1975 let control_handle = BatterySimulatorControllerControlHandle {
1976 inner: this.inner.clone(),
1977 };
1978 Ok(BatterySimulatorControllerRequest::SetChargeSource {charge_source: req.charge_source,
1979
1980 control_handle,
1981 })
1982 }
1983 0x64a9d96eb7a45a9f => {
1984 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1985 let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatteryPercentageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1986 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryPercentageRequest>(&header, _body_bytes, handles, &mut req)?;
1987 let control_handle = BatterySimulatorControllerControlHandle {
1988 inner: this.inner.clone(),
1989 };
1990 Ok(BatterySimulatorControllerRequest::SetBatteryPercentage {percent: req.percent,
1991
1992 control_handle,
1993 })
1994 }
1995 0x577fc3314f7a48a4 => {
1996 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1997 let mut req = fidl::new_empty!(BatterySimulatorControllerSetLevelStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1998 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetLevelStatusRequest>(&header, _body_bytes, handles, &mut req)?;
1999 let control_handle = BatterySimulatorControllerControlHandle {
2000 inner: this.inner.clone(),
2001 };
2002 Ok(BatterySimulatorControllerRequest::SetLevelStatus {level_status: req.level_status,
2003
2004 control_handle,
2005 })
2006 }
2007 0x7427251c9d2a794e => {
2008 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2009 let mut req = fidl::new_empty!(BatterySimulatorControllerSetTimeRemainingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2010 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetTimeRemainingRequest>(&header, _body_bytes, handles, &mut req)?;
2011 let control_handle = BatterySimulatorControllerControlHandle {
2012 inner: this.inner.clone(),
2013 };
2014 Ok(BatterySimulatorControllerRequest::SetTimeRemaining {duration: req.duration,
2015
2016 control_handle,
2017 })
2018 }
2019 0x75588eae6b9b67e3 => {
2020 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2021 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2022 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2023 let control_handle = BatterySimulatorControllerControlHandle {
2024 inner: this.inner.clone(),
2025 };
2026 Ok(BatterySimulatorControllerRequest::DisconnectRealBattery {
2027 control_handle,
2028 })
2029 }
2030 0x4bf85cfe3476975d => {
2031 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2032 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2033 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2034 let control_handle = BatterySimulatorControllerControlHandle {
2035 inner: this.inner.clone(),
2036 };
2037 Ok(BatterySimulatorControllerRequest::IsSimulating {
2038 responder: BatterySimulatorControllerIsSimulatingResponder {
2039 control_handle: std::mem::ManuallyDrop::new(control_handle),
2040 tx_id: header.tx_id,
2041 },
2042 })
2043 }
2044 0x18306690352d9dfa => {
2045 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2046 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2047 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2048 let control_handle = BatterySimulatorControllerControlHandle {
2049 inner: this.inner.clone(),
2050 };
2051 Ok(BatterySimulatorControllerRequest::ReconnectRealBattery {
2052 control_handle,
2053 })
2054 }
2055 0x5462c9e9f947b8ce => {
2056 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2057 let mut req = fidl::new_empty!(BatterySimulatorControllerSetPresentVoltageMvRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2058 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetPresentVoltageMvRequest>(&header, _body_bytes, handles, &mut req)?;
2059 let control_handle = BatterySimulatorControllerControlHandle {
2060 inner: this.inner.clone(),
2061 };
2062 Ok(BatterySimulatorControllerRequest::SetPresentVoltageMv {voltage: req.voltage,
2063
2064 control_handle,
2065 })
2066 }
2067 0x38054049fe8c26ab => {
2068 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2069 let mut req = fidl::new_empty!(BatterySimulatorControllerSetRemainingCapacityUahRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2070 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(&header, _body_bytes, handles, &mut req)?;
2071 let control_handle = BatterySimulatorControllerControlHandle {
2072 inner: this.inner.clone(),
2073 };
2074 Ok(BatterySimulatorControllerRequest::SetRemainingCapacityUah {capacity: req.capacity,
2075
2076 control_handle,
2077 })
2078 }
2079 0x7324672546976583 => {
2080 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2081 let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatterySpecRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2082 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatterySpecRequest>(&header, _body_bytes, handles, &mut req)?;
2083 let control_handle = BatterySimulatorControllerControlHandle {
2084 inner: this.inner.clone(),
2085 };
2086 Ok(BatterySimulatorControllerRequest::SetBatterySpec {spec: req.spec,
2087
2088 control_handle,
2089 })
2090 }
2091 _ => Err(fidl::Error::UnknownOrdinal {
2092 ordinal: header.ordinal,
2093 protocol_name: <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2094 }),
2095 }))
2096 },
2097 )
2098 }
2099}
2100
2101#[derive(Debug)]
2103pub enum BatterySimulatorControllerRequest {
2104 GetBatteryInfo { responder: BatterySimulatorControllerGetBatteryInfoResponder },
2107 SetBatteryStatus {
2110 battery_status: fidl_fuchsia_power_battery::BatteryStatus,
2111 control_handle: BatterySimulatorControllerControlHandle,
2112 },
2113 SetChargeStatus {
2116 charge_status: fidl_fuchsia_power_battery::ChargeStatus,
2117 control_handle: BatterySimulatorControllerControlHandle,
2118 },
2119 SetChargeSource {
2122 charge_source: fidl_fuchsia_power_battery::ChargeSource,
2123 control_handle: BatterySimulatorControllerControlHandle,
2124 },
2125 SetBatteryPercentage { percent: f32, control_handle: BatterySimulatorControllerControlHandle },
2128 SetLevelStatus {
2131 level_status: fidl_fuchsia_power_battery::LevelStatus,
2132 control_handle: BatterySimulatorControllerControlHandle,
2133 },
2134 SetTimeRemaining { duration: i64, control_handle: BatterySimulatorControllerControlHandle },
2137 DisconnectRealBattery { control_handle: BatterySimulatorControllerControlHandle },
2139 IsSimulating { responder: BatterySimulatorControllerIsSimulatingResponder },
2141 ReconnectRealBattery { control_handle: BatterySimulatorControllerControlHandle },
2144 SetPresentVoltageMv { voltage: u32, control_handle: BatterySimulatorControllerControlHandle },
2147 SetRemainingCapacityUah {
2150 capacity: u32,
2151 control_handle: BatterySimulatorControllerControlHandle,
2152 },
2153 SetBatterySpec {
2155 spec: fidl_fuchsia_power_battery::BatterySpec,
2156 control_handle: BatterySimulatorControllerControlHandle,
2157 },
2158}
2159
2160impl BatterySimulatorControllerRequest {
2161 #[allow(irrefutable_let_patterns)]
2162 pub fn into_get_battery_info(
2163 self,
2164 ) -> Option<(BatterySimulatorControllerGetBatteryInfoResponder)> {
2165 if let BatterySimulatorControllerRequest::GetBatteryInfo { responder } = self {
2166 Some((responder))
2167 } else {
2168 None
2169 }
2170 }
2171
2172 #[allow(irrefutable_let_patterns)]
2173 pub fn into_set_battery_status(
2174 self,
2175 ) -> Option<(fidl_fuchsia_power_battery::BatteryStatus, BatterySimulatorControllerControlHandle)>
2176 {
2177 if let BatterySimulatorControllerRequest::SetBatteryStatus {
2178 battery_status,
2179 control_handle,
2180 } = self
2181 {
2182 Some((battery_status, control_handle))
2183 } else {
2184 None
2185 }
2186 }
2187
2188 #[allow(irrefutable_let_patterns)]
2189 pub fn into_set_charge_status(
2190 self,
2191 ) -> Option<(fidl_fuchsia_power_battery::ChargeStatus, BatterySimulatorControllerControlHandle)>
2192 {
2193 if let BatterySimulatorControllerRequest::SetChargeStatus {
2194 charge_status,
2195 control_handle,
2196 } = self
2197 {
2198 Some((charge_status, control_handle))
2199 } else {
2200 None
2201 }
2202 }
2203
2204 #[allow(irrefutable_let_patterns)]
2205 pub fn into_set_charge_source(
2206 self,
2207 ) -> Option<(fidl_fuchsia_power_battery::ChargeSource, BatterySimulatorControllerControlHandle)>
2208 {
2209 if let BatterySimulatorControllerRequest::SetChargeSource {
2210 charge_source,
2211 control_handle,
2212 } = self
2213 {
2214 Some((charge_source, control_handle))
2215 } else {
2216 None
2217 }
2218 }
2219
2220 #[allow(irrefutable_let_patterns)]
2221 pub fn into_set_battery_percentage(
2222 self,
2223 ) -> Option<(f32, BatterySimulatorControllerControlHandle)> {
2224 if let BatterySimulatorControllerRequest::SetBatteryPercentage { percent, control_handle } =
2225 self
2226 {
2227 Some((percent, control_handle))
2228 } else {
2229 None
2230 }
2231 }
2232
2233 #[allow(irrefutable_let_patterns)]
2234 pub fn into_set_level_status(
2235 self,
2236 ) -> Option<(fidl_fuchsia_power_battery::LevelStatus, BatterySimulatorControllerControlHandle)>
2237 {
2238 if let BatterySimulatorControllerRequest::SetLevelStatus { level_status, control_handle } =
2239 self
2240 {
2241 Some((level_status, control_handle))
2242 } else {
2243 None
2244 }
2245 }
2246
2247 #[allow(irrefutable_let_patterns)]
2248 pub fn into_set_time_remaining(self) -> Option<(i64, BatterySimulatorControllerControlHandle)> {
2249 if let BatterySimulatorControllerRequest::SetTimeRemaining { duration, control_handle } =
2250 self
2251 {
2252 Some((duration, control_handle))
2253 } else {
2254 None
2255 }
2256 }
2257
2258 #[allow(irrefutable_let_patterns)]
2259 pub fn into_disconnect_real_battery(self) -> Option<(BatterySimulatorControllerControlHandle)> {
2260 if let BatterySimulatorControllerRequest::DisconnectRealBattery { control_handle } = self {
2261 Some((control_handle))
2262 } else {
2263 None
2264 }
2265 }
2266
2267 #[allow(irrefutable_let_patterns)]
2268 pub fn into_is_simulating(self) -> Option<(BatterySimulatorControllerIsSimulatingResponder)> {
2269 if let BatterySimulatorControllerRequest::IsSimulating { responder } = self {
2270 Some((responder))
2271 } else {
2272 None
2273 }
2274 }
2275
2276 #[allow(irrefutable_let_patterns)]
2277 pub fn into_reconnect_real_battery(self) -> Option<(BatterySimulatorControllerControlHandle)> {
2278 if let BatterySimulatorControllerRequest::ReconnectRealBattery { control_handle } = self {
2279 Some((control_handle))
2280 } else {
2281 None
2282 }
2283 }
2284
2285 #[allow(irrefutable_let_patterns)]
2286 pub fn into_set_present_voltage_mv(
2287 self,
2288 ) -> Option<(u32, BatterySimulatorControllerControlHandle)> {
2289 if let BatterySimulatorControllerRequest::SetPresentVoltageMv { voltage, control_handle } =
2290 self
2291 {
2292 Some((voltage, control_handle))
2293 } else {
2294 None
2295 }
2296 }
2297
2298 #[allow(irrefutable_let_patterns)]
2299 pub fn into_set_remaining_capacity_uah(
2300 self,
2301 ) -> Option<(u32, BatterySimulatorControllerControlHandle)> {
2302 if let BatterySimulatorControllerRequest::SetRemainingCapacityUah {
2303 capacity,
2304 control_handle,
2305 } = self
2306 {
2307 Some((capacity, control_handle))
2308 } else {
2309 None
2310 }
2311 }
2312
2313 #[allow(irrefutable_let_patterns)]
2314 pub fn into_set_battery_spec(
2315 self,
2316 ) -> Option<(fidl_fuchsia_power_battery::BatterySpec, BatterySimulatorControllerControlHandle)>
2317 {
2318 if let BatterySimulatorControllerRequest::SetBatterySpec { spec, control_handle } = self {
2319 Some((spec, control_handle))
2320 } else {
2321 None
2322 }
2323 }
2324
2325 pub fn method_name(&self) -> &'static str {
2327 match *self {
2328 BatterySimulatorControllerRequest::GetBatteryInfo { .. } => "get_battery_info",
2329 BatterySimulatorControllerRequest::SetBatteryStatus { .. } => "set_battery_status",
2330 BatterySimulatorControllerRequest::SetChargeStatus { .. } => "set_charge_status",
2331 BatterySimulatorControllerRequest::SetChargeSource { .. } => "set_charge_source",
2332 BatterySimulatorControllerRequest::SetBatteryPercentage { .. } => {
2333 "set_battery_percentage"
2334 }
2335 BatterySimulatorControllerRequest::SetLevelStatus { .. } => "set_level_status",
2336 BatterySimulatorControllerRequest::SetTimeRemaining { .. } => "set_time_remaining",
2337 BatterySimulatorControllerRequest::DisconnectRealBattery { .. } => {
2338 "disconnect_real_battery"
2339 }
2340 BatterySimulatorControllerRequest::IsSimulating { .. } => "is_simulating",
2341 BatterySimulatorControllerRequest::ReconnectRealBattery { .. } => {
2342 "reconnect_real_battery"
2343 }
2344 BatterySimulatorControllerRequest::SetPresentVoltageMv { .. } => {
2345 "set_present_voltage_mv"
2346 }
2347 BatterySimulatorControllerRequest::SetRemainingCapacityUah { .. } => {
2348 "set_remaining_capacity_uah"
2349 }
2350 BatterySimulatorControllerRequest::SetBatterySpec { .. } => "set_battery_spec",
2351 }
2352 }
2353}
2354
2355#[derive(Debug, Clone)]
2356pub struct BatterySimulatorControllerControlHandle {
2357 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2358}
2359
2360impl fidl::endpoints::ControlHandle for BatterySimulatorControllerControlHandle {
2361 fn shutdown(&self) {
2362 self.inner.shutdown()
2363 }
2364 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2365 self.inner.shutdown_with_epitaph(status)
2366 }
2367
2368 fn is_closed(&self) -> bool {
2369 self.inner.channel().is_closed()
2370 }
2371 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2372 self.inner.channel().on_closed()
2373 }
2374
2375 #[cfg(target_os = "fuchsia")]
2376 fn signal_peer(
2377 &self,
2378 clear_mask: zx::Signals,
2379 set_mask: zx::Signals,
2380 ) -> Result<(), zx_status::Status> {
2381 use fidl::Peered;
2382 self.inner.channel().signal_peer(clear_mask, set_mask)
2383 }
2384}
2385
2386impl BatterySimulatorControllerControlHandle {}
2387
2388#[must_use = "FIDL methods require a response to be sent"]
2389#[derive(Debug)]
2390pub struct BatterySimulatorControllerGetBatteryInfoResponder {
2391 control_handle: std::mem::ManuallyDrop<BatterySimulatorControllerControlHandle>,
2392 tx_id: u32,
2393}
2394
2395impl std::ops::Drop for BatterySimulatorControllerGetBatteryInfoResponder {
2399 fn drop(&mut self) {
2400 self.control_handle.shutdown();
2401 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2403 }
2404}
2405
2406impl fidl::endpoints::Responder for BatterySimulatorControllerGetBatteryInfoResponder {
2407 type ControlHandle = BatterySimulatorControllerControlHandle;
2408
2409 fn control_handle(&self) -> &BatterySimulatorControllerControlHandle {
2410 &self.control_handle
2411 }
2412
2413 fn drop_without_shutdown(mut self) {
2414 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2416 std::mem::forget(self);
2418 }
2419}
2420
2421impl BatterySimulatorControllerGetBatteryInfoResponder {
2422 pub fn send(
2426 self,
2427 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
2428 ) -> Result<(), fidl::Error> {
2429 let _result = self.send_raw(info);
2430 if _result.is_err() {
2431 self.control_handle.shutdown();
2432 }
2433 self.drop_without_shutdown();
2434 _result
2435 }
2436
2437 pub fn send_no_shutdown_on_err(
2439 self,
2440 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
2441 ) -> Result<(), fidl::Error> {
2442 let _result = self.send_raw(info);
2443 self.drop_without_shutdown();
2444 _result
2445 }
2446
2447 fn send_raw(
2448 &self,
2449 mut info: &fidl_fuchsia_power_battery::BatteryInfo,
2450 ) -> Result<(), fidl::Error> {
2451 self.control_handle.inner.send::<BatterySimulatorControllerGetBatteryInfoResponse>(
2452 (info,),
2453 self.tx_id,
2454 0x4a20d3731366aaf8,
2455 fidl::encoding::DynamicFlags::empty(),
2456 )
2457 }
2458}
2459
2460#[must_use = "FIDL methods require a response to be sent"]
2461#[derive(Debug)]
2462pub struct BatterySimulatorControllerIsSimulatingResponder {
2463 control_handle: std::mem::ManuallyDrop<BatterySimulatorControllerControlHandle>,
2464 tx_id: u32,
2465}
2466
2467impl std::ops::Drop for BatterySimulatorControllerIsSimulatingResponder {
2471 fn drop(&mut self) {
2472 self.control_handle.shutdown();
2473 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2475 }
2476}
2477
2478impl fidl::endpoints::Responder for BatterySimulatorControllerIsSimulatingResponder {
2479 type ControlHandle = BatterySimulatorControllerControlHandle;
2480
2481 fn control_handle(&self) -> &BatterySimulatorControllerControlHandle {
2482 &self.control_handle
2483 }
2484
2485 fn drop_without_shutdown(mut self) {
2486 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2488 std::mem::forget(self);
2490 }
2491}
2492
2493impl BatterySimulatorControllerIsSimulatingResponder {
2494 pub fn send(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
2498 let _result = self.send_raw(simulation_state);
2499 if _result.is_err() {
2500 self.control_handle.shutdown();
2501 }
2502 self.drop_without_shutdown();
2503 _result
2504 }
2505
2506 pub fn send_no_shutdown_on_err(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
2508 let _result = self.send_raw(simulation_state);
2509 self.drop_without_shutdown();
2510 _result
2511 }
2512
2513 fn send_raw(&self, mut simulation_state: bool) -> Result<(), fidl::Error> {
2514 self.control_handle.inner.send::<BatterySimulatorControllerIsSimulatingResponse>(
2515 (simulation_state,),
2516 self.tx_id,
2517 0x4bf85cfe3476975d,
2518 fidl::encoding::DynamicFlags::empty(),
2519 )
2520 }
2521}
2522
2523mod internal {
2524 use super::*;
2525}