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_google_odpm_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.google.odpm.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceGetRailMetadataResult = Result<RailMetadata, i32>;
27pub type DeviceGetPowerWattsResult = Result<PowerReading, i32>;
28pub type DeviceGetCurrentAmperesResult = Result<CurrentReading, i32>;
29pub type DeviceGetEnergyJoulesResult = Result<EnergyReading, i32>;
30
31pub trait DeviceProxyInterface: Send + Sync {
32 type GetRailMetadataResponseFut: std::future::Future<Output = Result<DeviceGetRailMetadataResult, fidl::Error>>
33 + Send;
34 fn r#get_rail_metadata(&self) -> Self::GetRailMetadataResponseFut;
35 type GetPowerWattsResponseFut: std::future::Future<Output = Result<DeviceGetPowerWattsResult, fidl::Error>>
36 + Send;
37 fn r#get_power_watts(&self, payload: &Options) -> Self::GetPowerWattsResponseFut;
38 type GetCurrentAmperesResponseFut: std::future::Future<Output = Result<DeviceGetCurrentAmperesResult, fidl::Error>>
39 + Send;
40 fn r#get_current_amperes(&self, payload: &Options) -> Self::GetCurrentAmperesResponseFut;
41 type GetEnergyJoulesResponseFut: std::future::Future<Output = Result<DeviceGetEnergyJoulesResult, fidl::Error>>
42 + Send;
43 fn r#get_energy_joules(&self, payload: &Options) -> Self::GetEnergyJoulesResponseFut;
44}
45#[derive(Debug)]
46#[cfg(target_os = "fuchsia")]
47pub struct DeviceSynchronousProxy {
48 client: fidl::client::sync::Client,
49}
50
51#[cfg(target_os = "fuchsia")]
52impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
53 type Proxy = DeviceProxy;
54 type Protocol = DeviceMarker;
55
56 fn from_channel(inner: fidl::Channel) -> Self {
57 Self::new(inner)
58 }
59
60 fn into_channel(self) -> fidl::Channel {
61 self.client.into_channel()
62 }
63
64 fn as_channel(&self) -> &fidl::Channel {
65 self.client.as_channel()
66 }
67}
68
69#[cfg(target_os = "fuchsia")]
70impl DeviceSynchronousProxy {
71 pub fn new(channel: fidl::Channel) -> Self {
72 Self { client: fidl::client::sync::Client::new(channel) }
73 }
74
75 pub fn into_channel(self) -> fidl::Channel {
76 self.client.into_channel()
77 }
78
79 pub fn wait_for_event(
82 &self,
83 deadline: zx::MonotonicInstant,
84 ) -> Result<DeviceEvent, fidl::Error> {
85 DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
86 }
87
88 pub fn r#get_rail_metadata(
90 &self,
91 ___deadline: zx::MonotonicInstant,
92 ) -> Result<DeviceGetRailMetadataResult, fidl::Error> {
93 let _response = self.client.send_query::<
94 fidl::encoding::EmptyPayload,
95 fidl::encoding::FlexibleResultType<RailMetadata, i32>,
96 DeviceMarker,
97 >(
98 (),
99 0x10f1af06f7642901,
100 fidl::encoding::DynamicFlags::FLEXIBLE,
101 ___deadline,
102 )?
103 .into_result::<DeviceMarker>("get_rail_metadata")?;
104 Ok(_response.map(|x| x))
105 }
106
107 pub fn r#get_power_watts(
110 &self,
111 mut payload: &Options,
112 ___deadline: zx::MonotonicInstant,
113 ) -> Result<DeviceGetPowerWattsResult, fidl::Error> {
114 let _response = self.client.send_query::<
115 Options,
116 fidl::encoding::FlexibleResultType<PowerReading, i32>,
117 DeviceMarker,
118 >(
119 payload,
120 0x3f8ada9ce9065924,
121 fidl::encoding::DynamicFlags::FLEXIBLE,
122 ___deadline,
123 )?
124 .into_result::<DeviceMarker>("get_power_watts")?;
125 Ok(_response.map(|x| x))
126 }
127
128 pub fn r#get_current_amperes(
131 &self,
132 mut payload: &Options,
133 ___deadline: zx::MonotonicInstant,
134 ) -> Result<DeviceGetCurrentAmperesResult, fidl::Error> {
135 let _response = self.client.send_query::<
136 Options,
137 fidl::encoding::FlexibleResultType<CurrentReading, i32>,
138 DeviceMarker,
139 >(
140 payload,
141 0x22fb9ad39b15d8a5,
142 fidl::encoding::DynamicFlags::FLEXIBLE,
143 ___deadline,
144 )?
145 .into_result::<DeviceMarker>("get_current_amperes")?;
146 Ok(_response.map(|x| x))
147 }
148
149 pub fn r#get_energy_joules(
152 &self,
153 mut payload: &Options,
154 ___deadline: zx::MonotonicInstant,
155 ) -> Result<DeviceGetEnergyJoulesResult, fidl::Error> {
156 let _response = self.client.send_query::<
157 Options,
158 fidl::encoding::FlexibleResultType<EnergyReading, i32>,
159 DeviceMarker,
160 >(
161 payload,
162 0x4bd34b82e636efc9,
163 fidl::encoding::DynamicFlags::FLEXIBLE,
164 ___deadline,
165 )?
166 .into_result::<DeviceMarker>("get_energy_joules")?;
167 Ok(_response.map(|x| x))
168 }
169}
170
171#[cfg(target_os = "fuchsia")]
172impl From<DeviceSynchronousProxy> for zx::NullableHandle {
173 fn from(value: DeviceSynchronousProxy) -> Self {
174 value.into_channel().into()
175 }
176}
177
178#[cfg(target_os = "fuchsia")]
179impl From<fidl::Channel> for DeviceSynchronousProxy {
180 fn from(value: fidl::Channel) -> Self {
181 Self::new(value)
182 }
183}
184
185#[cfg(target_os = "fuchsia")]
186impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
187 type Protocol = DeviceMarker;
188
189 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
190 Self::new(value.into_channel())
191 }
192}
193
194#[derive(Debug, Clone)]
195pub struct DeviceProxy {
196 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl fidl::endpoints::Proxy for DeviceProxy {
200 type Protocol = DeviceMarker;
201
202 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
203 Self::new(inner)
204 }
205
206 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
207 self.client.into_channel().map_err(|client| Self { client })
208 }
209
210 fn as_channel(&self) -> &::fidl::AsyncChannel {
211 self.client.as_channel()
212 }
213}
214
215impl DeviceProxy {
216 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
218 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
219 Self { client: fidl::client::Client::new(channel, protocol_name) }
220 }
221
222 pub fn take_event_stream(&self) -> DeviceEventStream {
228 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
229 }
230
231 pub fn r#get_rail_metadata(
233 &self,
234 ) -> fidl::client::QueryResponseFut<
235 DeviceGetRailMetadataResult,
236 fidl::encoding::DefaultFuchsiaResourceDialect,
237 > {
238 DeviceProxyInterface::r#get_rail_metadata(self)
239 }
240
241 pub fn r#get_power_watts(
244 &self,
245 mut payload: &Options,
246 ) -> fidl::client::QueryResponseFut<
247 DeviceGetPowerWattsResult,
248 fidl::encoding::DefaultFuchsiaResourceDialect,
249 > {
250 DeviceProxyInterface::r#get_power_watts(self, payload)
251 }
252
253 pub fn r#get_current_amperes(
256 &self,
257 mut payload: &Options,
258 ) -> fidl::client::QueryResponseFut<
259 DeviceGetCurrentAmperesResult,
260 fidl::encoding::DefaultFuchsiaResourceDialect,
261 > {
262 DeviceProxyInterface::r#get_current_amperes(self, payload)
263 }
264
265 pub fn r#get_energy_joules(
268 &self,
269 mut payload: &Options,
270 ) -> fidl::client::QueryResponseFut<
271 DeviceGetEnergyJoulesResult,
272 fidl::encoding::DefaultFuchsiaResourceDialect,
273 > {
274 DeviceProxyInterface::r#get_energy_joules(self, payload)
275 }
276}
277
278impl DeviceProxyInterface for DeviceProxy {
279 type GetRailMetadataResponseFut = fidl::client::QueryResponseFut<
280 DeviceGetRailMetadataResult,
281 fidl::encoding::DefaultFuchsiaResourceDialect,
282 >;
283 fn r#get_rail_metadata(&self) -> Self::GetRailMetadataResponseFut {
284 fn _decode(
285 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
286 ) -> Result<DeviceGetRailMetadataResult, fidl::Error> {
287 let _response = fidl::client::decode_transaction_body::<
288 fidl::encoding::FlexibleResultType<RailMetadata, i32>,
289 fidl::encoding::DefaultFuchsiaResourceDialect,
290 0x10f1af06f7642901,
291 >(_buf?)?
292 .into_result::<DeviceMarker>("get_rail_metadata")?;
293 Ok(_response.map(|x| x))
294 }
295 self.client
296 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetRailMetadataResult>(
297 (),
298 0x10f1af06f7642901,
299 fidl::encoding::DynamicFlags::FLEXIBLE,
300 _decode,
301 )
302 }
303
304 type GetPowerWattsResponseFut = fidl::client::QueryResponseFut<
305 DeviceGetPowerWattsResult,
306 fidl::encoding::DefaultFuchsiaResourceDialect,
307 >;
308 fn r#get_power_watts(&self, mut payload: &Options) -> Self::GetPowerWattsResponseFut {
309 fn _decode(
310 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
311 ) -> Result<DeviceGetPowerWattsResult, fidl::Error> {
312 let _response = fidl::client::decode_transaction_body::<
313 fidl::encoding::FlexibleResultType<PowerReading, i32>,
314 fidl::encoding::DefaultFuchsiaResourceDialect,
315 0x3f8ada9ce9065924,
316 >(_buf?)?
317 .into_result::<DeviceMarker>("get_power_watts")?;
318 Ok(_response.map(|x| x))
319 }
320 self.client.send_query_and_decode::<Options, DeviceGetPowerWattsResult>(
321 payload,
322 0x3f8ada9ce9065924,
323 fidl::encoding::DynamicFlags::FLEXIBLE,
324 _decode,
325 )
326 }
327
328 type GetCurrentAmperesResponseFut = fidl::client::QueryResponseFut<
329 DeviceGetCurrentAmperesResult,
330 fidl::encoding::DefaultFuchsiaResourceDialect,
331 >;
332 fn r#get_current_amperes(&self, mut payload: &Options) -> Self::GetCurrentAmperesResponseFut {
333 fn _decode(
334 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
335 ) -> Result<DeviceGetCurrentAmperesResult, fidl::Error> {
336 let _response = fidl::client::decode_transaction_body::<
337 fidl::encoding::FlexibleResultType<CurrentReading, i32>,
338 fidl::encoding::DefaultFuchsiaResourceDialect,
339 0x22fb9ad39b15d8a5,
340 >(_buf?)?
341 .into_result::<DeviceMarker>("get_current_amperes")?;
342 Ok(_response.map(|x| x))
343 }
344 self.client.send_query_and_decode::<Options, DeviceGetCurrentAmperesResult>(
345 payload,
346 0x22fb9ad39b15d8a5,
347 fidl::encoding::DynamicFlags::FLEXIBLE,
348 _decode,
349 )
350 }
351
352 type GetEnergyJoulesResponseFut = fidl::client::QueryResponseFut<
353 DeviceGetEnergyJoulesResult,
354 fidl::encoding::DefaultFuchsiaResourceDialect,
355 >;
356 fn r#get_energy_joules(&self, mut payload: &Options) -> Self::GetEnergyJoulesResponseFut {
357 fn _decode(
358 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
359 ) -> Result<DeviceGetEnergyJoulesResult, fidl::Error> {
360 let _response = fidl::client::decode_transaction_body::<
361 fidl::encoding::FlexibleResultType<EnergyReading, i32>,
362 fidl::encoding::DefaultFuchsiaResourceDialect,
363 0x4bd34b82e636efc9,
364 >(_buf?)?
365 .into_result::<DeviceMarker>("get_energy_joules")?;
366 Ok(_response.map(|x| x))
367 }
368 self.client.send_query_and_decode::<Options, DeviceGetEnergyJoulesResult>(
369 payload,
370 0x4bd34b82e636efc9,
371 fidl::encoding::DynamicFlags::FLEXIBLE,
372 _decode,
373 )
374 }
375}
376
377pub struct DeviceEventStream {
378 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
379}
380
381impl std::marker::Unpin for DeviceEventStream {}
382
383impl futures::stream::FusedStream for DeviceEventStream {
384 fn is_terminated(&self) -> bool {
385 self.event_receiver.is_terminated()
386 }
387}
388
389impl futures::Stream for DeviceEventStream {
390 type Item = Result<DeviceEvent, fidl::Error>;
391
392 fn poll_next(
393 mut self: std::pin::Pin<&mut Self>,
394 cx: &mut std::task::Context<'_>,
395 ) -> std::task::Poll<Option<Self::Item>> {
396 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
397 &mut self.event_receiver,
398 cx
399 )?) {
400 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
401 None => std::task::Poll::Ready(None),
402 }
403 }
404}
405
406#[derive(Debug)]
407pub enum DeviceEvent {
408 #[non_exhaustive]
409 _UnknownEvent {
410 ordinal: u64,
412 },
413}
414
415impl DeviceEvent {
416 fn decode(
418 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
419 ) -> Result<DeviceEvent, fidl::Error> {
420 let (bytes, _handles) = buf.split_mut();
421 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
422 debug_assert_eq!(tx_header.tx_id, 0);
423 match tx_header.ordinal {
424 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
425 Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
426 }
427 _ => Err(fidl::Error::UnknownOrdinal {
428 ordinal: tx_header.ordinal,
429 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
430 }),
431 }
432 }
433}
434
435pub struct DeviceRequestStream {
437 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
438 is_terminated: bool,
439}
440
441impl std::marker::Unpin for DeviceRequestStream {}
442
443impl futures::stream::FusedStream for DeviceRequestStream {
444 fn is_terminated(&self) -> bool {
445 self.is_terminated
446 }
447}
448
449impl fidl::endpoints::RequestStream for DeviceRequestStream {
450 type Protocol = DeviceMarker;
451 type ControlHandle = DeviceControlHandle;
452
453 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
454 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
455 }
456
457 fn control_handle(&self) -> Self::ControlHandle {
458 DeviceControlHandle { inner: self.inner.clone() }
459 }
460
461 fn into_inner(
462 self,
463 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
464 {
465 (self.inner, self.is_terminated)
466 }
467
468 fn from_inner(
469 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
470 is_terminated: bool,
471 ) -> Self {
472 Self { inner, is_terminated }
473 }
474}
475
476impl futures::Stream for DeviceRequestStream {
477 type Item = Result<DeviceRequest, fidl::Error>;
478
479 fn poll_next(
480 mut self: std::pin::Pin<&mut Self>,
481 cx: &mut std::task::Context<'_>,
482 ) -> std::task::Poll<Option<Self::Item>> {
483 let this = &mut *self;
484 if this.inner.check_shutdown(cx) {
485 this.is_terminated = true;
486 return std::task::Poll::Ready(None);
487 }
488 if this.is_terminated {
489 panic!("polled DeviceRequestStream after completion");
490 }
491 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
492 |bytes, handles| {
493 match this.inner.channel().read_etc(cx, bytes, handles) {
494 std::task::Poll::Ready(Ok(())) => {}
495 std::task::Poll::Pending => return std::task::Poll::Pending,
496 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
497 this.is_terminated = true;
498 return std::task::Poll::Ready(None);
499 }
500 std::task::Poll::Ready(Err(e)) => {
501 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
502 e.into(),
503 ))));
504 }
505 }
506
507 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
509
510 std::task::Poll::Ready(Some(match header.ordinal {
511 0x10f1af06f7642901 => {
512 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
513 let mut req = fidl::new_empty!(
514 fidl::encoding::EmptyPayload,
515 fidl::encoding::DefaultFuchsiaResourceDialect
516 );
517 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
518 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
519 Ok(DeviceRequest::GetRailMetadata {
520 responder: DeviceGetRailMetadataResponder {
521 control_handle: std::mem::ManuallyDrop::new(control_handle),
522 tx_id: header.tx_id,
523 },
524 })
525 }
526 0x3f8ada9ce9065924 => {
527 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
528 let mut req = fidl::new_empty!(
529 Options,
530 fidl::encoding::DefaultFuchsiaResourceDialect
531 );
532 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
533 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
534 Ok(DeviceRequest::GetPowerWatts {
535 payload: req,
536 responder: DeviceGetPowerWattsResponder {
537 control_handle: std::mem::ManuallyDrop::new(control_handle),
538 tx_id: header.tx_id,
539 },
540 })
541 }
542 0x22fb9ad39b15d8a5 => {
543 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
544 let mut req = fidl::new_empty!(
545 Options,
546 fidl::encoding::DefaultFuchsiaResourceDialect
547 );
548 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
549 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
550 Ok(DeviceRequest::GetCurrentAmperes {
551 payload: req,
552 responder: DeviceGetCurrentAmperesResponder {
553 control_handle: std::mem::ManuallyDrop::new(control_handle),
554 tx_id: header.tx_id,
555 },
556 })
557 }
558 0x4bd34b82e636efc9 => {
559 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
560 let mut req = fidl::new_empty!(
561 Options,
562 fidl::encoding::DefaultFuchsiaResourceDialect
563 );
564 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
565 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
566 Ok(DeviceRequest::GetEnergyJoules {
567 payload: req,
568 responder: DeviceGetEnergyJoulesResponder {
569 control_handle: std::mem::ManuallyDrop::new(control_handle),
570 tx_id: header.tx_id,
571 },
572 })
573 }
574 _ if header.tx_id == 0
575 && header
576 .dynamic_flags()
577 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
578 {
579 Ok(DeviceRequest::_UnknownMethod {
580 ordinal: header.ordinal,
581 control_handle: DeviceControlHandle { inner: this.inner.clone() },
582 method_type: fidl::MethodType::OneWay,
583 })
584 }
585 _ if header
586 .dynamic_flags()
587 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
588 {
589 this.inner.send_framework_err(
590 fidl::encoding::FrameworkErr::UnknownMethod,
591 header.tx_id,
592 header.ordinal,
593 header.dynamic_flags(),
594 (bytes, handles),
595 )?;
596 Ok(DeviceRequest::_UnknownMethod {
597 ordinal: header.ordinal,
598 control_handle: DeviceControlHandle { inner: this.inner.clone() },
599 method_type: fidl::MethodType::TwoWay,
600 })
601 }
602 _ => Err(fidl::Error::UnknownOrdinal {
603 ordinal: header.ordinal,
604 protocol_name:
605 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
606 }),
607 }))
608 },
609 )
610 }
611}
612
613#[derive(Debug)]
615pub enum DeviceRequest {
616 GetRailMetadata { responder: DeviceGetRailMetadataResponder },
618 GetPowerWatts { payload: Options, responder: DeviceGetPowerWattsResponder },
621 GetCurrentAmperes { payload: Options, responder: DeviceGetCurrentAmperesResponder },
624 GetEnergyJoules { payload: Options, responder: DeviceGetEnergyJoulesResponder },
627 #[non_exhaustive]
629 _UnknownMethod {
630 ordinal: u64,
632 control_handle: DeviceControlHandle,
633 method_type: fidl::MethodType,
634 },
635}
636
637impl DeviceRequest {
638 #[allow(irrefutable_let_patterns)]
639 pub fn into_get_rail_metadata(self) -> Option<(DeviceGetRailMetadataResponder)> {
640 if let DeviceRequest::GetRailMetadata { responder } = self {
641 Some((responder))
642 } else {
643 None
644 }
645 }
646
647 #[allow(irrefutable_let_patterns)]
648 pub fn into_get_power_watts(self) -> Option<(Options, DeviceGetPowerWattsResponder)> {
649 if let DeviceRequest::GetPowerWatts { payload, responder } = self {
650 Some((payload, responder))
651 } else {
652 None
653 }
654 }
655
656 #[allow(irrefutable_let_patterns)]
657 pub fn into_get_current_amperes(self) -> Option<(Options, DeviceGetCurrentAmperesResponder)> {
658 if let DeviceRequest::GetCurrentAmperes { payload, responder } = self {
659 Some((payload, responder))
660 } else {
661 None
662 }
663 }
664
665 #[allow(irrefutable_let_patterns)]
666 pub fn into_get_energy_joules(self) -> Option<(Options, DeviceGetEnergyJoulesResponder)> {
667 if let DeviceRequest::GetEnergyJoules { payload, responder } = self {
668 Some((payload, responder))
669 } else {
670 None
671 }
672 }
673
674 pub fn method_name(&self) -> &'static str {
676 match *self {
677 DeviceRequest::GetRailMetadata { .. } => "get_rail_metadata",
678 DeviceRequest::GetPowerWatts { .. } => "get_power_watts",
679 DeviceRequest::GetCurrentAmperes { .. } => "get_current_amperes",
680 DeviceRequest::GetEnergyJoules { .. } => "get_energy_joules",
681 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
682 "unknown one-way method"
683 }
684 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
685 "unknown two-way method"
686 }
687 }
688 }
689}
690
691#[derive(Debug, Clone)]
692pub struct DeviceControlHandle {
693 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
694}
695
696impl DeviceControlHandle {
697 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
698 self.inner.shutdown_with_epitaph(status.into())
699 }
700}
701
702impl fidl::endpoints::ControlHandle for DeviceControlHandle {
703 fn shutdown(&self) {
704 self.inner.shutdown()
705 }
706
707 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
708 self.inner.shutdown_with_epitaph(status)
709 }
710
711 fn is_closed(&self) -> bool {
712 self.inner.channel().is_closed()
713 }
714 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
715 self.inner.channel().on_closed()
716 }
717
718 #[cfg(target_os = "fuchsia")]
719 fn signal_peer(
720 &self,
721 clear_mask: zx::Signals,
722 set_mask: zx::Signals,
723 ) -> Result<(), zx_status::Status> {
724 use fidl::Peered;
725 self.inner.channel().signal_peer(clear_mask, set_mask)
726 }
727}
728
729impl DeviceControlHandle {}
730
731#[must_use = "FIDL methods require a response to be sent"]
732#[derive(Debug)]
733pub struct DeviceGetRailMetadataResponder {
734 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
735 tx_id: u32,
736}
737
738impl std::ops::Drop for DeviceGetRailMetadataResponder {
742 fn drop(&mut self) {
743 self.control_handle.shutdown();
744 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
746 }
747}
748
749impl fidl::endpoints::Responder for DeviceGetRailMetadataResponder {
750 type ControlHandle = DeviceControlHandle;
751
752 fn control_handle(&self) -> &DeviceControlHandle {
753 &self.control_handle
754 }
755
756 fn drop_without_shutdown(mut self) {
757 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
759 std::mem::forget(self);
761 }
762}
763
764impl DeviceGetRailMetadataResponder {
765 pub fn send(self, mut result: Result<&RailMetadata, i32>) -> Result<(), fidl::Error> {
769 let _result = self.send_raw(result);
770 if _result.is_err() {
771 self.control_handle.shutdown();
772 }
773 self.drop_without_shutdown();
774 _result
775 }
776
777 pub fn send_no_shutdown_on_err(
779 self,
780 mut result: Result<&RailMetadata, i32>,
781 ) -> Result<(), fidl::Error> {
782 let _result = self.send_raw(result);
783 self.drop_without_shutdown();
784 _result
785 }
786
787 fn send_raw(&self, mut result: Result<&RailMetadata, i32>) -> Result<(), fidl::Error> {
788 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<RailMetadata, i32>>(
789 fidl::encoding::FlexibleResult::new(result),
790 self.tx_id,
791 0x10f1af06f7642901,
792 fidl::encoding::DynamicFlags::FLEXIBLE,
793 )
794 }
795}
796
797#[must_use = "FIDL methods require a response to be sent"]
798#[derive(Debug)]
799pub struct DeviceGetPowerWattsResponder {
800 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
801 tx_id: u32,
802}
803
804impl std::ops::Drop for DeviceGetPowerWattsResponder {
808 fn drop(&mut self) {
809 self.control_handle.shutdown();
810 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
812 }
813}
814
815impl fidl::endpoints::Responder for DeviceGetPowerWattsResponder {
816 type ControlHandle = DeviceControlHandle;
817
818 fn control_handle(&self) -> &DeviceControlHandle {
819 &self.control_handle
820 }
821
822 fn drop_without_shutdown(mut self) {
823 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
825 std::mem::forget(self);
827 }
828}
829
830impl DeviceGetPowerWattsResponder {
831 pub fn send(self, mut result: Result<&PowerReading, i32>) -> Result<(), fidl::Error> {
835 let _result = self.send_raw(result);
836 if _result.is_err() {
837 self.control_handle.shutdown();
838 }
839 self.drop_without_shutdown();
840 _result
841 }
842
843 pub fn send_no_shutdown_on_err(
845 self,
846 mut result: Result<&PowerReading, i32>,
847 ) -> Result<(), fidl::Error> {
848 let _result = self.send_raw(result);
849 self.drop_without_shutdown();
850 _result
851 }
852
853 fn send_raw(&self, mut result: Result<&PowerReading, i32>) -> Result<(), fidl::Error> {
854 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<PowerReading, i32>>(
855 fidl::encoding::FlexibleResult::new(result),
856 self.tx_id,
857 0x3f8ada9ce9065924,
858 fidl::encoding::DynamicFlags::FLEXIBLE,
859 )
860 }
861}
862
863#[must_use = "FIDL methods require a response to be sent"]
864#[derive(Debug)]
865pub struct DeviceGetCurrentAmperesResponder {
866 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
867 tx_id: u32,
868}
869
870impl std::ops::Drop for DeviceGetCurrentAmperesResponder {
874 fn drop(&mut self) {
875 self.control_handle.shutdown();
876 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
878 }
879}
880
881impl fidl::endpoints::Responder for DeviceGetCurrentAmperesResponder {
882 type ControlHandle = DeviceControlHandle;
883
884 fn control_handle(&self) -> &DeviceControlHandle {
885 &self.control_handle
886 }
887
888 fn drop_without_shutdown(mut self) {
889 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
891 std::mem::forget(self);
893 }
894}
895
896impl DeviceGetCurrentAmperesResponder {
897 pub fn send(self, mut result: Result<&CurrentReading, i32>) -> Result<(), fidl::Error> {
901 let _result = self.send_raw(result);
902 if _result.is_err() {
903 self.control_handle.shutdown();
904 }
905 self.drop_without_shutdown();
906 _result
907 }
908
909 pub fn send_no_shutdown_on_err(
911 self,
912 mut result: Result<&CurrentReading, i32>,
913 ) -> Result<(), fidl::Error> {
914 let _result = self.send_raw(result);
915 self.drop_without_shutdown();
916 _result
917 }
918
919 fn send_raw(&self, mut result: Result<&CurrentReading, i32>) -> Result<(), fidl::Error> {
920 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<CurrentReading, i32>>(
921 fidl::encoding::FlexibleResult::new(result),
922 self.tx_id,
923 0x22fb9ad39b15d8a5,
924 fidl::encoding::DynamicFlags::FLEXIBLE,
925 )
926 }
927}
928
929#[must_use = "FIDL methods require a response to be sent"]
930#[derive(Debug)]
931pub struct DeviceGetEnergyJoulesResponder {
932 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
933 tx_id: u32,
934}
935
936impl std::ops::Drop for DeviceGetEnergyJoulesResponder {
940 fn drop(&mut self) {
941 self.control_handle.shutdown();
942 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
944 }
945}
946
947impl fidl::endpoints::Responder for DeviceGetEnergyJoulesResponder {
948 type ControlHandle = DeviceControlHandle;
949
950 fn control_handle(&self) -> &DeviceControlHandle {
951 &self.control_handle
952 }
953
954 fn drop_without_shutdown(mut self) {
955 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
957 std::mem::forget(self);
959 }
960}
961
962impl DeviceGetEnergyJoulesResponder {
963 pub fn send(self, mut result: Result<&EnergyReading, i32>) -> Result<(), fidl::Error> {
967 let _result = self.send_raw(result);
968 if _result.is_err() {
969 self.control_handle.shutdown();
970 }
971 self.drop_without_shutdown();
972 _result
973 }
974
975 pub fn send_no_shutdown_on_err(
977 self,
978 mut result: Result<&EnergyReading, i32>,
979 ) -> Result<(), fidl::Error> {
980 let _result = self.send_raw(result);
981 self.drop_without_shutdown();
982 _result
983 }
984
985 fn send_raw(&self, mut result: Result<&EnergyReading, i32>) -> Result<(), fidl::Error> {
986 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<EnergyReading, i32>>(
987 fidl::encoding::FlexibleResult::new(result),
988 self.tx_id,
989 0x4bd34b82e636efc9,
990 fidl::encoding::DynamicFlags::FLEXIBLE,
991 )
992 }
993}
994
995#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
996pub struct DriverConfigMarker;
997
998impl fidl::endpoints::ProtocolMarker for DriverConfigMarker {
999 type Proxy = DriverConfigProxy;
1000 type RequestStream = DriverConfigRequestStream;
1001 #[cfg(target_os = "fuchsia")]
1002 type SynchronousProxy = DriverConfigSynchronousProxy;
1003
1004 const DEBUG_NAME: &'static str = "fuchsia.hardware.google.odpm.DriverConfig";
1005}
1006impl fidl::endpoints::DiscoverableProtocolMarker for DriverConfigMarker {}
1007pub type DriverConfigSetPollingConfigResult = Result<(), i32>;
1008pub type DriverConfigGetPollingConfigResult = Result<PollingConfig, i32>;
1009pub type DriverConfigResetPollingConfigResult = Result<(), i32>;
1010
1011pub trait DriverConfigProxyInterface: Send + Sync {
1012 type SetPollingConfigResponseFut: std::future::Future<Output = Result<DriverConfigSetPollingConfigResult, fidl::Error>>
1013 + Send;
1014 fn r#set_polling_config(&self, payload: &PollingConfig) -> Self::SetPollingConfigResponseFut;
1015 type GetPollingConfigResponseFut: std::future::Future<Output = Result<DriverConfigGetPollingConfigResult, fidl::Error>>
1016 + Send;
1017 fn r#get_polling_config(&self) -> Self::GetPollingConfigResponseFut;
1018 type ResetPollingConfigResponseFut: std::future::Future<Output = Result<DriverConfigResetPollingConfigResult, fidl::Error>>
1019 + Send;
1020 fn r#reset_polling_config(&self) -> Self::ResetPollingConfigResponseFut;
1021}
1022#[derive(Debug)]
1023#[cfg(target_os = "fuchsia")]
1024pub struct DriverConfigSynchronousProxy {
1025 client: fidl::client::sync::Client,
1026}
1027
1028#[cfg(target_os = "fuchsia")]
1029impl fidl::endpoints::SynchronousProxy for DriverConfigSynchronousProxy {
1030 type Proxy = DriverConfigProxy;
1031 type Protocol = DriverConfigMarker;
1032
1033 fn from_channel(inner: fidl::Channel) -> Self {
1034 Self::new(inner)
1035 }
1036
1037 fn into_channel(self) -> fidl::Channel {
1038 self.client.into_channel()
1039 }
1040
1041 fn as_channel(&self) -> &fidl::Channel {
1042 self.client.as_channel()
1043 }
1044}
1045
1046#[cfg(target_os = "fuchsia")]
1047impl DriverConfigSynchronousProxy {
1048 pub fn new(channel: fidl::Channel) -> Self {
1049 Self { client: fidl::client::sync::Client::new(channel) }
1050 }
1051
1052 pub fn into_channel(self) -> fidl::Channel {
1053 self.client.into_channel()
1054 }
1055
1056 pub fn wait_for_event(
1059 &self,
1060 deadline: zx::MonotonicInstant,
1061 ) -> Result<DriverConfigEvent, fidl::Error> {
1062 DriverConfigEvent::decode(self.client.wait_for_event::<DriverConfigMarker>(deadline)?)
1063 }
1064
1065 pub fn r#set_polling_config(
1070 &self,
1071 mut payload: &PollingConfig,
1072 ___deadline: zx::MonotonicInstant,
1073 ) -> Result<DriverConfigSetPollingConfigResult, fidl::Error> {
1074 let _response = self.client.send_query::<
1075 PollingConfig,
1076 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1077 DriverConfigMarker,
1078 >(
1079 payload,
1080 0x36ce1193d5909de7,
1081 fidl::encoding::DynamicFlags::FLEXIBLE,
1082 ___deadline,
1083 )?
1084 .into_result::<DriverConfigMarker>("set_polling_config")?;
1085 Ok(_response.map(|x| x))
1086 }
1087
1088 pub fn r#get_polling_config(
1090 &self,
1091 ___deadline: zx::MonotonicInstant,
1092 ) -> Result<DriverConfigGetPollingConfigResult, fidl::Error> {
1093 let _response = self.client.send_query::<
1094 fidl::encoding::EmptyPayload,
1095 fidl::encoding::FlexibleResultType<PollingConfig, i32>,
1096 DriverConfigMarker,
1097 >(
1098 (),
1099 0x539228d93dd77892,
1100 fidl::encoding::DynamicFlags::FLEXIBLE,
1101 ___deadline,
1102 )?
1103 .into_result::<DriverConfigMarker>("get_polling_config")?;
1104 Ok(_response.map(|x| x))
1105 }
1106
1107 pub fn r#reset_polling_config(
1109 &self,
1110 ___deadline: zx::MonotonicInstant,
1111 ) -> Result<DriverConfigResetPollingConfigResult, fidl::Error> {
1112 let _response = self.client.send_query::<
1113 fidl::encoding::EmptyPayload,
1114 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1115 DriverConfigMarker,
1116 >(
1117 (),
1118 0x303419d0841fb28f,
1119 fidl::encoding::DynamicFlags::FLEXIBLE,
1120 ___deadline,
1121 )?
1122 .into_result::<DriverConfigMarker>("reset_polling_config")?;
1123 Ok(_response.map(|x| x))
1124 }
1125}
1126
1127#[cfg(target_os = "fuchsia")]
1128impl From<DriverConfigSynchronousProxy> for zx::NullableHandle {
1129 fn from(value: DriverConfigSynchronousProxy) -> Self {
1130 value.into_channel().into()
1131 }
1132}
1133
1134#[cfg(target_os = "fuchsia")]
1135impl From<fidl::Channel> for DriverConfigSynchronousProxy {
1136 fn from(value: fidl::Channel) -> Self {
1137 Self::new(value)
1138 }
1139}
1140
1141#[cfg(target_os = "fuchsia")]
1142impl fidl::endpoints::FromClient for DriverConfigSynchronousProxy {
1143 type Protocol = DriverConfigMarker;
1144
1145 fn from_client(value: fidl::endpoints::ClientEnd<DriverConfigMarker>) -> Self {
1146 Self::new(value.into_channel())
1147 }
1148}
1149
1150#[derive(Debug, Clone)]
1151pub struct DriverConfigProxy {
1152 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1153}
1154
1155impl fidl::endpoints::Proxy for DriverConfigProxy {
1156 type Protocol = DriverConfigMarker;
1157
1158 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1159 Self::new(inner)
1160 }
1161
1162 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1163 self.client.into_channel().map_err(|client| Self { client })
1164 }
1165
1166 fn as_channel(&self) -> &::fidl::AsyncChannel {
1167 self.client.as_channel()
1168 }
1169}
1170
1171impl DriverConfigProxy {
1172 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1174 let protocol_name = <DriverConfigMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1175 Self { client: fidl::client::Client::new(channel, protocol_name) }
1176 }
1177
1178 pub fn take_event_stream(&self) -> DriverConfigEventStream {
1184 DriverConfigEventStream { event_receiver: self.client.take_event_receiver() }
1185 }
1186
1187 pub fn r#set_polling_config(
1192 &self,
1193 mut payload: &PollingConfig,
1194 ) -> fidl::client::QueryResponseFut<
1195 DriverConfigSetPollingConfigResult,
1196 fidl::encoding::DefaultFuchsiaResourceDialect,
1197 > {
1198 DriverConfigProxyInterface::r#set_polling_config(self, payload)
1199 }
1200
1201 pub fn r#get_polling_config(
1203 &self,
1204 ) -> fidl::client::QueryResponseFut<
1205 DriverConfigGetPollingConfigResult,
1206 fidl::encoding::DefaultFuchsiaResourceDialect,
1207 > {
1208 DriverConfigProxyInterface::r#get_polling_config(self)
1209 }
1210
1211 pub fn r#reset_polling_config(
1213 &self,
1214 ) -> fidl::client::QueryResponseFut<
1215 DriverConfigResetPollingConfigResult,
1216 fidl::encoding::DefaultFuchsiaResourceDialect,
1217 > {
1218 DriverConfigProxyInterface::r#reset_polling_config(self)
1219 }
1220}
1221
1222impl DriverConfigProxyInterface for DriverConfigProxy {
1223 type SetPollingConfigResponseFut = fidl::client::QueryResponseFut<
1224 DriverConfigSetPollingConfigResult,
1225 fidl::encoding::DefaultFuchsiaResourceDialect,
1226 >;
1227 fn r#set_polling_config(
1228 &self,
1229 mut payload: &PollingConfig,
1230 ) -> Self::SetPollingConfigResponseFut {
1231 fn _decode(
1232 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1233 ) -> Result<DriverConfigSetPollingConfigResult, fidl::Error> {
1234 let _response = fidl::client::decode_transaction_body::<
1235 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1236 fidl::encoding::DefaultFuchsiaResourceDialect,
1237 0x36ce1193d5909de7,
1238 >(_buf?)?
1239 .into_result::<DriverConfigMarker>("set_polling_config")?;
1240 Ok(_response.map(|x| x))
1241 }
1242 self.client.send_query_and_decode::<PollingConfig, DriverConfigSetPollingConfigResult>(
1243 payload,
1244 0x36ce1193d5909de7,
1245 fidl::encoding::DynamicFlags::FLEXIBLE,
1246 _decode,
1247 )
1248 }
1249
1250 type GetPollingConfigResponseFut = fidl::client::QueryResponseFut<
1251 DriverConfigGetPollingConfigResult,
1252 fidl::encoding::DefaultFuchsiaResourceDialect,
1253 >;
1254 fn r#get_polling_config(&self) -> Self::GetPollingConfigResponseFut {
1255 fn _decode(
1256 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1257 ) -> Result<DriverConfigGetPollingConfigResult, fidl::Error> {
1258 let _response = fidl::client::decode_transaction_body::<
1259 fidl::encoding::FlexibleResultType<PollingConfig, i32>,
1260 fidl::encoding::DefaultFuchsiaResourceDialect,
1261 0x539228d93dd77892,
1262 >(_buf?)?
1263 .into_result::<DriverConfigMarker>("get_polling_config")?;
1264 Ok(_response.map(|x| x))
1265 }
1266 self.client.send_query_and_decode::<
1267 fidl::encoding::EmptyPayload,
1268 DriverConfigGetPollingConfigResult,
1269 >(
1270 (),
1271 0x539228d93dd77892,
1272 fidl::encoding::DynamicFlags::FLEXIBLE,
1273 _decode,
1274 )
1275 }
1276
1277 type ResetPollingConfigResponseFut = fidl::client::QueryResponseFut<
1278 DriverConfigResetPollingConfigResult,
1279 fidl::encoding::DefaultFuchsiaResourceDialect,
1280 >;
1281 fn r#reset_polling_config(&self) -> Self::ResetPollingConfigResponseFut {
1282 fn _decode(
1283 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1284 ) -> Result<DriverConfigResetPollingConfigResult, fidl::Error> {
1285 let _response = fidl::client::decode_transaction_body::<
1286 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1287 fidl::encoding::DefaultFuchsiaResourceDialect,
1288 0x303419d0841fb28f,
1289 >(_buf?)?
1290 .into_result::<DriverConfigMarker>("reset_polling_config")?;
1291 Ok(_response.map(|x| x))
1292 }
1293 self.client.send_query_and_decode::<
1294 fidl::encoding::EmptyPayload,
1295 DriverConfigResetPollingConfigResult,
1296 >(
1297 (),
1298 0x303419d0841fb28f,
1299 fidl::encoding::DynamicFlags::FLEXIBLE,
1300 _decode,
1301 )
1302 }
1303}
1304
1305pub struct DriverConfigEventStream {
1306 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1307}
1308
1309impl std::marker::Unpin for DriverConfigEventStream {}
1310
1311impl futures::stream::FusedStream for DriverConfigEventStream {
1312 fn is_terminated(&self) -> bool {
1313 self.event_receiver.is_terminated()
1314 }
1315}
1316
1317impl futures::Stream for DriverConfigEventStream {
1318 type Item = Result<DriverConfigEvent, fidl::Error>;
1319
1320 fn poll_next(
1321 mut self: std::pin::Pin<&mut Self>,
1322 cx: &mut std::task::Context<'_>,
1323 ) -> std::task::Poll<Option<Self::Item>> {
1324 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1325 &mut self.event_receiver,
1326 cx
1327 )?) {
1328 Some(buf) => std::task::Poll::Ready(Some(DriverConfigEvent::decode(buf))),
1329 None => std::task::Poll::Ready(None),
1330 }
1331 }
1332}
1333
1334#[derive(Debug)]
1335pub enum DriverConfigEvent {
1336 #[non_exhaustive]
1337 _UnknownEvent {
1338 ordinal: u64,
1340 },
1341}
1342
1343impl DriverConfigEvent {
1344 fn decode(
1346 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1347 ) -> Result<DriverConfigEvent, fidl::Error> {
1348 let (bytes, _handles) = buf.split_mut();
1349 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1350 debug_assert_eq!(tx_header.tx_id, 0);
1351 match tx_header.ordinal {
1352 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1353 Ok(DriverConfigEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1354 }
1355 _ => Err(fidl::Error::UnknownOrdinal {
1356 ordinal: tx_header.ordinal,
1357 protocol_name: <DriverConfigMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1358 }),
1359 }
1360 }
1361}
1362
1363pub struct DriverConfigRequestStream {
1365 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1366 is_terminated: bool,
1367}
1368
1369impl std::marker::Unpin for DriverConfigRequestStream {}
1370
1371impl futures::stream::FusedStream for DriverConfigRequestStream {
1372 fn is_terminated(&self) -> bool {
1373 self.is_terminated
1374 }
1375}
1376
1377impl fidl::endpoints::RequestStream for DriverConfigRequestStream {
1378 type Protocol = DriverConfigMarker;
1379 type ControlHandle = DriverConfigControlHandle;
1380
1381 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1382 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1383 }
1384
1385 fn control_handle(&self) -> Self::ControlHandle {
1386 DriverConfigControlHandle { inner: self.inner.clone() }
1387 }
1388
1389 fn into_inner(
1390 self,
1391 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1392 {
1393 (self.inner, self.is_terminated)
1394 }
1395
1396 fn from_inner(
1397 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1398 is_terminated: bool,
1399 ) -> Self {
1400 Self { inner, is_terminated }
1401 }
1402}
1403
1404impl futures::Stream for DriverConfigRequestStream {
1405 type Item = Result<DriverConfigRequest, fidl::Error>;
1406
1407 fn poll_next(
1408 mut self: std::pin::Pin<&mut Self>,
1409 cx: &mut std::task::Context<'_>,
1410 ) -> std::task::Poll<Option<Self::Item>> {
1411 let this = &mut *self;
1412 if this.inner.check_shutdown(cx) {
1413 this.is_terminated = true;
1414 return std::task::Poll::Ready(None);
1415 }
1416 if this.is_terminated {
1417 panic!("polled DriverConfigRequestStream after completion");
1418 }
1419 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1420 |bytes, handles| {
1421 match this.inner.channel().read_etc(cx, bytes, handles) {
1422 std::task::Poll::Ready(Ok(())) => {}
1423 std::task::Poll::Pending => return std::task::Poll::Pending,
1424 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1425 this.is_terminated = true;
1426 return std::task::Poll::Ready(None);
1427 }
1428 std::task::Poll::Ready(Err(e)) => {
1429 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1430 e.into(),
1431 ))));
1432 }
1433 }
1434
1435 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1437
1438 std::task::Poll::Ready(Some(match header.ordinal {
1439 0x36ce1193d5909de7 => {
1440 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1441 let mut req = fidl::new_empty!(
1442 PollingConfig,
1443 fidl::encoding::DefaultFuchsiaResourceDialect
1444 );
1445 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PollingConfig>(&header, _body_bytes, handles, &mut req)?;
1446 let control_handle =
1447 DriverConfigControlHandle { inner: this.inner.clone() };
1448 Ok(DriverConfigRequest::SetPollingConfig {
1449 payload: req,
1450 responder: DriverConfigSetPollingConfigResponder {
1451 control_handle: std::mem::ManuallyDrop::new(control_handle),
1452 tx_id: header.tx_id,
1453 },
1454 })
1455 }
1456 0x539228d93dd77892 => {
1457 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1458 let mut req = fidl::new_empty!(
1459 fidl::encoding::EmptyPayload,
1460 fidl::encoding::DefaultFuchsiaResourceDialect
1461 );
1462 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1463 let control_handle =
1464 DriverConfigControlHandle { inner: this.inner.clone() };
1465 Ok(DriverConfigRequest::GetPollingConfig {
1466 responder: DriverConfigGetPollingConfigResponder {
1467 control_handle: std::mem::ManuallyDrop::new(control_handle),
1468 tx_id: header.tx_id,
1469 },
1470 })
1471 }
1472 0x303419d0841fb28f => {
1473 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1474 let mut req = fidl::new_empty!(
1475 fidl::encoding::EmptyPayload,
1476 fidl::encoding::DefaultFuchsiaResourceDialect
1477 );
1478 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1479 let control_handle =
1480 DriverConfigControlHandle { inner: this.inner.clone() };
1481 Ok(DriverConfigRequest::ResetPollingConfig {
1482 responder: DriverConfigResetPollingConfigResponder {
1483 control_handle: std::mem::ManuallyDrop::new(control_handle),
1484 tx_id: header.tx_id,
1485 },
1486 })
1487 }
1488 _ if header.tx_id == 0
1489 && header
1490 .dynamic_flags()
1491 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1492 {
1493 Ok(DriverConfigRequest::_UnknownMethod {
1494 ordinal: header.ordinal,
1495 control_handle: DriverConfigControlHandle { inner: this.inner.clone() },
1496 method_type: fidl::MethodType::OneWay,
1497 })
1498 }
1499 _ if header
1500 .dynamic_flags()
1501 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1502 {
1503 this.inner.send_framework_err(
1504 fidl::encoding::FrameworkErr::UnknownMethod,
1505 header.tx_id,
1506 header.ordinal,
1507 header.dynamic_flags(),
1508 (bytes, handles),
1509 )?;
1510 Ok(DriverConfigRequest::_UnknownMethod {
1511 ordinal: header.ordinal,
1512 control_handle: DriverConfigControlHandle { inner: this.inner.clone() },
1513 method_type: fidl::MethodType::TwoWay,
1514 })
1515 }
1516 _ => Err(fidl::Error::UnknownOrdinal {
1517 ordinal: header.ordinal,
1518 protocol_name:
1519 <DriverConfigMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1520 }),
1521 }))
1522 },
1523 )
1524 }
1525}
1526
1527#[derive(Debug)]
1530pub enum DriverConfigRequest {
1531 SetPollingConfig { payload: PollingConfig, responder: DriverConfigSetPollingConfigResponder },
1536 GetPollingConfig { responder: DriverConfigGetPollingConfigResponder },
1538 ResetPollingConfig { responder: DriverConfigResetPollingConfigResponder },
1540 #[non_exhaustive]
1542 _UnknownMethod {
1543 ordinal: u64,
1545 control_handle: DriverConfigControlHandle,
1546 method_type: fidl::MethodType,
1547 },
1548}
1549
1550impl DriverConfigRequest {
1551 #[allow(irrefutable_let_patterns)]
1552 pub fn into_set_polling_config(
1553 self,
1554 ) -> Option<(PollingConfig, DriverConfigSetPollingConfigResponder)> {
1555 if let DriverConfigRequest::SetPollingConfig { payload, responder } = self {
1556 Some((payload, responder))
1557 } else {
1558 None
1559 }
1560 }
1561
1562 #[allow(irrefutable_let_patterns)]
1563 pub fn into_get_polling_config(self) -> Option<(DriverConfigGetPollingConfigResponder)> {
1564 if let DriverConfigRequest::GetPollingConfig { responder } = self {
1565 Some((responder))
1566 } else {
1567 None
1568 }
1569 }
1570
1571 #[allow(irrefutable_let_patterns)]
1572 pub fn into_reset_polling_config(self) -> Option<(DriverConfigResetPollingConfigResponder)> {
1573 if let DriverConfigRequest::ResetPollingConfig { responder } = self {
1574 Some((responder))
1575 } else {
1576 None
1577 }
1578 }
1579
1580 pub fn method_name(&self) -> &'static str {
1582 match *self {
1583 DriverConfigRequest::SetPollingConfig { .. } => "set_polling_config",
1584 DriverConfigRequest::GetPollingConfig { .. } => "get_polling_config",
1585 DriverConfigRequest::ResetPollingConfig { .. } => "reset_polling_config",
1586 DriverConfigRequest::_UnknownMethod {
1587 method_type: fidl::MethodType::OneWay, ..
1588 } => "unknown one-way method",
1589 DriverConfigRequest::_UnknownMethod {
1590 method_type: fidl::MethodType::TwoWay, ..
1591 } => "unknown two-way method",
1592 }
1593 }
1594}
1595
1596#[derive(Debug, Clone)]
1597pub struct DriverConfigControlHandle {
1598 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1599}
1600
1601impl DriverConfigControlHandle {
1602 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1603 self.inner.shutdown_with_epitaph(status.into())
1604 }
1605}
1606
1607impl fidl::endpoints::ControlHandle for DriverConfigControlHandle {
1608 fn shutdown(&self) {
1609 self.inner.shutdown()
1610 }
1611
1612 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1613 self.inner.shutdown_with_epitaph(status)
1614 }
1615
1616 fn is_closed(&self) -> bool {
1617 self.inner.channel().is_closed()
1618 }
1619 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1620 self.inner.channel().on_closed()
1621 }
1622
1623 #[cfg(target_os = "fuchsia")]
1624 fn signal_peer(
1625 &self,
1626 clear_mask: zx::Signals,
1627 set_mask: zx::Signals,
1628 ) -> Result<(), zx_status::Status> {
1629 use fidl::Peered;
1630 self.inner.channel().signal_peer(clear_mask, set_mask)
1631 }
1632}
1633
1634impl DriverConfigControlHandle {}
1635
1636#[must_use = "FIDL methods require a response to be sent"]
1637#[derive(Debug)]
1638pub struct DriverConfigSetPollingConfigResponder {
1639 control_handle: std::mem::ManuallyDrop<DriverConfigControlHandle>,
1640 tx_id: u32,
1641}
1642
1643impl std::ops::Drop for DriverConfigSetPollingConfigResponder {
1647 fn drop(&mut self) {
1648 self.control_handle.shutdown();
1649 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1651 }
1652}
1653
1654impl fidl::endpoints::Responder for DriverConfigSetPollingConfigResponder {
1655 type ControlHandle = DriverConfigControlHandle;
1656
1657 fn control_handle(&self) -> &DriverConfigControlHandle {
1658 &self.control_handle
1659 }
1660
1661 fn drop_without_shutdown(mut self) {
1662 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1664 std::mem::forget(self);
1666 }
1667}
1668
1669impl DriverConfigSetPollingConfigResponder {
1670 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1674 let _result = self.send_raw(result);
1675 if _result.is_err() {
1676 self.control_handle.shutdown();
1677 }
1678 self.drop_without_shutdown();
1679 _result
1680 }
1681
1682 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1684 let _result = self.send_raw(result);
1685 self.drop_without_shutdown();
1686 _result
1687 }
1688
1689 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1690 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1691 fidl::encoding::EmptyStruct,
1692 i32,
1693 >>(
1694 fidl::encoding::FlexibleResult::new(result),
1695 self.tx_id,
1696 0x36ce1193d5909de7,
1697 fidl::encoding::DynamicFlags::FLEXIBLE,
1698 )
1699 }
1700}
1701
1702#[must_use = "FIDL methods require a response to be sent"]
1703#[derive(Debug)]
1704pub struct DriverConfigGetPollingConfigResponder {
1705 control_handle: std::mem::ManuallyDrop<DriverConfigControlHandle>,
1706 tx_id: u32,
1707}
1708
1709impl std::ops::Drop for DriverConfigGetPollingConfigResponder {
1713 fn drop(&mut self) {
1714 self.control_handle.shutdown();
1715 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1717 }
1718}
1719
1720impl fidl::endpoints::Responder for DriverConfigGetPollingConfigResponder {
1721 type ControlHandle = DriverConfigControlHandle;
1722
1723 fn control_handle(&self) -> &DriverConfigControlHandle {
1724 &self.control_handle
1725 }
1726
1727 fn drop_without_shutdown(mut self) {
1728 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1730 std::mem::forget(self);
1732 }
1733}
1734
1735impl DriverConfigGetPollingConfigResponder {
1736 pub fn send(self, mut result: Result<&PollingConfig, i32>) -> Result<(), fidl::Error> {
1740 let _result = self.send_raw(result);
1741 if _result.is_err() {
1742 self.control_handle.shutdown();
1743 }
1744 self.drop_without_shutdown();
1745 _result
1746 }
1747
1748 pub fn send_no_shutdown_on_err(
1750 self,
1751 mut result: Result<&PollingConfig, i32>,
1752 ) -> Result<(), fidl::Error> {
1753 let _result = self.send_raw(result);
1754 self.drop_without_shutdown();
1755 _result
1756 }
1757
1758 fn send_raw(&self, mut result: Result<&PollingConfig, i32>) -> Result<(), fidl::Error> {
1759 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<PollingConfig, i32>>(
1760 fidl::encoding::FlexibleResult::new(result),
1761 self.tx_id,
1762 0x539228d93dd77892,
1763 fidl::encoding::DynamicFlags::FLEXIBLE,
1764 )
1765 }
1766}
1767
1768#[must_use = "FIDL methods require a response to be sent"]
1769#[derive(Debug)]
1770pub struct DriverConfigResetPollingConfigResponder {
1771 control_handle: std::mem::ManuallyDrop<DriverConfigControlHandle>,
1772 tx_id: u32,
1773}
1774
1775impl std::ops::Drop for DriverConfigResetPollingConfigResponder {
1779 fn drop(&mut self) {
1780 self.control_handle.shutdown();
1781 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1783 }
1784}
1785
1786impl fidl::endpoints::Responder for DriverConfigResetPollingConfigResponder {
1787 type ControlHandle = DriverConfigControlHandle;
1788
1789 fn control_handle(&self) -> &DriverConfigControlHandle {
1790 &self.control_handle
1791 }
1792
1793 fn drop_without_shutdown(mut self) {
1794 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1796 std::mem::forget(self);
1798 }
1799}
1800
1801impl DriverConfigResetPollingConfigResponder {
1802 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1806 let _result = self.send_raw(result);
1807 if _result.is_err() {
1808 self.control_handle.shutdown();
1809 }
1810 self.drop_without_shutdown();
1811 _result
1812 }
1813
1814 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1816 let _result = self.send_raw(result);
1817 self.drop_without_shutdown();
1818 _result
1819 }
1820
1821 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1822 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1823 fidl::encoding::EmptyStruct,
1824 i32,
1825 >>(
1826 fidl::encoding::FlexibleResult::new(result),
1827 self.tx_id,
1828 0x303419d0841fb28f,
1829 fidl::encoding::DynamicFlags::FLEXIBLE,
1830 )
1831 }
1832}
1833
1834#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1835pub struct ServiceMarker;
1836
1837#[cfg(target_os = "fuchsia")]
1838impl fidl::endpoints::ServiceMarker for ServiceMarker {
1839 type Proxy = ServiceProxy;
1840 type Request = ServiceRequest;
1841 const SERVICE_NAME: &'static str = "fuchsia.hardware.google.odpm.Service";
1842}
1843
1844#[cfg(target_os = "fuchsia")]
1848pub enum ServiceRequest {
1849 Device(DeviceRequestStream),
1850}
1851
1852#[cfg(target_os = "fuchsia")]
1853impl fidl::endpoints::ServiceRequest for ServiceRequest {
1854 type Service = ServiceMarker;
1855
1856 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1857 match name {
1858 "device" => Self::Device(
1859 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1860 ),
1861 _ => panic!("no such member protocol name for service Service"),
1862 }
1863 }
1864
1865 fn member_names() -> &'static [&'static str] {
1866 &["device"]
1867 }
1868}
1869#[cfg(target_os = "fuchsia")]
1871pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1872
1873#[cfg(target_os = "fuchsia")]
1874impl fidl::endpoints::ServiceProxy for ServiceProxy {
1875 type Service = ServiceMarker;
1876
1877 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1878 Self(opener)
1879 }
1880}
1881
1882#[cfg(target_os = "fuchsia")]
1883impl ServiceProxy {
1884 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1885 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1886 self.connect_channel_to_device(server_end)?;
1887 Ok(proxy)
1888 }
1889
1890 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1893 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1894 self.connect_channel_to_device(server_end)?;
1895 Ok(proxy)
1896 }
1897
1898 pub fn connect_channel_to_device(
1901 &self,
1902 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1903 ) -> Result<(), fidl::Error> {
1904 self.0.open_member("device", server_end.into_channel())
1905 }
1906
1907 pub fn instance_name(&self) -> &str {
1908 self.0.instance_name()
1909 }
1910}
1911
1912mod internal {
1913 use super::*;
1914}