1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_power_sensor__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18 type Proxy = DeviceProxy;
19 type RequestStream = DeviceRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DeviceSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.power.sensor.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceGetPowerWattsResult = Result<f32, i32>;
27pub type DeviceGetVoltageVoltsResult = Result<f32, i32>;
28
29pub trait DeviceProxyInterface: Send + Sync {
30 type GetPowerWattsResponseFut: std::future::Future<Output = Result<DeviceGetPowerWattsResult, fidl::Error>>
31 + Send;
32 fn r#get_power_watts(&self) -> Self::GetPowerWattsResponseFut;
33 type GetVoltageVoltsResponseFut: std::future::Future<Output = Result<DeviceGetVoltageVoltsResult, fidl::Error>>
34 + Send;
35 fn r#get_voltage_volts(&self) -> Self::GetVoltageVoltsResponseFut;
36 type GetSensorNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
37 fn r#get_sensor_name(&self) -> Self::GetSensorNameResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct DeviceSynchronousProxy {
42 client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
47 type Proxy = DeviceProxy;
48 type Protocol = DeviceMarker;
49
50 fn from_channel(inner: fidl::Channel) -> Self {
51 Self::new(inner)
52 }
53
54 fn into_channel(self) -> fidl::Channel {
55 self.client.into_channel()
56 }
57
58 fn as_channel(&self) -> &fidl::Channel {
59 self.client.as_channel()
60 }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl DeviceSynchronousProxy {
65 pub fn new(channel: fidl::Channel) -> Self {
66 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
67 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<DeviceEvent, fidl::Error> {
80 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
81 }
82
83 pub fn r#get_power_watts(
84 &self,
85 ___deadline: zx::MonotonicInstant,
86 ) -> Result<DeviceGetPowerWattsResult, fidl::Error> {
87 let _response = self.client.send_query::<
88 fidl::encoding::EmptyPayload,
89 fidl::encoding::ResultType<DeviceGetPowerWattsResponse, i32>,
90 >(
91 (),
92 0x552bb46982c1957b,
93 fidl::encoding::DynamicFlags::empty(),
94 ___deadline,
95 )?;
96 Ok(_response.map(|x| x.power))
97 }
98
99 pub fn r#get_voltage_volts(
100 &self,
101 ___deadline: zx::MonotonicInstant,
102 ) -> Result<DeviceGetVoltageVoltsResult, fidl::Error> {
103 let _response = self.client.send_query::<
104 fidl::encoding::EmptyPayload,
105 fidl::encoding::ResultType<DeviceGetVoltageVoltsResponse, i32>,
106 >(
107 (),
108 0x4b0d0841e3445c37,
109 fidl::encoding::DynamicFlags::empty(),
110 ___deadline,
111 )?;
112 Ok(_response.map(|x| x.voltage))
113 }
114
115 pub fn r#get_sensor_name(
116 &self,
117 ___deadline: zx::MonotonicInstant,
118 ) -> Result<String, fidl::Error> {
119 let _response =
120 self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetSensorNameResponse>(
121 (),
122 0x3cf646dfaf29b21a,
123 fidl::encoding::DynamicFlags::empty(),
124 ___deadline,
125 )?;
126 Ok(_response.name)
127 }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl From<DeviceSynchronousProxy> for zx::NullableHandle {
132 fn from(value: DeviceSynchronousProxy) -> Self {
133 value.into_channel().into()
134 }
135}
136
137#[cfg(target_os = "fuchsia")]
138impl From<fidl::Channel> for DeviceSynchronousProxy {
139 fn from(value: fidl::Channel) -> Self {
140 Self::new(value)
141 }
142}
143
144#[cfg(target_os = "fuchsia")]
145impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
146 type Protocol = DeviceMarker;
147
148 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
149 Self::new(value.into_channel())
150 }
151}
152
153#[derive(Debug, Clone)]
154pub struct DeviceProxy {
155 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
156}
157
158impl fidl::endpoints::Proxy for DeviceProxy {
159 type Protocol = DeviceMarker;
160
161 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
162 Self::new(inner)
163 }
164
165 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
166 self.client.into_channel().map_err(|client| Self { client })
167 }
168
169 fn as_channel(&self) -> &::fidl::AsyncChannel {
170 self.client.as_channel()
171 }
172}
173
174impl DeviceProxy {
175 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
177 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
178 Self { client: fidl::client::Client::new(channel, protocol_name) }
179 }
180
181 pub fn take_event_stream(&self) -> DeviceEventStream {
187 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
188 }
189
190 pub fn r#get_power_watts(
191 &self,
192 ) -> fidl::client::QueryResponseFut<
193 DeviceGetPowerWattsResult,
194 fidl::encoding::DefaultFuchsiaResourceDialect,
195 > {
196 DeviceProxyInterface::r#get_power_watts(self)
197 }
198
199 pub fn r#get_voltage_volts(
200 &self,
201 ) -> fidl::client::QueryResponseFut<
202 DeviceGetVoltageVoltsResult,
203 fidl::encoding::DefaultFuchsiaResourceDialect,
204 > {
205 DeviceProxyInterface::r#get_voltage_volts(self)
206 }
207
208 pub fn r#get_sensor_name(
209 &self,
210 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
211 DeviceProxyInterface::r#get_sensor_name(self)
212 }
213}
214
215impl DeviceProxyInterface for DeviceProxy {
216 type GetPowerWattsResponseFut = fidl::client::QueryResponseFut<
217 DeviceGetPowerWattsResult,
218 fidl::encoding::DefaultFuchsiaResourceDialect,
219 >;
220 fn r#get_power_watts(&self) -> Self::GetPowerWattsResponseFut {
221 fn _decode(
222 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
223 ) -> Result<DeviceGetPowerWattsResult, fidl::Error> {
224 let _response = fidl::client::decode_transaction_body::<
225 fidl::encoding::ResultType<DeviceGetPowerWattsResponse, i32>,
226 fidl::encoding::DefaultFuchsiaResourceDialect,
227 0x552bb46982c1957b,
228 >(_buf?)?;
229 Ok(_response.map(|x| x.power))
230 }
231 self.client
232 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetPowerWattsResult>(
233 (),
234 0x552bb46982c1957b,
235 fidl::encoding::DynamicFlags::empty(),
236 _decode,
237 )
238 }
239
240 type GetVoltageVoltsResponseFut = fidl::client::QueryResponseFut<
241 DeviceGetVoltageVoltsResult,
242 fidl::encoding::DefaultFuchsiaResourceDialect,
243 >;
244 fn r#get_voltage_volts(&self) -> Self::GetVoltageVoltsResponseFut {
245 fn _decode(
246 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
247 ) -> Result<DeviceGetVoltageVoltsResult, fidl::Error> {
248 let _response = fidl::client::decode_transaction_body::<
249 fidl::encoding::ResultType<DeviceGetVoltageVoltsResponse, i32>,
250 fidl::encoding::DefaultFuchsiaResourceDialect,
251 0x4b0d0841e3445c37,
252 >(_buf?)?;
253 Ok(_response.map(|x| x.voltage))
254 }
255 self.client
256 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetVoltageVoltsResult>(
257 (),
258 0x4b0d0841e3445c37,
259 fidl::encoding::DynamicFlags::empty(),
260 _decode,
261 )
262 }
263
264 type GetSensorNameResponseFut =
265 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
266 fn r#get_sensor_name(&self) -> Self::GetSensorNameResponseFut {
267 fn _decode(
268 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
269 ) -> Result<String, fidl::Error> {
270 let _response = fidl::client::decode_transaction_body::<
271 DeviceGetSensorNameResponse,
272 fidl::encoding::DefaultFuchsiaResourceDialect,
273 0x3cf646dfaf29b21a,
274 >(_buf?)?;
275 Ok(_response.name)
276 }
277 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
278 (),
279 0x3cf646dfaf29b21a,
280 fidl::encoding::DynamicFlags::empty(),
281 _decode,
282 )
283 }
284}
285
286pub struct DeviceEventStream {
287 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
288}
289
290impl std::marker::Unpin for DeviceEventStream {}
291
292impl futures::stream::FusedStream for DeviceEventStream {
293 fn is_terminated(&self) -> bool {
294 self.event_receiver.is_terminated()
295 }
296}
297
298impl futures::Stream for DeviceEventStream {
299 type Item = Result<DeviceEvent, fidl::Error>;
300
301 fn poll_next(
302 mut self: std::pin::Pin<&mut Self>,
303 cx: &mut std::task::Context<'_>,
304 ) -> std::task::Poll<Option<Self::Item>> {
305 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
306 &mut self.event_receiver,
307 cx
308 )?) {
309 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
310 None => std::task::Poll::Ready(None),
311 }
312 }
313}
314
315#[derive(Debug)]
316pub enum DeviceEvent {}
317
318impl DeviceEvent {
319 fn decode(
321 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
322 ) -> Result<DeviceEvent, fidl::Error> {
323 let (bytes, _handles) = buf.split_mut();
324 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
325 debug_assert_eq!(tx_header.tx_id, 0);
326 match tx_header.ordinal {
327 _ => Err(fidl::Error::UnknownOrdinal {
328 ordinal: tx_header.ordinal,
329 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330 }),
331 }
332 }
333}
334
335pub struct DeviceRequestStream {
337 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
338 is_terminated: bool,
339}
340
341impl std::marker::Unpin for DeviceRequestStream {}
342
343impl futures::stream::FusedStream for DeviceRequestStream {
344 fn is_terminated(&self) -> bool {
345 self.is_terminated
346 }
347}
348
349impl fidl::endpoints::RequestStream for DeviceRequestStream {
350 type Protocol = DeviceMarker;
351 type ControlHandle = DeviceControlHandle;
352
353 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
354 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
355 }
356
357 fn control_handle(&self) -> Self::ControlHandle {
358 DeviceControlHandle { inner: self.inner.clone() }
359 }
360
361 fn into_inner(
362 self,
363 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
364 {
365 (self.inner, self.is_terminated)
366 }
367
368 fn from_inner(
369 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
370 is_terminated: bool,
371 ) -> Self {
372 Self { inner, is_terminated }
373 }
374}
375
376impl futures::Stream for DeviceRequestStream {
377 type Item = Result<DeviceRequest, fidl::Error>;
378
379 fn poll_next(
380 mut self: std::pin::Pin<&mut Self>,
381 cx: &mut std::task::Context<'_>,
382 ) -> std::task::Poll<Option<Self::Item>> {
383 let this = &mut *self;
384 if this.inner.check_shutdown(cx) {
385 this.is_terminated = true;
386 return std::task::Poll::Ready(None);
387 }
388 if this.is_terminated {
389 panic!("polled DeviceRequestStream after completion");
390 }
391 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
392 |bytes, handles| {
393 match this.inner.channel().read_etc(cx, bytes, handles) {
394 std::task::Poll::Ready(Ok(())) => {}
395 std::task::Poll::Pending => return std::task::Poll::Pending,
396 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
397 this.is_terminated = true;
398 return std::task::Poll::Ready(None);
399 }
400 std::task::Poll::Ready(Err(e)) => {
401 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
402 e.into(),
403 ))));
404 }
405 }
406
407 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
409
410 std::task::Poll::Ready(Some(match header.ordinal {
411 0x552bb46982c1957b => {
412 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
413 let mut req = fidl::new_empty!(
414 fidl::encoding::EmptyPayload,
415 fidl::encoding::DefaultFuchsiaResourceDialect
416 );
417 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
418 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
419 Ok(DeviceRequest::GetPowerWatts {
420 responder: DeviceGetPowerWattsResponder {
421 control_handle: std::mem::ManuallyDrop::new(control_handle),
422 tx_id: header.tx_id,
423 },
424 })
425 }
426 0x4b0d0841e3445c37 => {
427 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
428 let mut req = fidl::new_empty!(
429 fidl::encoding::EmptyPayload,
430 fidl::encoding::DefaultFuchsiaResourceDialect
431 );
432 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
433 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
434 Ok(DeviceRequest::GetVoltageVolts {
435 responder: DeviceGetVoltageVoltsResponder {
436 control_handle: std::mem::ManuallyDrop::new(control_handle),
437 tx_id: header.tx_id,
438 },
439 })
440 }
441 0x3cf646dfaf29b21a => {
442 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
443 let mut req = fidl::new_empty!(
444 fidl::encoding::EmptyPayload,
445 fidl::encoding::DefaultFuchsiaResourceDialect
446 );
447 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
448 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
449 Ok(DeviceRequest::GetSensorName {
450 responder: DeviceGetSensorNameResponder {
451 control_handle: std::mem::ManuallyDrop::new(control_handle),
452 tx_id: header.tx_id,
453 },
454 })
455 }
456 _ => Err(fidl::Error::UnknownOrdinal {
457 ordinal: header.ordinal,
458 protocol_name:
459 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
460 }),
461 }))
462 },
463 )
464 }
465}
466
467#[derive(Debug)]
468pub enum DeviceRequest {
469 GetPowerWatts { responder: DeviceGetPowerWattsResponder },
470 GetVoltageVolts { responder: DeviceGetVoltageVoltsResponder },
471 GetSensorName { responder: DeviceGetSensorNameResponder },
472}
473
474impl DeviceRequest {
475 #[allow(irrefutable_let_patterns)]
476 pub fn into_get_power_watts(self) -> Option<(DeviceGetPowerWattsResponder)> {
477 if let DeviceRequest::GetPowerWatts { responder } = self { Some((responder)) } else { None }
478 }
479
480 #[allow(irrefutable_let_patterns)]
481 pub fn into_get_voltage_volts(self) -> Option<(DeviceGetVoltageVoltsResponder)> {
482 if let DeviceRequest::GetVoltageVolts { responder } = self {
483 Some((responder))
484 } else {
485 None
486 }
487 }
488
489 #[allow(irrefutable_let_patterns)]
490 pub fn into_get_sensor_name(self) -> Option<(DeviceGetSensorNameResponder)> {
491 if let DeviceRequest::GetSensorName { responder } = self { Some((responder)) } else { None }
492 }
493
494 pub fn method_name(&self) -> &'static str {
496 match *self {
497 DeviceRequest::GetPowerWatts { .. } => "get_power_watts",
498 DeviceRequest::GetVoltageVolts { .. } => "get_voltage_volts",
499 DeviceRequest::GetSensorName { .. } => "get_sensor_name",
500 }
501 }
502}
503
504#[derive(Debug, Clone)]
505pub struct DeviceControlHandle {
506 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
507}
508
509impl fidl::endpoints::ControlHandle for DeviceControlHandle {
510 fn shutdown(&self) {
511 self.inner.shutdown()
512 }
513
514 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
515 self.inner.shutdown_with_epitaph(status)
516 }
517
518 fn is_closed(&self) -> bool {
519 self.inner.channel().is_closed()
520 }
521 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
522 self.inner.channel().on_closed()
523 }
524
525 #[cfg(target_os = "fuchsia")]
526 fn signal_peer(
527 &self,
528 clear_mask: zx::Signals,
529 set_mask: zx::Signals,
530 ) -> Result<(), zx_status::Status> {
531 use fidl::Peered;
532 self.inner.channel().signal_peer(clear_mask, set_mask)
533 }
534}
535
536impl DeviceControlHandle {}
537
538#[must_use = "FIDL methods require a response to be sent"]
539#[derive(Debug)]
540pub struct DeviceGetPowerWattsResponder {
541 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
542 tx_id: u32,
543}
544
545impl std::ops::Drop for DeviceGetPowerWattsResponder {
549 fn drop(&mut self) {
550 self.control_handle.shutdown();
551 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553 }
554}
555
556impl fidl::endpoints::Responder for DeviceGetPowerWattsResponder {
557 type ControlHandle = DeviceControlHandle;
558
559 fn control_handle(&self) -> &DeviceControlHandle {
560 &self.control_handle
561 }
562
563 fn drop_without_shutdown(mut self) {
564 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566 std::mem::forget(self);
568 }
569}
570
571impl DeviceGetPowerWattsResponder {
572 pub fn send(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
576 let _result = self.send_raw(result);
577 if _result.is_err() {
578 self.control_handle.shutdown();
579 }
580 self.drop_without_shutdown();
581 _result
582 }
583
584 pub fn send_no_shutdown_on_err(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
586 let _result = self.send_raw(result);
587 self.drop_without_shutdown();
588 _result
589 }
590
591 fn send_raw(&self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
592 self.control_handle
593 .inner
594 .send::<fidl::encoding::ResultType<DeviceGetPowerWattsResponse, i32>>(
595 result.map(|power| (power,)),
596 self.tx_id,
597 0x552bb46982c1957b,
598 fidl::encoding::DynamicFlags::empty(),
599 )
600 }
601}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct DeviceGetVoltageVoltsResponder {
606 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
607 tx_id: u32,
608}
609
610impl std::ops::Drop for DeviceGetVoltageVoltsResponder {
614 fn drop(&mut self) {
615 self.control_handle.shutdown();
616 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618 }
619}
620
621impl fidl::endpoints::Responder for DeviceGetVoltageVoltsResponder {
622 type ControlHandle = DeviceControlHandle;
623
624 fn control_handle(&self) -> &DeviceControlHandle {
625 &self.control_handle
626 }
627
628 fn drop_without_shutdown(mut self) {
629 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631 std::mem::forget(self);
633 }
634}
635
636impl DeviceGetVoltageVoltsResponder {
637 pub fn send(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
641 let _result = self.send_raw(result);
642 if _result.is_err() {
643 self.control_handle.shutdown();
644 }
645 self.drop_without_shutdown();
646 _result
647 }
648
649 pub fn send_no_shutdown_on_err(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
651 let _result = self.send_raw(result);
652 self.drop_without_shutdown();
653 _result
654 }
655
656 fn send_raw(&self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
657 self.control_handle
658 .inner
659 .send::<fidl::encoding::ResultType<DeviceGetVoltageVoltsResponse, i32>>(
660 result.map(|voltage| (voltage,)),
661 self.tx_id,
662 0x4b0d0841e3445c37,
663 fidl::encoding::DynamicFlags::empty(),
664 )
665 }
666}
667
668#[must_use = "FIDL methods require a response to be sent"]
669#[derive(Debug)]
670pub struct DeviceGetSensorNameResponder {
671 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
672 tx_id: u32,
673}
674
675impl std::ops::Drop for DeviceGetSensorNameResponder {
679 fn drop(&mut self) {
680 self.control_handle.shutdown();
681 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
683 }
684}
685
686impl fidl::endpoints::Responder for DeviceGetSensorNameResponder {
687 type ControlHandle = DeviceControlHandle;
688
689 fn control_handle(&self) -> &DeviceControlHandle {
690 &self.control_handle
691 }
692
693 fn drop_without_shutdown(mut self) {
694 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
696 std::mem::forget(self);
698 }
699}
700
701impl DeviceGetSensorNameResponder {
702 pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
706 let _result = self.send_raw(name);
707 if _result.is_err() {
708 self.control_handle.shutdown();
709 }
710 self.drop_without_shutdown();
711 _result
712 }
713
714 pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
716 let _result = self.send_raw(name);
717 self.drop_without_shutdown();
718 _result
719 }
720
721 fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
722 self.control_handle.inner.send::<DeviceGetSensorNameResponse>(
723 (name,),
724 self.tx_id,
725 0x3cf646dfaf29b21a,
726 fidl::encoding::DynamicFlags::empty(),
727 )
728 }
729}
730
731#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
732pub struct ServiceMarker;
733
734#[cfg(target_os = "fuchsia")]
735impl fidl::endpoints::ServiceMarker for ServiceMarker {
736 type Proxy = ServiceProxy;
737 type Request = ServiceRequest;
738 const SERVICE_NAME: &'static str = "fuchsia.hardware.power.sensor.Service";
739}
740
741#[cfg(target_os = "fuchsia")]
744pub enum ServiceRequest {
745 Device(DeviceRequestStream),
746}
747
748#[cfg(target_os = "fuchsia")]
749impl fidl::endpoints::ServiceRequest for ServiceRequest {
750 type Service = ServiceMarker;
751
752 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
753 match name {
754 "device" => Self::Device(
755 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
756 ),
757 _ => panic!("no such member protocol name for service Service"),
758 }
759 }
760
761 fn member_names() -> &'static [&'static str] {
762 &["device"]
763 }
764}
765#[cfg(target_os = "fuchsia")]
766pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
767
768#[cfg(target_os = "fuchsia")]
769impl fidl::endpoints::ServiceProxy for ServiceProxy {
770 type Service = ServiceMarker;
771
772 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
773 Self(opener)
774 }
775}
776
777#[cfg(target_os = "fuchsia")]
778impl ServiceProxy {
779 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
780 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
781 self.connect_channel_to_device(server_end)?;
782 Ok(proxy)
783 }
784
785 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
788 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
789 self.connect_channel_to_device(server_end)?;
790 Ok(proxy)
791 }
792
793 pub fn connect_channel_to_device(
796 &self,
797 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
798 ) -> Result<(), fidl::Error> {
799 self.0.open_member("device", server_end.into_channel())
800 }
801
802 pub fn instance_name(&self) -> &str {
803 self.0.instance_name()
804 }
805}
806
807mod internal {
808 use super::*;
809}