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