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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
514 self.inner.shutdown_with_epitaph(status)
515 }
516
517 fn is_closed(&self) -> bool {
518 self.inner.channel().is_closed()
519 }
520 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
521 self.inner.channel().on_closed()
522 }
523
524 #[cfg(target_os = "fuchsia")]
525 fn signal_peer(
526 &self,
527 clear_mask: zx::Signals,
528 set_mask: zx::Signals,
529 ) -> Result<(), zx_status::Status> {
530 use fidl::Peered;
531 self.inner.channel().signal_peer(clear_mask, set_mask)
532 }
533}
534
535impl DeviceControlHandle {}
536
537#[must_use = "FIDL methods require a response to be sent"]
538#[derive(Debug)]
539pub struct DeviceGetPowerWattsResponder {
540 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
541 tx_id: u32,
542}
543
544impl std::ops::Drop for DeviceGetPowerWattsResponder {
548 fn drop(&mut self) {
549 self.control_handle.shutdown();
550 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
552 }
553}
554
555impl fidl::endpoints::Responder for DeviceGetPowerWattsResponder {
556 type ControlHandle = DeviceControlHandle;
557
558 fn control_handle(&self) -> &DeviceControlHandle {
559 &self.control_handle
560 }
561
562 fn drop_without_shutdown(mut self) {
563 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565 std::mem::forget(self);
567 }
568}
569
570impl DeviceGetPowerWattsResponder {
571 pub fn send(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
575 let _result = self.send_raw(result);
576 if _result.is_err() {
577 self.control_handle.shutdown();
578 }
579 self.drop_without_shutdown();
580 _result
581 }
582
583 pub fn send_no_shutdown_on_err(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
585 let _result = self.send_raw(result);
586 self.drop_without_shutdown();
587 _result
588 }
589
590 fn send_raw(&self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
591 self.control_handle
592 .inner
593 .send::<fidl::encoding::ResultType<DeviceGetPowerWattsResponse, i32>>(
594 result.map(|power| (power,)),
595 self.tx_id,
596 0x552bb46982c1957b,
597 fidl::encoding::DynamicFlags::empty(),
598 )
599 }
600}
601
602#[must_use = "FIDL methods require a response to be sent"]
603#[derive(Debug)]
604pub struct DeviceGetVoltageVoltsResponder {
605 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
606 tx_id: u32,
607}
608
609impl std::ops::Drop for DeviceGetVoltageVoltsResponder {
613 fn drop(&mut self) {
614 self.control_handle.shutdown();
615 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
617 }
618}
619
620impl fidl::endpoints::Responder for DeviceGetVoltageVoltsResponder {
621 type ControlHandle = DeviceControlHandle;
622
623 fn control_handle(&self) -> &DeviceControlHandle {
624 &self.control_handle
625 }
626
627 fn drop_without_shutdown(mut self) {
628 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
630 std::mem::forget(self);
632 }
633}
634
635impl DeviceGetVoltageVoltsResponder {
636 pub fn send(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
640 let _result = self.send_raw(result);
641 if _result.is_err() {
642 self.control_handle.shutdown();
643 }
644 self.drop_without_shutdown();
645 _result
646 }
647
648 pub fn send_no_shutdown_on_err(self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
650 let _result = self.send_raw(result);
651 self.drop_without_shutdown();
652 _result
653 }
654
655 fn send_raw(&self, mut result: Result<f32, i32>) -> Result<(), fidl::Error> {
656 self.control_handle
657 .inner
658 .send::<fidl::encoding::ResultType<DeviceGetVoltageVoltsResponse, i32>>(
659 result.map(|voltage| (voltage,)),
660 self.tx_id,
661 0x4b0d0841e3445c37,
662 fidl::encoding::DynamicFlags::empty(),
663 )
664 }
665}
666
667#[must_use = "FIDL methods require a response to be sent"]
668#[derive(Debug)]
669pub struct DeviceGetSensorNameResponder {
670 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
671 tx_id: u32,
672}
673
674impl std::ops::Drop for DeviceGetSensorNameResponder {
678 fn drop(&mut self) {
679 self.control_handle.shutdown();
680 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
682 }
683}
684
685impl fidl::endpoints::Responder for DeviceGetSensorNameResponder {
686 type ControlHandle = DeviceControlHandle;
687
688 fn control_handle(&self) -> &DeviceControlHandle {
689 &self.control_handle
690 }
691
692 fn drop_without_shutdown(mut self) {
693 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
695 std::mem::forget(self);
697 }
698}
699
700impl DeviceGetSensorNameResponder {
701 pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
705 let _result = self.send_raw(name);
706 if _result.is_err() {
707 self.control_handle.shutdown();
708 }
709 self.drop_without_shutdown();
710 _result
711 }
712
713 pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
715 let _result = self.send_raw(name);
716 self.drop_without_shutdown();
717 _result
718 }
719
720 fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
721 self.control_handle.inner.send::<DeviceGetSensorNameResponse>(
722 (name,),
723 self.tx_id,
724 0x3cf646dfaf29b21a,
725 fidl::encoding::DynamicFlags::empty(),
726 )
727 }
728}
729
730#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
731pub struct ServiceMarker;
732
733#[cfg(target_os = "fuchsia")]
734impl fidl::endpoints::ServiceMarker for ServiceMarker {
735 type Proxy = ServiceProxy;
736 type Request = ServiceRequest;
737 const SERVICE_NAME: &'static str = "fuchsia.hardware.power.sensor.Service";
738}
739
740#[cfg(target_os = "fuchsia")]
743pub enum ServiceRequest {
744 Device(DeviceRequestStream),
745}
746
747#[cfg(target_os = "fuchsia")]
748impl fidl::endpoints::ServiceRequest for ServiceRequest {
749 type Service = ServiceMarker;
750
751 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
752 match name {
753 "device" => Self::Device(
754 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
755 ),
756 _ => panic!("no such member protocol name for service Service"),
757 }
758 }
759
760 fn member_names() -> &'static [&'static str] {
761 &["device"]
762 }
763}
764#[cfg(target_os = "fuchsia")]
765pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
766
767#[cfg(target_os = "fuchsia")]
768impl fidl::endpoints::ServiceProxy for ServiceProxy {
769 type Service = ServiceMarker;
770
771 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
772 Self(opener)
773 }
774}
775
776#[cfg(target_os = "fuchsia")]
777impl ServiceProxy {
778 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
779 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
780 self.connect_channel_to_device(server_end)?;
781 Ok(proxy)
782 }
783
784 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
787 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
788 self.connect_channel_to_device(server_end)?;
789 Ok(proxy)
790 }
791
792 pub fn connect_channel_to_device(
795 &self,
796 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
797 ) -> Result<(), fidl::Error> {
798 self.0.open_member("device", server_end.into_channel())
799 }
800
801 pub fn instance_name(&self) -> &str {
802 self.0.instance_name()
803 }
804}
805
806mod internal {
807 use super::*;
808}