fidl_fuchsia_hardware_cpu_ctrl/
fidl_fuchsia_hardware_cpu_ctrl.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_cpu_ctrl__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 = "(anonymous) Device";
24}
25pub type DeviceGetOperatingPointInfoResult = Result<CpuOperatingPointInfo, i32>;
26pub type DeviceSetCurrentOperatingPointResult = Result<u32, i32>;
27pub type DeviceGetOperatingPointCountResult = Result<u32, i32>;
28pub type DeviceGetRelativePerformanceResult = Result<u8, i32>;
29
30pub trait DeviceProxyInterface: Send + Sync {
31    type GetOperatingPointInfoResponseFut: std::future::Future<Output = Result<DeviceGetOperatingPointInfoResult, fidl::Error>>
32        + Send;
33    fn r#get_operating_point_info(&self, opp: u32) -> Self::GetOperatingPointInfoResponseFut;
34    type GetCurrentOperatingPointResponseFut: std::future::Future<Output = Result<u32, fidl::Error>>
35        + Send;
36    fn r#get_current_operating_point(&self) -> Self::GetCurrentOperatingPointResponseFut;
37    type SetCurrentOperatingPointResponseFut: std::future::Future<Output = Result<DeviceSetCurrentOperatingPointResult, fidl::Error>>
38        + Send;
39    fn r#set_current_operating_point(
40        &self,
41        requested_opp: u32,
42    ) -> Self::SetCurrentOperatingPointResponseFut;
43    type GetOperatingPointCountResponseFut: std::future::Future<Output = Result<DeviceGetOperatingPointCountResult, fidl::Error>>
44        + Send;
45    fn r#get_operating_point_count(&self) -> Self::GetOperatingPointCountResponseFut;
46    type GetNumLogicalCoresResponseFut: std::future::Future<Output = Result<u64, fidl::Error>>
47        + Send;
48    fn r#get_num_logical_cores(&self) -> Self::GetNumLogicalCoresResponseFut;
49    type GetLogicalCoreIdResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
50    fn r#get_logical_core_id(&self, index: u64) -> Self::GetLogicalCoreIdResponseFut;
51    type GetDomainIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
52    fn r#get_domain_id(&self) -> Self::GetDomainIdResponseFut;
53    type GetRelativePerformanceResponseFut: std::future::Future<Output = Result<DeviceGetRelativePerformanceResult, fidl::Error>>
54        + Send;
55    fn r#get_relative_performance(&self) -> Self::GetRelativePerformanceResponseFut;
56}
57#[derive(Debug)]
58#[cfg(target_os = "fuchsia")]
59pub struct DeviceSynchronousProxy {
60    client: fidl::client::sync::Client,
61}
62
63#[cfg(target_os = "fuchsia")]
64impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
65    type Proxy = DeviceProxy;
66    type Protocol = DeviceMarker;
67
68    fn from_channel(inner: fidl::Channel) -> Self {
69        Self::new(inner)
70    }
71
72    fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    fn as_channel(&self) -> &fidl::Channel {
77        self.client.as_channel()
78    }
79}
80
81#[cfg(target_os = "fuchsia")]
82impl DeviceSynchronousProxy {
83    pub fn new(channel: fidl::Channel) -> Self {
84        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
85        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
86    }
87
88    pub fn into_channel(self) -> fidl::Channel {
89        self.client.into_channel()
90    }
91
92    /// Waits until an event arrives and returns it. It is safe for other
93    /// threads to make concurrent requests while waiting for an event.
94    pub fn wait_for_event(
95        &self,
96        deadline: zx::MonotonicInstant,
97    ) -> Result<DeviceEvent, fidl::Error> {
98        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
99    }
100
101    /// Returns information about a given operating point for this performance
102    /// domain.
103    pub fn r#get_operating_point_info(
104        &self,
105        mut opp: u32,
106        ___deadline: zx::MonotonicInstant,
107    ) -> Result<DeviceGetOperatingPointInfoResult, fidl::Error> {
108        let _response = self.client.send_query::<
109            DeviceGetOperatingPointInfoRequest,
110            fidl::encoding::ResultType<DeviceGetOperatingPointInfoResponse, i32>,
111        >(
112            (opp,),
113            0x6594a9234fc958e2,
114            fidl::encoding::DynamicFlags::empty(),
115            ___deadline,
116        )?;
117        Ok(_response.map(|x| x.info))
118    }
119
120    /// Gets the current operating point of the device.
121    pub fn r#get_current_operating_point(
122        &self,
123        ___deadline: zx::MonotonicInstant,
124    ) -> Result<u32, fidl::Error> {
125        let _response = self
126            .client
127            .send_query::<fidl::encoding::EmptyPayload, DeviceGetCurrentOperatingPointResponse>(
128                (),
129                0x52de67a5993f5fe1,
130                fidl::encoding::DynamicFlags::empty(),
131                ___deadline,
132            )?;
133        Ok(_response.out_opp)
134    }
135
136    /// Set the operating point of this device to the requested operating point.
137    /// Returns ZX_OK, if the device is in a working state and the operating point is changed to
138    /// requested_opp successfully. out_opp will be same as requested_opp.
139    /// Returns error status, if switching to the requested_opp was unsuccessful. out_opp
140    /// is the operating performance point (OPP) that the device is currently in.
141    pub fn r#set_current_operating_point(
142        &self,
143        mut requested_opp: u32,
144        ___deadline: zx::MonotonicInstant,
145    ) -> Result<DeviceSetCurrentOperatingPointResult, fidl::Error> {
146        let _response = self.client.send_query::<
147            DeviceSetCurrentOperatingPointRequest,
148            fidl::encoding::ResultType<DeviceSetCurrentOperatingPointResponse, i32>,
149        >(
150            (requested_opp,),
151            0x34a7828b5ca53fd,
152            fidl::encoding::DynamicFlags::empty(),
153            ___deadline,
154        )?;
155        Ok(_response.map(|x| x.out_opp))
156    }
157
158    /// Returns the number of operating points within this performance domain.
159    pub fn r#get_operating_point_count(
160        &self,
161        ___deadline: zx::MonotonicInstant,
162    ) -> Result<DeviceGetOperatingPointCountResult, fidl::Error> {
163        let _response = self.client.send_query::<
164            fidl::encoding::EmptyPayload,
165            fidl::encoding::ResultType<DeviceGetOperatingPointCountResponse, i32>,
166        >(
167            (),
168            0x13e70ec7131889ba,
169            fidl::encoding::DynamicFlags::empty(),
170            ___deadline,
171        )?;
172        Ok(_response.map(|x| x.count))
173    }
174
175    /// Returns the number of logical cores contained within this performance
176    /// domain.
177    pub fn r#get_num_logical_cores(
178        &self,
179        ___deadline: zx::MonotonicInstant,
180    ) -> Result<u64, fidl::Error> {
181        let _response = self
182            .client
183            .send_query::<fidl::encoding::EmptyPayload, DeviceGetNumLogicalCoresResponse>(
184                (),
185                0x74e304c90ca165c5,
186                fidl::encoding::DynamicFlags::empty(),
187                ___deadline,
188            )?;
189        Ok(_response.count)
190    }
191
192    /// Returns a global system-wide core ID for the nth core in this
193    /// performance domain. `index` must be a value in the range [0, n) where
194    /// n is the value returned by GetNumLogicalCores().
195    pub fn r#get_logical_core_id(
196        &self,
197        mut index: u64,
198        ___deadline: zx::MonotonicInstant,
199    ) -> Result<u64, fidl::Error> {
200        let _response = self
201            .client
202            .send_query::<DeviceGetLogicalCoreIdRequest, DeviceGetLogicalCoreIdResponse>(
203                (index,),
204                0x7168f98ddbd26058,
205                fidl::encoding::DynamicFlags::empty(),
206                ___deadline,
207            )?;
208        Ok(_response.id)
209    }
210
211    /// Returns the id of this performance domain within its package. This
212    /// number should be stable across boots, but clients should prefer to use
213    /// GetRelativePerformance to differentiate cores if possible.
214    pub fn r#get_domain_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
215        let _response =
216            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetDomainIdResponse>(
217                (),
218                0x3030f85bdc1ef321,
219                fidl::encoding::DynamicFlags::empty(),
220                ___deadline,
221            )?;
222        Ok(_response.domain_id)
223    }
224
225    /// The relative performance of this domain as configured by the platform,
226    /// if known. The highest performance domain should return 255, while others
227    /// should return N/255 fractional values relative to that domain.
228    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
229    pub fn r#get_relative_performance(
230        &self,
231        ___deadline: zx::MonotonicInstant,
232    ) -> Result<DeviceGetRelativePerformanceResult, fidl::Error> {
233        let _response = self.client.send_query::<
234            fidl::encoding::EmptyPayload,
235            fidl::encoding::ResultType<DeviceGetRelativePerformanceResponse, i32>,
236        >(
237            (),
238            0x41c37eaf0c26a3d3,
239            fidl::encoding::DynamicFlags::empty(),
240            ___deadline,
241        )?;
242        Ok(_response.map(|x| x.relative_performance))
243    }
244}
245
246#[cfg(target_os = "fuchsia")]
247impl From<DeviceSynchronousProxy> for zx::Handle {
248    fn from(value: DeviceSynchronousProxy) -> Self {
249        value.into_channel().into()
250    }
251}
252
253#[cfg(target_os = "fuchsia")]
254impl From<fidl::Channel> for DeviceSynchronousProxy {
255    fn from(value: fidl::Channel) -> Self {
256        Self::new(value)
257    }
258}
259
260#[cfg(target_os = "fuchsia")]
261impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
262    type Protocol = DeviceMarker;
263
264    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
265        Self::new(value.into_channel())
266    }
267}
268
269#[derive(Debug, Clone)]
270pub struct DeviceProxy {
271    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
272}
273
274impl fidl::endpoints::Proxy for DeviceProxy {
275    type Protocol = DeviceMarker;
276
277    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
278        Self::new(inner)
279    }
280
281    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
282        self.client.into_channel().map_err(|client| Self { client })
283    }
284
285    fn as_channel(&self) -> &::fidl::AsyncChannel {
286        self.client.as_channel()
287    }
288}
289
290impl DeviceProxy {
291    /// Create a new Proxy for fuchsia.hardware.cpu.ctrl/Device.
292    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
293        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
294        Self { client: fidl::client::Client::new(channel, protocol_name) }
295    }
296
297    /// Get a Stream of events from the remote end of the protocol.
298    ///
299    /// # Panics
300    ///
301    /// Panics if the event stream was already taken.
302    pub fn take_event_stream(&self) -> DeviceEventStream {
303        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
304    }
305
306    /// Returns information about a given operating point for this performance
307    /// domain.
308    pub fn r#get_operating_point_info(
309        &self,
310        mut opp: u32,
311    ) -> fidl::client::QueryResponseFut<
312        DeviceGetOperatingPointInfoResult,
313        fidl::encoding::DefaultFuchsiaResourceDialect,
314    > {
315        DeviceProxyInterface::r#get_operating_point_info(self, opp)
316    }
317
318    /// Gets the current operating point of the device.
319    pub fn r#get_current_operating_point(
320        &self,
321    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
322        DeviceProxyInterface::r#get_current_operating_point(self)
323    }
324
325    /// Set the operating point of this device to the requested operating point.
326    /// Returns ZX_OK, if the device is in a working state and the operating point is changed to
327    /// requested_opp successfully. out_opp will be same as requested_opp.
328    /// Returns error status, if switching to the requested_opp was unsuccessful. out_opp
329    /// is the operating performance point (OPP) that the device is currently in.
330    pub fn r#set_current_operating_point(
331        &self,
332        mut requested_opp: u32,
333    ) -> fidl::client::QueryResponseFut<
334        DeviceSetCurrentOperatingPointResult,
335        fidl::encoding::DefaultFuchsiaResourceDialect,
336    > {
337        DeviceProxyInterface::r#set_current_operating_point(self, requested_opp)
338    }
339
340    /// Returns the number of operating points within this performance domain.
341    pub fn r#get_operating_point_count(
342        &self,
343    ) -> fidl::client::QueryResponseFut<
344        DeviceGetOperatingPointCountResult,
345        fidl::encoding::DefaultFuchsiaResourceDialect,
346    > {
347        DeviceProxyInterface::r#get_operating_point_count(self)
348    }
349
350    /// Returns the number of logical cores contained within this performance
351    /// domain.
352    pub fn r#get_num_logical_cores(
353        &self,
354    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
355        DeviceProxyInterface::r#get_num_logical_cores(self)
356    }
357
358    /// Returns a global system-wide core ID for the nth core in this
359    /// performance domain. `index` must be a value in the range [0, n) where
360    /// n is the value returned by GetNumLogicalCores().
361    pub fn r#get_logical_core_id(
362        &self,
363        mut index: u64,
364    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
365        DeviceProxyInterface::r#get_logical_core_id(self, index)
366    }
367
368    /// Returns the id of this performance domain within its package. This
369    /// number should be stable across boots, but clients should prefer to use
370    /// GetRelativePerformance to differentiate cores if possible.
371    pub fn r#get_domain_id(
372        &self,
373    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
374        DeviceProxyInterface::r#get_domain_id(self)
375    }
376
377    /// The relative performance of this domain as configured by the platform,
378    /// if known. The highest performance domain should return 255, while others
379    /// should return N/255 fractional values relative to that domain.
380    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
381    pub fn r#get_relative_performance(
382        &self,
383    ) -> fidl::client::QueryResponseFut<
384        DeviceGetRelativePerformanceResult,
385        fidl::encoding::DefaultFuchsiaResourceDialect,
386    > {
387        DeviceProxyInterface::r#get_relative_performance(self)
388    }
389}
390
391impl DeviceProxyInterface for DeviceProxy {
392    type GetOperatingPointInfoResponseFut = fidl::client::QueryResponseFut<
393        DeviceGetOperatingPointInfoResult,
394        fidl::encoding::DefaultFuchsiaResourceDialect,
395    >;
396    fn r#get_operating_point_info(&self, mut opp: u32) -> Self::GetOperatingPointInfoResponseFut {
397        fn _decode(
398            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
399        ) -> Result<DeviceGetOperatingPointInfoResult, fidl::Error> {
400            let _response = fidl::client::decode_transaction_body::<
401                fidl::encoding::ResultType<DeviceGetOperatingPointInfoResponse, i32>,
402                fidl::encoding::DefaultFuchsiaResourceDialect,
403                0x6594a9234fc958e2,
404            >(_buf?)?;
405            Ok(_response.map(|x| x.info))
406        }
407        self.client.send_query_and_decode::<
408            DeviceGetOperatingPointInfoRequest,
409            DeviceGetOperatingPointInfoResult,
410        >(
411            (opp,),
412            0x6594a9234fc958e2,
413            fidl::encoding::DynamicFlags::empty(),
414            _decode,
415        )
416    }
417
418    type GetCurrentOperatingPointResponseFut =
419        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
420    fn r#get_current_operating_point(&self) -> Self::GetCurrentOperatingPointResponseFut {
421        fn _decode(
422            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
423        ) -> Result<u32, fidl::Error> {
424            let _response = fidl::client::decode_transaction_body::<
425                DeviceGetCurrentOperatingPointResponse,
426                fidl::encoding::DefaultFuchsiaResourceDialect,
427                0x52de67a5993f5fe1,
428            >(_buf?)?;
429            Ok(_response.out_opp)
430        }
431        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
432            (),
433            0x52de67a5993f5fe1,
434            fidl::encoding::DynamicFlags::empty(),
435            _decode,
436        )
437    }
438
439    type SetCurrentOperatingPointResponseFut = fidl::client::QueryResponseFut<
440        DeviceSetCurrentOperatingPointResult,
441        fidl::encoding::DefaultFuchsiaResourceDialect,
442    >;
443    fn r#set_current_operating_point(
444        &self,
445        mut requested_opp: u32,
446    ) -> Self::SetCurrentOperatingPointResponseFut {
447        fn _decode(
448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
449        ) -> Result<DeviceSetCurrentOperatingPointResult, fidl::Error> {
450            let _response = fidl::client::decode_transaction_body::<
451                fidl::encoding::ResultType<DeviceSetCurrentOperatingPointResponse, i32>,
452                fidl::encoding::DefaultFuchsiaResourceDialect,
453                0x34a7828b5ca53fd,
454            >(_buf?)?;
455            Ok(_response.map(|x| x.out_opp))
456        }
457        self.client.send_query_and_decode::<
458            DeviceSetCurrentOperatingPointRequest,
459            DeviceSetCurrentOperatingPointResult,
460        >(
461            (requested_opp,),
462            0x34a7828b5ca53fd,
463            fidl::encoding::DynamicFlags::empty(),
464            _decode,
465        )
466    }
467
468    type GetOperatingPointCountResponseFut = fidl::client::QueryResponseFut<
469        DeviceGetOperatingPointCountResult,
470        fidl::encoding::DefaultFuchsiaResourceDialect,
471    >;
472    fn r#get_operating_point_count(&self) -> Self::GetOperatingPointCountResponseFut {
473        fn _decode(
474            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
475        ) -> Result<DeviceGetOperatingPointCountResult, fidl::Error> {
476            let _response = fidl::client::decode_transaction_body::<
477                fidl::encoding::ResultType<DeviceGetOperatingPointCountResponse, i32>,
478                fidl::encoding::DefaultFuchsiaResourceDialect,
479                0x13e70ec7131889ba,
480            >(_buf?)?;
481            Ok(_response.map(|x| x.count))
482        }
483        self.client.send_query_and_decode::<
484            fidl::encoding::EmptyPayload,
485            DeviceGetOperatingPointCountResult,
486        >(
487            (),
488            0x13e70ec7131889ba,
489            fidl::encoding::DynamicFlags::empty(),
490            _decode,
491        )
492    }
493
494    type GetNumLogicalCoresResponseFut =
495        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
496    fn r#get_num_logical_cores(&self) -> Self::GetNumLogicalCoresResponseFut {
497        fn _decode(
498            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
499        ) -> Result<u64, fidl::Error> {
500            let _response = fidl::client::decode_transaction_body::<
501                DeviceGetNumLogicalCoresResponse,
502                fidl::encoding::DefaultFuchsiaResourceDialect,
503                0x74e304c90ca165c5,
504            >(_buf?)?;
505            Ok(_response.count)
506        }
507        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
508            (),
509            0x74e304c90ca165c5,
510            fidl::encoding::DynamicFlags::empty(),
511            _decode,
512        )
513    }
514
515    type GetLogicalCoreIdResponseFut =
516        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
517    fn r#get_logical_core_id(&self, mut index: u64) -> Self::GetLogicalCoreIdResponseFut {
518        fn _decode(
519            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
520        ) -> Result<u64, fidl::Error> {
521            let _response = fidl::client::decode_transaction_body::<
522                DeviceGetLogicalCoreIdResponse,
523                fidl::encoding::DefaultFuchsiaResourceDialect,
524                0x7168f98ddbd26058,
525            >(_buf?)?;
526            Ok(_response.id)
527        }
528        self.client.send_query_and_decode::<DeviceGetLogicalCoreIdRequest, u64>(
529            (index,),
530            0x7168f98ddbd26058,
531            fidl::encoding::DynamicFlags::empty(),
532            _decode,
533        )
534    }
535
536    type GetDomainIdResponseFut =
537        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
538    fn r#get_domain_id(&self) -> Self::GetDomainIdResponseFut {
539        fn _decode(
540            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
541        ) -> Result<u32, fidl::Error> {
542            let _response = fidl::client::decode_transaction_body::<
543                DeviceGetDomainIdResponse,
544                fidl::encoding::DefaultFuchsiaResourceDialect,
545                0x3030f85bdc1ef321,
546            >(_buf?)?;
547            Ok(_response.domain_id)
548        }
549        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
550            (),
551            0x3030f85bdc1ef321,
552            fidl::encoding::DynamicFlags::empty(),
553            _decode,
554        )
555    }
556
557    type GetRelativePerformanceResponseFut = fidl::client::QueryResponseFut<
558        DeviceGetRelativePerformanceResult,
559        fidl::encoding::DefaultFuchsiaResourceDialect,
560    >;
561    fn r#get_relative_performance(&self) -> Self::GetRelativePerformanceResponseFut {
562        fn _decode(
563            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
564        ) -> Result<DeviceGetRelativePerformanceResult, fidl::Error> {
565            let _response = fidl::client::decode_transaction_body::<
566                fidl::encoding::ResultType<DeviceGetRelativePerformanceResponse, i32>,
567                fidl::encoding::DefaultFuchsiaResourceDialect,
568                0x41c37eaf0c26a3d3,
569            >(_buf?)?;
570            Ok(_response.map(|x| x.relative_performance))
571        }
572        self.client.send_query_and_decode::<
573            fidl::encoding::EmptyPayload,
574            DeviceGetRelativePerformanceResult,
575        >(
576            (),
577            0x41c37eaf0c26a3d3,
578            fidl::encoding::DynamicFlags::empty(),
579            _decode,
580        )
581    }
582}
583
584pub struct DeviceEventStream {
585    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
586}
587
588impl std::marker::Unpin for DeviceEventStream {}
589
590impl futures::stream::FusedStream for DeviceEventStream {
591    fn is_terminated(&self) -> bool {
592        self.event_receiver.is_terminated()
593    }
594}
595
596impl futures::Stream for DeviceEventStream {
597    type Item = Result<DeviceEvent, fidl::Error>;
598
599    fn poll_next(
600        mut self: std::pin::Pin<&mut Self>,
601        cx: &mut std::task::Context<'_>,
602    ) -> std::task::Poll<Option<Self::Item>> {
603        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
604            &mut self.event_receiver,
605            cx
606        )?) {
607            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
608            None => std::task::Poll::Ready(None),
609        }
610    }
611}
612
613#[derive(Debug)]
614pub enum DeviceEvent {}
615
616impl DeviceEvent {
617    /// Decodes a message buffer as a [`DeviceEvent`].
618    fn decode(
619        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
620    ) -> Result<DeviceEvent, fidl::Error> {
621        let (bytes, _handles) = buf.split_mut();
622        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
623        debug_assert_eq!(tx_header.tx_id, 0);
624        match tx_header.ordinal {
625            _ => Err(fidl::Error::UnknownOrdinal {
626                ordinal: tx_header.ordinal,
627                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
628            }),
629        }
630    }
631}
632
633/// A Stream of incoming requests for fuchsia.hardware.cpu.ctrl/Device.
634pub struct DeviceRequestStream {
635    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
636    is_terminated: bool,
637}
638
639impl std::marker::Unpin for DeviceRequestStream {}
640
641impl futures::stream::FusedStream for DeviceRequestStream {
642    fn is_terminated(&self) -> bool {
643        self.is_terminated
644    }
645}
646
647impl fidl::endpoints::RequestStream for DeviceRequestStream {
648    type Protocol = DeviceMarker;
649    type ControlHandle = DeviceControlHandle;
650
651    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
652        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
653    }
654
655    fn control_handle(&self) -> Self::ControlHandle {
656        DeviceControlHandle { inner: self.inner.clone() }
657    }
658
659    fn into_inner(
660        self,
661    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
662    {
663        (self.inner, self.is_terminated)
664    }
665
666    fn from_inner(
667        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
668        is_terminated: bool,
669    ) -> Self {
670        Self { inner, is_terminated }
671    }
672}
673
674impl futures::Stream for DeviceRequestStream {
675    type Item = Result<DeviceRequest, fidl::Error>;
676
677    fn poll_next(
678        mut self: std::pin::Pin<&mut Self>,
679        cx: &mut std::task::Context<'_>,
680    ) -> std::task::Poll<Option<Self::Item>> {
681        let this = &mut *self;
682        if this.inner.check_shutdown(cx) {
683            this.is_terminated = true;
684            return std::task::Poll::Ready(None);
685        }
686        if this.is_terminated {
687            panic!("polled DeviceRequestStream after completion");
688        }
689        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
690            |bytes, handles| {
691                match this.inner.channel().read_etc(cx, bytes, handles) {
692                    std::task::Poll::Ready(Ok(())) => {}
693                    std::task::Poll::Pending => return std::task::Poll::Pending,
694                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
695                        this.is_terminated = true;
696                        return std::task::Poll::Ready(None);
697                    }
698                    std::task::Poll::Ready(Err(e)) => {
699                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
700                            e.into(),
701                        ))))
702                    }
703                }
704
705                // A message has been received from the channel
706                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
707
708                std::task::Poll::Ready(Some(match header.ordinal {
709                    0x6594a9234fc958e2 => {
710                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
711                        let mut req = fidl::new_empty!(
712                            DeviceGetOperatingPointInfoRequest,
713                            fidl::encoding::DefaultFuchsiaResourceDialect
714                        );
715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetOperatingPointInfoRequest>(&header, _body_bytes, handles, &mut req)?;
716                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
717                        Ok(DeviceRequest::GetOperatingPointInfo {
718                            opp: req.opp,
719
720                            responder: DeviceGetOperatingPointInfoResponder {
721                                control_handle: std::mem::ManuallyDrop::new(control_handle),
722                                tx_id: header.tx_id,
723                            },
724                        })
725                    }
726                    0x52de67a5993f5fe1 => {
727                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
728                        let mut req = fidl::new_empty!(
729                            fidl::encoding::EmptyPayload,
730                            fidl::encoding::DefaultFuchsiaResourceDialect
731                        );
732                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
733                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
734                        Ok(DeviceRequest::GetCurrentOperatingPoint {
735                            responder: DeviceGetCurrentOperatingPointResponder {
736                                control_handle: std::mem::ManuallyDrop::new(control_handle),
737                                tx_id: header.tx_id,
738                            },
739                        })
740                    }
741                    0x34a7828b5ca53fd => {
742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
743                        let mut req = fidl::new_empty!(
744                            DeviceSetCurrentOperatingPointRequest,
745                            fidl::encoding::DefaultFuchsiaResourceDialect
746                        );
747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetCurrentOperatingPointRequest>(&header, _body_bytes, handles, &mut req)?;
748                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
749                        Ok(DeviceRequest::SetCurrentOperatingPoint {
750                            requested_opp: req.requested_opp,
751
752                            responder: DeviceSetCurrentOperatingPointResponder {
753                                control_handle: std::mem::ManuallyDrop::new(control_handle),
754                                tx_id: header.tx_id,
755                            },
756                        })
757                    }
758                    0x13e70ec7131889ba => {
759                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
760                        let mut req = fidl::new_empty!(
761                            fidl::encoding::EmptyPayload,
762                            fidl::encoding::DefaultFuchsiaResourceDialect
763                        );
764                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
765                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
766                        Ok(DeviceRequest::GetOperatingPointCount {
767                            responder: DeviceGetOperatingPointCountResponder {
768                                control_handle: std::mem::ManuallyDrop::new(control_handle),
769                                tx_id: header.tx_id,
770                            },
771                        })
772                    }
773                    0x74e304c90ca165c5 => {
774                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
775                        let mut req = fidl::new_empty!(
776                            fidl::encoding::EmptyPayload,
777                            fidl::encoding::DefaultFuchsiaResourceDialect
778                        );
779                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
780                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
781                        Ok(DeviceRequest::GetNumLogicalCores {
782                            responder: DeviceGetNumLogicalCoresResponder {
783                                control_handle: std::mem::ManuallyDrop::new(control_handle),
784                                tx_id: header.tx_id,
785                            },
786                        })
787                    }
788                    0x7168f98ddbd26058 => {
789                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
790                        let mut req = fidl::new_empty!(
791                            DeviceGetLogicalCoreIdRequest,
792                            fidl::encoding::DefaultFuchsiaResourceDialect
793                        );
794                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetLogicalCoreIdRequest>(&header, _body_bytes, handles, &mut req)?;
795                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
796                        Ok(DeviceRequest::GetLogicalCoreId {
797                            index: req.index,
798
799                            responder: DeviceGetLogicalCoreIdResponder {
800                                control_handle: std::mem::ManuallyDrop::new(control_handle),
801                                tx_id: header.tx_id,
802                            },
803                        })
804                    }
805                    0x3030f85bdc1ef321 => {
806                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
807                        let mut req = fidl::new_empty!(
808                            fidl::encoding::EmptyPayload,
809                            fidl::encoding::DefaultFuchsiaResourceDialect
810                        );
811                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
812                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
813                        Ok(DeviceRequest::GetDomainId {
814                            responder: DeviceGetDomainIdResponder {
815                                control_handle: std::mem::ManuallyDrop::new(control_handle),
816                                tx_id: header.tx_id,
817                            },
818                        })
819                    }
820                    0x41c37eaf0c26a3d3 => {
821                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
822                        let mut req = fidl::new_empty!(
823                            fidl::encoding::EmptyPayload,
824                            fidl::encoding::DefaultFuchsiaResourceDialect
825                        );
826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
827                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
828                        Ok(DeviceRequest::GetRelativePerformance {
829                            responder: DeviceGetRelativePerformanceResponder {
830                                control_handle: std::mem::ManuallyDrop::new(control_handle),
831                                tx_id: header.tx_id,
832                            },
833                        })
834                    }
835                    _ => Err(fidl::Error::UnknownOrdinal {
836                        ordinal: header.ordinal,
837                        protocol_name:
838                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
839                    }),
840                }))
841            },
842        )
843    }
844}
845
846#[derive(Debug)]
847pub enum DeviceRequest {
848    /// Returns information about a given operating point for this performance
849    /// domain.
850    GetOperatingPointInfo { opp: u32, responder: DeviceGetOperatingPointInfoResponder },
851    /// Gets the current operating point of the device.
852    GetCurrentOperatingPoint { responder: DeviceGetCurrentOperatingPointResponder },
853    /// Set the operating point of this device to the requested operating point.
854    /// Returns ZX_OK, if the device is in a working state and the operating point is changed to
855    /// requested_opp successfully. out_opp will be same as requested_opp.
856    /// Returns error status, if switching to the requested_opp was unsuccessful. out_opp
857    /// is the operating performance point (OPP) that the device is currently in.
858    SetCurrentOperatingPoint {
859        requested_opp: u32,
860        responder: DeviceSetCurrentOperatingPointResponder,
861    },
862    /// Returns the number of operating points within this performance domain.
863    GetOperatingPointCount { responder: DeviceGetOperatingPointCountResponder },
864    /// Returns the number of logical cores contained within this performance
865    /// domain.
866    GetNumLogicalCores { responder: DeviceGetNumLogicalCoresResponder },
867    /// Returns a global system-wide core ID for the nth core in this
868    /// performance domain. `index` must be a value in the range [0, n) where
869    /// n is the value returned by GetNumLogicalCores().
870    GetLogicalCoreId { index: u64, responder: DeviceGetLogicalCoreIdResponder },
871    /// Returns the id of this performance domain within its package. This
872    /// number should be stable across boots, but clients should prefer to use
873    /// GetRelativePerformance to differentiate cores if possible.
874    GetDomainId { responder: DeviceGetDomainIdResponder },
875    /// The relative performance of this domain as configured by the platform,
876    /// if known. The highest performance domain should return 255, while others
877    /// should return N/255 fractional values relative to that domain.
878    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
879    GetRelativePerformance { responder: DeviceGetRelativePerformanceResponder },
880}
881
882impl DeviceRequest {
883    #[allow(irrefutable_let_patterns)]
884    pub fn into_get_operating_point_info(
885        self,
886    ) -> Option<(u32, DeviceGetOperatingPointInfoResponder)> {
887        if let DeviceRequest::GetOperatingPointInfo { opp, responder } = self {
888            Some((opp, responder))
889        } else {
890            None
891        }
892    }
893
894    #[allow(irrefutable_let_patterns)]
895    pub fn into_get_current_operating_point(
896        self,
897    ) -> Option<(DeviceGetCurrentOperatingPointResponder)> {
898        if let DeviceRequest::GetCurrentOperatingPoint { responder } = self {
899            Some((responder))
900        } else {
901            None
902        }
903    }
904
905    #[allow(irrefutable_let_patterns)]
906    pub fn into_set_current_operating_point(
907        self,
908    ) -> Option<(u32, DeviceSetCurrentOperatingPointResponder)> {
909        if let DeviceRequest::SetCurrentOperatingPoint { requested_opp, responder } = self {
910            Some((requested_opp, responder))
911        } else {
912            None
913        }
914    }
915
916    #[allow(irrefutable_let_patterns)]
917    pub fn into_get_operating_point_count(self) -> Option<(DeviceGetOperatingPointCountResponder)> {
918        if let DeviceRequest::GetOperatingPointCount { responder } = self {
919            Some((responder))
920        } else {
921            None
922        }
923    }
924
925    #[allow(irrefutable_let_patterns)]
926    pub fn into_get_num_logical_cores(self) -> Option<(DeviceGetNumLogicalCoresResponder)> {
927        if let DeviceRequest::GetNumLogicalCores { responder } = self {
928            Some((responder))
929        } else {
930            None
931        }
932    }
933
934    #[allow(irrefutable_let_patterns)]
935    pub fn into_get_logical_core_id(self) -> Option<(u64, DeviceGetLogicalCoreIdResponder)> {
936        if let DeviceRequest::GetLogicalCoreId { index, responder } = self {
937            Some((index, responder))
938        } else {
939            None
940        }
941    }
942
943    #[allow(irrefutable_let_patterns)]
944    pub fn into_get_domain_id(self) -> Option<(DeviceGetDomainIdResponder)> {
945        if let DeviceRequest::GetDomainId { responder } = self {
946            Some((responder))
947        } else {
948            None
949        }
950    }
951
952    #[allow(irrefutable_let_patterns)]
953    pub fn into_get_relative_performance(self) -> Option<(DeviceGetRelativePerformanceResponder)> {
954        if let DeviceRequest::GetRelativePerformance { responder } = self {
955            Some((responder))
956        } else {
957            None
958        }
959    }
960
961    /// Name of the method defined in FIDL
962    pub fn method_name(&self) -> &'static str {
963        match *self {
964            DeviceRequest::GetOperatingPointInfo { .. } => "get_operating_point_info",
965            DeviceRequest::GetCurrentOperatingPoint { .. } => "get_current_operating_point",
966            DeviceRequest::SetCurrentOperatingPoint { .. } => "set_current_operating_point",
967            DeviceRequest::GetOperatingPointCount { .. } => "get_operating_point_count",
968            DeviceRequest::GetNumLogicalCores { .. } => "get_num_logical_cores",
969            DeviceRequest::GetLogicalCoreId { .. } => "get_logical_core_id",
970            DeviceRequest::GetDomainId { .. } => "get_domain_id",
971            DeviceRequest::GetRelativePerformance { .. } => "get_relative_performance",
972        }
973    }
974}
975
976#[derive(Debug, Clone)]
977pub struct DeviceControlHandle {
978    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
979}
980
981impl fidl::endpoints::ControlHandle for DeviceControlHandle {
982    fn shutdown(&self) {
983        self.inner.shutdown()
984    }
985    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
986        self.inner.shutdown_with_epitaph(status)
987    }
988
989    fn is_closed(&self) -> bool {
990        self.inner.channel().is_closed()
991    }
992    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
993        self.inner.channel().on_closed()
994    }
995
996    #[cfg(target_os = "fuchsia")]
997    fn signal_peer(
998        &self,
999        clear_mask: zx::Signals,
1000        set_mask: zx::Signals,
1001    ) -> Result<(), zx_status::Status> {
1002        use fidl::Peered;
1003        self.inner.channel().signal_peer(clear_mask, set_mask)
1004    }
1005}
1006
1007impl DeviceControlHandle {}
1008
1009#[must_use = "FIDL methods require a response to be sent"]
1010#[derive(Debug)]
1011pub struct DeviceGetOperatingPointInfoResponder {
1012    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1013    tx_id: u32,
1014}
1015
1016/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1017/// if the responder is dropped without sending a response, so that the client
1018/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1019impl std::ops::Drop for DeviceGetOperatingPointInfoResponder {
1020    fn drop(&mut self) {
1021        self.control_handle.shutdown();
1022        // Safety: drops once, never accessed again
1023        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1024    }
1025}
1026
1027impl fidl::endpoints::Responder for DeviceGetOperatingPointInfoResponder {
1028    type ControlHandle = DeviceControlHandle;
1029
1030    fn control_handle(&self) -> &DeviceControlHandle {
1031        &self.control_handle
1032    }
1033
1034    fn drop_without_shutdown(mut self) {
1035        // Safety: drops once, never accessed again due to mem::forget
1036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1037        // Prevent Drop from running (which would shut down the channel)
1038        std::mem::forget(self);
1039    }
1040}
1041
1042impl DeviceGetOperatingPointInfoResponder {
1043    /// Sends a response to the FIDL transaction.
1044    ///
1045    /// Sets the channel to shutdown if an error occurs.
1046    pub fn send(self, mut result: Result<&CpuOperatingPointInfo, i32>) -> Result<(), fidl::Error> {
1047        let _result = self.send_raw(result);
1048        if _result.is_err() {
1049            self.control_handle.shutdown();
1050        }
1051        self.drop_without_shutdown();
1052        _result
1053    }
1054
1055    /// Similar to "send" but does not shutdown the channel if an error occurs.
1056    pub fn send_no_shutdown_on_err(
1057        self,
1058        mut result: Result<&CpuOperatingPointInfo, i32>,
1059    ) -> Result<(), fidl::Error> {
1060        let _result = self.send_raw(result);
1061        self.drop_without_shutdown();
1062        _result
1063    }
1064
1065    fn send_raw(&self, mut result: Result<&CpuOperatingPointInfo, i32>) -> Result<(), fidl::Error> {
1066        self.control_handle.inner.send::<fidl::encoding::ResultType<
1067            DeviceGetOperatingPointInfoResponse,
1068            i32,
1069        >>(
1070            result.map(|info| (info,)),
1071            self.tx_id,
1072            0x6594a9234fc958e2,
1073            fidl::encoding::DynamicFlags::empty(),
1074        )
1075    }
1076}
1077
1078#[must_use = "FIDL methods require a response to be sent"]
1079#[derive(Debug)]
1080pub struct DeviceGetCurrentOperatingPointResponder {
1081    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1082    tx_id: u32,
1083}
1084
1085/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1086/// if the responder is dropped without sending a response, so that the client
1087/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1088impl std::ops::Drop for DeviceGetCurrentOperatingPointResponder {
1089    fn drop(&mut self) {
1090        self.control_handle.shutdown();
1091        // Safety: drops once, never accessed again
1092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1093    }
1094}
1095
1096impl fidl::endpoints::Responder for DeviceGetCurrentOperatingPointResponder {
1097    type ControlHandle = DeviceControlHandle;
1098
1099    fn control_handle(&self) -> &DeviceControlHandle {
1100        &self.control_handle
1101    }
1102
1103    fn drop_without_shutdown(mut self) {
1104        // Safety: drops once, never accessed again due to mem::forget
1105        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1106        // Prevent Drop from running (which would shut down the channel)
1107        std::mem::forget(self);
1108    }
1109}
1110
1111impl DeviceGetCurrentOperatingPointResponder {
1112    /// Sends a response to the FIDL transaction.
1113    ///
1114    /// Sets the channel to shutdown if an error occurs.
1115    pub fn send(self, mut out_opp: u32) -> Result<(), fidl::Error> {
1116        let _result = self.send_raw(out_opp);
1117        if _result.is_err() {
1118            self.control_handle.shutdown();
1119        }
1120        self.drop_without_shutdown();
1121        _result
1122    }
1123
1124    /// Similar to "send" but does not shutdown the channel if an error occurs.
1125    pub fn send_no_shutdown_on_err(self, mut out_opp: u32) -> Result<(), fidl::Error> {
1126        let _result = self.send_raw(out_opp);
1127        self.drop_without_shutdown();
1128        _result
1129    }
1130
1131    fn send_raw(&self, mut out_opp: u32) -> Result<(), fidl::Error> {
1132        self.control_handle.inner.send::<DeviceGetCurrentOperatingPointResponse>(
1133            (out_opp,),
1134            self.tx_id,
1135            0x52de67a5993f5fe1,
1136            fidl::encoding::DynamicFlags::empty(),
1137        )
1138    }
1139}
1140
1141#[must_use = "FIDL methods require a response to be sent"]
1142#[derive(Debug)]
1143pub struct DeviceSetCurrentOperatingPointResponder {
1144    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1145    tx_id: u32,
1146}
1147
1148/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1149/// if the responder is dropped without sending a response, so that the client
1150/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1151impl std::ops::Drop for DeviceSetCurrentOperatingPointResponder {
1152    fn drop(&mut self) {
1153        self.control_handle.shutdown();
1154        // Safety: drops once, never accessed again
1155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1156    }
1157}
1158
1159impl fidl::endpoints::Responder for DeviceSetCurrentOperatingPointResponder {
1160    type ControlHandle = DeviceControlHandle;
1161
1162    fn control_handle(&self) -> &DeviceControlHandle {
1163        &self.control_handle
1164    }
1165
1166    fn drop_without_shutdown(mut self) {
1167        // Safety: drops once, never accessed again due to mem::forget
1168        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1169        // Prevent Drop from running (which would shut down the channel)
1170        std::mem::forget(self);
1171    }
1172}
1173
1174impl DeviceSetCurrentOperatingPointResponder {
1175    /// Sends a response to the FIDL transaction.
1176    ///
1177    /// Sets the channel to shutdown if an error occurs.
1178    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1179        let _result = self.send_raw(result);
1180        if _result.is_err() {
1181            self.control_handle.shutdown();
1182        }
1183        self.drop_without_shutdown();
1184        _result
1185    }
1186
1187    /// Similar to "send" but does not shutdown the channel if an error occurs.
1188    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1189        let _result = self.send_raw(result);
1190        self.drop_without_shutdown();
1191        _result
1192    }
1193
1194    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1195        self.control_handle.inner.send::<fidl::encoding::ResultType<
1196            DeviceSetCurrentOperatingPointResponse,
1197            i32,
1198        >>(
1199            result.map(|out_opp| (out_opp,)),
1200            self.tx_id,
1201            0x34a7828b5ca53fd,
1202            fidl::encoding::DynamicFlags::empty(),
1203        )
1204    }
1205}
1206
1207#[must_use = "FIDL methods require a response to be sent"]
1208#[derive(Debug)]
1209pub struct DeviceGetOperatingPointCountResponder {
1210    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1211    tx_id: u32,
1212}
1213
1214/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1215/// if the responder is dropped without sending a response, so that the client
1216/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1217impl std::ops::Drop for DeviceGetOperatingPointCountResponder {
1218    fn drop(&mut self) {
1219        self.control_handle.shutdown();
1220        // Safety: drops once, never accessed again
1221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1222    }
1223}
1224
1225impl fidl::endpoints::Responder for DeviceGetOperatingPointCountResponder {
1226    type ControlHandle = DeviceControlHandle;
1227
1228    fn control_handle(&self) -> &DeviceControlHandle {
1229        &self.control_handle
1230    }
1231
1232    fn drop_without_shutdown(mut self) {
1233        // Safety: drops once, never accessed again due to mem::forget
1234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1235        // Prevent Drop from running (which would shut down the channel)
1236        std::mem::forget(self);
1237    }
1238}
1239
1240impl DeviceGetOperatingPointCountResponder {
1241    /// Sends a response to the FIDL transaction.
1242    ///
1243    /// Sets the channel to shutdown if an error occurs.
1244    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1245        let _result = self.send_raw(result);
1246        if _result.is_err() {
1247            self.control_handle.shutdown();
1248        }
1249        self.drop_without_shutdown();
1250        _result
1251    }
1252
1253    /// Similar to "send" but does not shutdown the channel if an error occurs.
1254    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1255        let _result = self.send_raw(result);
1256        self.drop_without_shutdown();
1257        _result
1258    }
1259
1260    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1261        self.control_handle.inner.send::<fidl::encoding::ResultType<
1262            DeviceGetOperatingPointCountResponse,
1263            i32,
1264        >>(
1265            result.map(|count| (count,)),
1266            self.tx_id,
1267            0x13e70ec7131889ba,
1268            fidl::encoding::DynamicFlags::empty(),
1269        )
1270    }
1271}
1272
1273#[must_use = "FIDL methods require a response to be sent"]
1274#[derive(Debug)]
1275pub struct DeviceGetNumLogicalCoresResponder {
1276    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1277    tx_id: u32,
1278}
1279
1280/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1281/// if the responder is dropped without sending a response, so that the client
1282/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1283impl std::ops::Drop for DeviceGetNumLogicalCoresResponder {
1284    fn drop(&mut self) {
1285        self.control_handle.shutdown();
1286        // Safety: drops once, never accessed again
1287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1288    }
1289}
1290
1291impl fidl::endpoints::Responder for DeviceGetNumLogicalCoresResponder {
1292    type ControlHandle = DeviceControlHandle;
1293
1294    fn control_handle(&self) -> &DeviceControlHandle {
1295        &self.control_handle
1296    }
1297
1298    fn drop_without_shutdown(mut self) {
1299        // Safety: drops once, never accessed again due to mem::forget
1300        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1301        // Prevent Drop from running (which would shut down the channel)
1302        std::mem::forget(self);
1303    }
1304}
1305
1306impl DeviceGetNumLogicalCoresResponder {
1307    /// Sends a response to the FIDL transaction.
1308    ///
1309    /// Sets the channel to shutdown if an error occurs.
1310    pub fn send(self, mut count: u64) -> Result<(), fidl::Error> {
1311        let _result = self.send_raw(count);
1312        if _result.is_err() {
1313            self.control_handle.shutdown();
1314        }
1315        self.drop_without_shutdown();
1316        _result
1317    }
1318
1319    /// Similar to "send" but does not shutdown the channel if an error occurs.
1320    pub fn send_no_shutdown_on_err(self, mut count: u64) -> Result<(), fidl::Error> {
1321        let _result = self.send_raw(count);
1322        self.drop_without_shutdown();
1323        _result
1324    }
1325
1326    fn send_raw(&self, mut count: u64) -> Result<(), fidl::Error> {
1327        self.control_handle.inner.send::<DeviceGetNumLogicalCoresResponse>(
1328            (count,),
1329            self.tx_id,
1330            0x74e304c90ca165c5,
1331            fidl::encoding::DynamicFlags::empty(),
1332        )
1333    }
1334}
1335
1336#[must_use = "FIDL methods require a response to be sent"]
1337#[derive(Debug)]
1338pub struct DeviceGetLogicalCoreIdResponder {
1339    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1340    tx_id: u32,
1341}
1342
1343/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1344/// if the responder is dropped without sending a response, so that the client
1345/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1346impl std::ops::Drop for DeviceGetLogicalCoreIdResponder {
1347    fn drop(&mut self) {
1348        self.control_handle.shutdown();
1349        // Safety: drops once, never accessed again
1350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1351    }
1352}
1353
1354impl fidl::endpoints::Responder for DeviceGetLogicalCoreIdResponder {
1355    type ControlHandle = DeviceControlHandle;
1356
1357    fn control_handle(&self) -> &DeviceControlHandle {
1358        &self.control_handle
1359    }
1360
1361    fn drop_without_shutdown(mut self) {
1362        // Safety: drops once, never accessed again due to mem::forget
1363        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1364        // Prevent Drop from running (which would shut down the channel)
1365        std::mem::forget(self);
1366    }
1367}
1368
1369impl DeviceGetLogicalCoreIdResponder {
1370    /// Sends a response to the FIDL transaction.
1371    ///
1372    /// Sets the channel to shutdown if an error occurs.
1373    pub fn send(self, mut id: u64) -> Result<(), fidl::Error> {
1374        let _result = self.send_raw(id);
1375        if _result.is_err() {
1376            self.control_handle.shutdown();
1377        }
1378        self.drop_without_shutdown();
1379        _result
1380    }
1381
1382    /// Similar to "send" but does not shutdown the channel if an error occurs.
1383    pub fn send_no_shutdown_on_err(self, mut id: u64) -> Result<(), fidl::Error> {
1384        let _result = self.send_raw(id);
1385        self.drop_without_shutdown();
1386        _result
1387    }
1388
1389    fn send_raw(&self, mut id: u64) -> Result<(), fidl::Error> {
1390        self.control_handle.inner.send::<DeviceGetLogicalCoreIdResponse>(
1391            (id,),
1392            self.tx_id,
1393            0x7168f98ddbd26058,
1394            fidl::encoding::DynamicFlags::empty(),
1395        )
1396    }
1397}
1398
1399#[must_use = "FIDL methods require a response to be sent"]
1400#[derive(Debug)]
1401pub struct DeviceGetDomainIdResponder {
1402    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1403    tx_id: u32,
1404}
1405
1406/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1407/// if the responder is dropped without sending a response, so that the client
1408/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1409impl std::ops::Drop for DeviceGetDomainIdResponder {
1410    fn drop(&mut self) {
1411        self.control_handle.shutdown();
1412        // Safety: drops once, never accessed again
1413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1414    }
1415}
1416
1417impl fidl::endpoints::Responder for DeviceGetDomainIdResponder {
1418    type ControlHandle = DeviceControlHandle;
1419
1420    fn control_handle(&self) -> &DeviceControlHandle {
1421        &self.control_handle
1422    }
1423
1424    fn drop_without_shutdown(mut self) {
1425        // Safety: drops once, never accessed again due to mem::forget
1426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1427        // Prevent Drop from running (which would shut down the channel)
1428        std::mem::forget(self);
1429    }
1430}
1431
1432impl DeviceGetDomainIdResponder {
1433    /// Sends a response to the FIDL transaction.
1434    ///
1435    /// Sets the channel to shutdown if an error occurs.
1436    pub fn send(self, mut domain_id: u32) -> Result<(), fidl::Error> {
1437        let _result = self.send_raw(domain_id);
1438        if _result.is_err() {
1439            self.control_handle.shutdown();
1440        }
1441        self.drop_without_shutdown();
1442        _result
1443    }
1444
1445    /// Similar to "send" but does not shutdown the channel if an error occurs.
1446    pub fn send_no_shutdown_on_err(self, mut domain_id: u32) -> Result<(), fidl::Error> {
1447        let _result = self.send_raw(domain_id);
1448        self.drop_without_shutdown();
1449        _result
1450    }
1451
1452    fn send_raw(&self, mut domain_id: u32) -> Result<(), fidl::Error> {
1453        self.control_handle.inner.send::<DeviceGetDomainIdResponse>(
1454            (domain_id,),
1455            self.tx_id,
1456            0x3030f85bdc1ef321,
1457            fidl::encoding::DynamicFlags::empty(),
1458        )
1459    }
1460}
1461
1462#[must_use = "FIDL methods require a response to be sent"]
1463#[derive(Debug)]
1464pub struct DeviceGetRelativePerformanceResponder {
1465    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1466    tx_id: u32,
1467}
1468
1469/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1470/// if the responder is dropped without sending a response, so that the client
1471/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1472impl std::ops::Drop for DeviceGetRelativePerformanceResponder {
1473    fn drop(&mut self) {
1474        self.control_handle.shutdown();
1475        // Safety: drops once, never accessed again
1476        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1477    }
1478}
1479
1480impl fidl::endpoints::Responder for DeviceGetRelativePerformanceResponder {
1481    type ControlHandle = DeviceControlHandle;
1482
1483    fn control_handle(&self) -> &DeviceControlHandle {
1484        &self.control_handle
1485    }
1486
1487    fn drop_without_shutdown(mut self) {
1488        // Safety: drops once, never accessed again due to mem::forget
1489        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1490        // Prevent Drop from running (which would shut down the channel)
1491        std::mem::forget(self);
1492    }
1493}
1494
1495impl DeviceGetRelativePerformanceResponder {
1496    /// Sends a response to the FIDL transaction.
1497    ///
1498    /// Sets the channel to shutdown if an error occurs.
1499    pub fn send(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
1500        let _result = self.send_raw(result);
1501        if _result.is_err() {
1502            self.control_handle.shutdown();
1503        }
1504        self.drop_without_shutdown();
1505        _result
1506    }
1507
1508    /// Similar to "send" but does not shutdown the channel if an error occurs.
1509    pub fn send_no_shutdown_on_err(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
1510        let _result = self.send_raw(result);
1511        self.drop_without_shutdown();
1512        _result
1513    }
1514
1515    fn send_raw(&self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
1516        self.control_handle.inner.send::<fidl::encoding::ResultType<
1517            DeviceGetRelativePerformanceResponse,
1518            i32,
1519        >>(
1520            result.map(|relative_performance| (relative_performance,)),
1521            self.tx_id,
1522            0x41c37eaf0c26a3d3,
1523            fidl::encoding::DynamicFlags::empty(),
1524        )
1525    }
1526}
1527
1528#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1529pub struct ServiceMarker;
1530
1531#[cfg(target_os = "fuchsia")]
1532impl fidl::endpoints::ServiceMarker for ServiceMarker {
1533    type Proxy = ServiceProxy;
1534    type Request = ServiceRequest;
1535    const SERVICE_NAME: &'static str = "fuchsia.hardware.cpu.ctrl.Service";
1536}
1537
1538/// A request for one of the member protocols of Service.
1539///
1540#[cfg(target_os = "fuchsia")]
1541pub enum ServiceRequest {
1542    Device(DeviceRequestStream),
1543}
1544
1545#[cfg(target_os = "fuchsia")]
1546impl fidl::endpoints::ServiceRequest for ServiceRequest {
1547    type Service = ServiceMarker;
1548
1549    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1550        match name {
1551            "device" => Self::Device(
1552                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1553            ),
1554            _ => panic!("no such member protocol name for service Service"),
1555        }
1556    }
1557
1558    fn member_names() -> &'static [&'static str] {
1559        &["device"]
1560    }
1561}
1562#[cfg(target_os = "fuchsia")]
1563pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1564
1565#[cfg(target_os = "fuchsia")]
1566impl fidl::endpoints::ServiceProxy for ServiceProxy {
1567    type Service = ServiceMarker;
1568
1569    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1570        Self(opener)
1571    }
1572}
1573
1574#[cfg(target_os = "fuchsia")]
1575impl ServiceProxy {
1576    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1577        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1578        self.connect_channel_to_device(server_end)?;
1579        Ok(proxy)
1580    }
1581
1582    /// Like `connect_to_device`, but returns a sync proxy.
1583    /// See [`Self::connect_to_device`] for more details.
1584    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1585        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1586        self.connect_channel_to_device(server_end)?;
1587        Ok(proxy)
1588    }
1589
1590    /// Like `connect_to_device`, but accepts a server end.
1591    /// See [`Self::connect_to_device`] for more details.
1592    pub fn connect_channel_to_device(
1593        &self,
1594        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1595    ) -> Result<(), fidl::Error> {
1596        self.0.open_member("device", server_end.into_channel())
1597    }
1598
1599    pub fn instance_name(&self) -> &str {
1600        self.0.instance_name()
1601    }
1602}
1603
1604mod internal {
1605    use super::*;
1606}