Skip to main content

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 DeviceSetMinimumOperatingPointLimitResult = Result<(), i32>;
28pub type DeviceSetMaximumOperatingPointLimitResult = Result<(), i32>;
29pub type DeviceSetOperatingPointLimitsResult = Result<(), i32>;
30pub type DeviceGetCurrentOperatingPointLimitsResult = Result<(u32, u32), i32>;
31pub type DeviceGetOperatingPointCountResult = Result<u32, i32>;
32pub type DeviceGetRelativePerformanceResult = Result<u8, i32>;
33pub type DeviceGetRelativePerformance2Result = Result<u64, i32>;
34
35pub trait DeviceProxyInterface: Send + Sync {
36    type GetOperatingPointInfoResponseFut: std::future::Future<Output = Result<DeviceGetOperatingPointInfoResult, fidl::Error>>
37        + Send;
38    fn r#get_operating_point_info(&self, opp: u32) -> Self::GetOperatingPointInfoResponseFut;
39    type GetCurrentOperatingPointResponseFut: std::future::Future<Output = Result<u32, fidl::Error>>
40        + Send;
41    fn r#get_current_operating_point(&self) -> Self::GetCurrentOperatingPointResponseFut;
42    type SetCurrentOperatingPointResponseFut: std::future::Future<Output = Result<DeviceSetCurrentOperatingPointResult, fidl::Error>>
43        + Send;
44    fn r#set_current_operating_point(
45        &self,
46        requested_opp: u32,
47    ) -> Self::SetCurrentOperatingPointResponseFut;
48    type SetMinimumOperatingPointLimitResponseFut: std::future::Future<Output = Result<DeviceSetMinimumOperatingPointLimitResult, fidl::Error>>
49        + Send;
50    fn r#set_minimum_operating_point_limit(
51        &self,
52        minimum_opp: u32,
53    ) -> Self::SetMinimumOperatingPointLimitResponseFut;
54    type SetMaximumOperatingPointLimitResponseFut: std::future::Future<Output = Result<DeviceSetMaximumOperatingPointLimitResult, fidl::Error>>
55        + Send;
56    fn r#set_maximum_operating_point_limit(
57        &self,
58        maximum_opp: u32,
59    ) -> Self::SetMaximumOperatingPointLimitResponseFut;
60    type SetOperatingPointLimitsResponseFut: std::future::Future<Output = Result<DeviceSetOperatingPointLimitsResult, fidl::Error>>
61        + Send;
62    fn r#set_operating_point_limits(
63        &self,
64        minimum_opp: u32,
65        maximum_opp: u32,
66    ) -> Self::SetOperatingPointLimitsResponseFut;
67    type GetCurrentOperatingPointLimitsResponseFut: std::future::Future<
68            Output = Result<DeviceGetCurrentOperatingPointLimitsResult, fidl::Error>,
69        > + Send;
70    fn r#get_current_operating_point_limits(
71        &self,
72    ) -> Self::GetCurrentOperatingPointLimitsResponseFut;
73    type GetOperatingPointCountResponseFut: std::future::Future<Output = Result<DeviceGetOperatingPointCountResult, fidl::Error>>
74        + Send;
75    fn r#get_operating_point_count(&self) -> Self::GetOperatingPointCountResponseFut;
76    type GetNumLogicalCoresResponseFut: std::future::Future<Output = Result<u64, fidl::Error>>
77        + Send;
78    fn r#get_num_logical_cores(&self) -> Self::GetNumLogicalCoresResponseFut;
79    type GetLogicalCoreIdResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
80    fn r#get_logical_core_id(&self, index: u64) -> Self::GetLogicalCoreIdResponseFut;
81    type GetDomainIdResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
82    fn r#get_domain_id(&self) -> Self::GetDomainIdResponseFut;
83    type GetRelativePerformanceResponseFut: std::future::Future<Output = Result<DeviceGetRelativePerformanceResult, fidl::Error>>
84        + Send;
85    fn r#get_relative_performance(&self) -> Self::GetRelativePerformanceResponseFut;
86    type GetRelativePerformance2ResponseFut: std::future::Future<Output = Result<DeviceGetRelativePerformance2Result, fidl::Error>>
87        + Send;
88    fn r#get_relative_performance2(&self) -> Self::GetRelativePerformance2ResponseFut;
89}
90#[derive(Debug)]
91#[cfg(target_os = "fuchsia")]
92pub struct DeviceSynchronousProxy {
93    client: fidl::client::sync::Client,
94}
95
96#[cfg(target_os = "fuchsia")]
97impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
98    type Proxy = DeviceProxy;
99    type Protocol = DeviceMarker;
100
101    fn from_channel(inner: fidl::Channel) -> Self {
102        Self::new(inner)
103    }
104
105    fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    fn as_channel(&self) -> &fidl::Channel {
110        self.client.as_channel()
111    }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl DeviceSynchronousProxy {
116    pub fn new(channel: fidl::Channel) -> Self {
117        Self { client: fidl::client::sync::Client::new(channel) }
118    }
119
120    pub fn into_channel(self) -> fidl::Channel {
121        self.client.into_channel()
122    }
123
124    /// Waits until an event arrives and returns it. It is safe for other
125    /// threads to make concurrent requests while waiting for an event.
126    pub fn wait_for_event(
127        &self,
128        deadline: zx::MonotonicInstant,
129    ) -> Result<DeviceEvent, fidl::Error> {
130        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
131    }
132
133    /// Returns information about a given operating point for this performance
134    /// domain.
135    pub fn r#get_operating_point_info(
136        &self,
137        mut opp: u32,
138        ___deadline: zx::MonotonicInstant,
139    ) -> Result<DeviceGetOperatingPointInfoResult, fidl::Error> {
140        let _response = self.client.send_query::<
141            DeviceGetOperatingPointInfoRequest,
142            fidl::encoding::ResultType<DeviceGetOperatingPointInfoResponse, i32>,
143            DeviceMarker,
144        >(
145            (opp,),
146            0x6594a9234fc958e2,
147            fidl::encoding::DynamicFlags::empty(),
148            ___deadline,
149        )?;
150        Ok(_response.map(|x| x.info))
151    }
152
153    /// Gets the current operating point of the device.
154    pub fn r#get_current_operating_point(
155        &self,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<u32, fidl::Error> {
158        let _response = self.client.send_query::<
159            fidl::encoding::EmptyPayload,
160            DeviceGetCurrentOperatingPointResponse,
161            DeviceMarker,
162        >(
163            (),
164            0x52de67a5993f5fe1,
165            fidl::encoding::DynamicFlags::empty(),
166            ___deadline,
167        )?;
168        Ok(_response.out_opp)
169    }
170
171    /// Set the operating point of this device to the requested operating point.
172    ///
173    /// Operating points are in numeric P-state order, such that the maximum
174    /// operating performance point is 0 and the minimum is n-1, where n is the
175    /// number of operating points returned by GetOperatingPointCount().
176    ///
177    /// The requested operating point may be clamped to the range [min, max]
178    /// when operating point limits are supported. See SetOperatingPointLimits
179    /// for details.
180    ///
181    /// Returns ZX_OK, if the device is in a working state and the operating
182    /// point is changed to requested_opp successfully. out_opp will be same as
183    /// requested_opp.
184    ///
185    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
186    /// [n-1, 0], where n is the number of operating points returned by
187    /// GetOperatingPointCount().
188    ///
189    /// Returns error status, if switching to the requested_opp was
190    /// unsuccessful. out_opp is the operating performance point (OPP) that the
191    /// device is currently in.
192    pub fn r#set_current_operating_point(
193        &self,
194        mut requested_opp: u32,
195        ___deadline: zx::MonotonicInstant,
196    ) -> Result<DeviceSetCurrentOperatingPointResult, fidl::Error> {
197        let _response = self.client.send_query::<
198            DeviceSetCurrentOperatingPointRequest,
199            fidl::encoding::ResultType<DeviceSetCurrentOperatingPointResponse, i32>,
200            DeviceMarker,
201        >(
202            (requested_opp,),
203            0x34a7828b5ca53fd,
204            fidl::encoding::DynamicFlags::empty(),
205            ___deadline,
206        )?;
207        Ok(_response.map(|x| x.out_opp))
208    }
209
210    /// Sets the minimum operating point to use, particularly when the kernel
211    /// automatically controls the operating points of this device.
212    ///
213    /// See SetOperatingPointLimits for details on the semantics of operating
214    /// point limits.
215    ///
216    /// Returns ZX_OK on success.
217    ///
218    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
219    /// [n-1, 0], where n is the number of operating points returned by
220    /// GetOperatingPointCount().
221    ///
222    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
223    pub fn r#set_minimum_operating_point_limit(
224        &self,
225        mut minimum_opp: u32,
226        ___deadline: zx::MonotonicInstant,
227    ) -> Result<DeviceSetMinimumOperatingPointLimitResult, fidl::Error> {
228        let _response = self.client.send_query::<
229            DeviceSetMinimumOperatingPointLimitRequest,
230            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
231            DeviceMarker,
232        >(
233            (minimum_opp,),
234            0x5467de86fa3fdfe7,
235            fidl::encoding::DynamicFlags::empty(),
236            ___deadline,
237        )?;
238        Ok(_response.map(|x| x))
239    }
240
241    /// Sets the maximum operating point to use, particularly when the kernel
242    /// automatically controls the operating points of this device.
243    ///
244    /// See SetOperatingPointLimits for details on the semantics of operating
245    /// point limits.
246    ///
247    /// Returns ZX_OK on success.
248    ///
249    /// Returns ZX_ERR_OUT_OF_RANGE if the maximum_opp is outside of the range
250    /// [n-1, 0], where n is the number of operating points returned by
251    /// GetOperatingPointCount().
252    ///
253    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
254    pub fn r#set_maximum_operating_point_limit(
255        &self,
256        mut maximum_opp: u32,
257        ___deadline: zx::MonotonicInstant,
258    ) -> Result<DeviceSetMaximumOperatingPointLimitResult, fidl::Error> {
259        let _response = self.client.send_query::<
260            DeviceSetMaximumOperatingPointLimitRequest,
261            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
262            DeviceMarker,
263        >(
264            (maximum_opp,),
265            0x385fa4d74481fbfd,
266            fidl::encoding::DynamicFlags::empty(),
267            ___deadline,
268        )?;
269        Ok(_response.map(|x| x))
270    }
271
272    /// Sets the operational boundaries (minimum and maximum operating points)
273    /// for the device, when supported.
274    ///
275    /// Limits define the allowable performance range for the performance
276    /// domain. They are primarily used for:
277    /// * Thermal Mitigation: Progressively lowering the maximum operating point
278    ///   (moving from 0 toward n-1) to reduce power dissipation.
279    /// * Performance Boosting: Raising the minimum operating point (moving
280    ///   from n-1 toward 0) when automatic performance matching is insufficient
281    ///   for the current workload.
282    ///
283    /// Limits are useful on platforms where ether hardware or the kernel
284    /// automatically manages performance. By setting boundaries, userspace can
285    /// enforce power and performance policies while allowing the underlying
286    /// system to react to high-fidelity signals in real-time.
287    ///
288    /// When limits are applied, the active operating point is clamped to the range:
289    /// `[max(minimum_opp, maximim_opp), maximum_opp]`.
290    ///
291    /// Note that `maximim_opp` and `minimum_opp` reside in the P-state range [n-1, 0].
292    /// This logic ensures that the `minimum_opp` can be adjusted independently while
293    /// always respecting the ceiling imposed by the `maximim_opp`.
294    ///
295    /// Set the operating point limits to (n-1, 0) to effectively remove the limits.
296    ///
297    /// Returns ZX_OK on success.
298    ///
299    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp or maximum_opp is outside
300    /// of the range [n-1, 0], where n is the number of operating points
301    /// returned by GetOperatingPointCount().
302    ///
303    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
304    pub fn r#set_operating_point_limits(
305        &self,
306        mut minimum_opp: u32,
307        mut maximum_opp: u32,
308        ___deadline: zx::MonotonicInstant,
309    ) -> Result<DeviceSetOperatingPointLimitsResult, fidl::Error> {
310        let _response = self.client.send_query::<
311            DeviceSetOperatingPointLimitsRequest,
312            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
313            DeviceMarker,
314        >(
315            (minimum_opp, maximum_opp,),
316            0x30aa7514dd598b23,
317            fidl::encoding::DynamicFlags::empty(),
318            ___deadline,
319        )?;
320        Ok(_response.map(|x| x))
321    }
322
323    /// Returns the current minimum and maximum operating point limits.
324    ///
325    /// Returns ZX_OK on success.
326    ///
327    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
328    pub fn r#get_current_operating_point_limits(
329        &self,
330        ___deadline: zx::MonotonicInstant,
331    ) -> Result<DeviceGetCurrentOperatingPointLimitsResult, fidl::Error> {
332        let _response =
333            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
334                DeviceGetCurrentOperatingPointLimitsResponse,
335                i32,
336            >, DeviceMarker>(
337                (),
338                0x7aefe3d765cfc6a7,
339                fidl::encoding::DynamicFlags::empty(),
340                ___deadline,
341            )?;
342        Ok(_response.map(|x| (x.minimum_opp, x.maximum_opp)))
343    }
344
345    /// Returns the number of operating points within this performance domain.
346    pub fn r#get_operating_point_count(
347        &self,
348        ___deadline: zx::MonotonicInstant,
349    ) -> Result<DeviceGetOperatingPointCountResult, fidl::Error> {
350        let _response = self.client.send_query::<
351            fidl::encoding::EmptyPayload,
352            fidl::encoding::ResultType<DeviceGetOperatingPointCountResponse, i32>,
353            DeviceMarker,
354        >(
355            (),
356            0x13e70ec7131889ba,
357            fidl::encoding::DynamicFlags::empty(),
358            ___deadline,
359        )?;
360        Ok(_response.map(|x| x.count))
361    }
362
363    /// Returns the number of logical cores contained within this performance
364    /// domain.
365    pub fn r#get_num_logical_cores(
366        &self,
367        ___deadline: zx::MonotonicInstant,
368    ) -> Result<u64, fidl::Error> {
369        let _response = self.client.send_query::<
370            fidl::encoding::EmptyPayload,
371            DeviceGetNumLogicalCoresResponse,
372            DeviceMarker,
373        >(
374            (),
375            0x74e304c90ca165c5,
376            fidl::encoding::DynamicFlags::empty(),
377            ___deadline,
378        )?;
379        Ok(_response.count)
380    }
381
382    /// Returns a global system-wide core ID for the nth core in this
383    /// performance domain. `index` must be a value in the range [0, n) where
384    /// n is the value returned by GetNumLogicalCores().
385    pub fn r#get_logical_core_id(
386        &self,
387        mut index: u64,
388        ___deadline: zx::MonotonicInstant,
389    ) -> Result<u64, fidl::Error> {
390        let _response = self.client.send_query::<
391            DeviceGetLogicalCoreIdRequest,
392            DeviceGetLogicalCoreIdResponse,
393            DeviceMarker,
394        >(
395            (index,),
396            0x7168f98ddbd26058,
397            fidl::encoding::DynamicFlags::empty(),
398            ___deadline,
399        )?;
400        Ok(_response.id)
401    }
402
403    /// Returns the id of this performance domain within its package. This
404    /// number should be stable across boots, but clients should prefer to use
405    /// GetRelativePerformance to differentiate cores if possible.
406    pub fn r#get_domain_id(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
407        let _response = self
408            .client
409            .send_query::<fidl::encoding::EmptyPayload, DeviceGetDomainIdResponse, DeviceMarker>(
410                (),
411                0x3030f85bdc1ef321,
412                fidl::encoding::DynamicFlags::empty(),
413                ___deadline,
414            )?;
415        Ok(_response.domain_id)
416    }
417
418    /// The relative performance of this domain as configured by the platform,
419    /// if known. The highest performance domain should return 255, while others
420    /// should return N/255 fractional values relative to that domain.
421    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
422    pub fn r#get_relative_performance(
423        &self,
424        ___deadline: zx::MonotonicInstant,
425    ) -> Result<DeviceGetRelativePerformanceResult, fidl::Error> {
426        let _response = self.client.send_query::<
427            fidl::encoding::EmptyPayload,
428            fidl::encoding::ResultType<DeviceGetRelativePerformanceResponse, i32>,
429            DeviceMarker,
430        >(
431            (),
432            0x41c37eaf0c26a3d3,
433            fidl::encoding::DynamicFlags::empty(),
434            ___deadline,
435        )?;
436        Ok(_response.map(|x| x.relative_performance))
437    }
438
439    /// The relative performance of this domain as configured by the platform,
440    /// if known.
441    ///
442    /// The relative performance is a unitless value. To calculate normalized
443    /// performance rates from the relative rates, a user would need to query
444    /// each performance domain to determine the maximum performance value
445    /// before calculating normalized values.
446    ///
447    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
448    pub fn r#get_relative_performance2(
449        &self,
450        ___deadline: zx::MonotonicInstant,
451    ) -> Result<DeviceGetRelativePerformance2Result, fidl::Error> {
452        let _response = self.client.send_query::<
453            fidl::encoding::EmptyPayload,
454            fidl::encoding::FlexibleResultType<DeviceGetRelativePerformance2Response, i32>,
455            DeviceMarker,
456        >(
457            (),
458            0x48831ad9a7fc2e38,
459            fidl::encoding::DynamicFlags::FLEXIBLE,
460            ___deadline,
461        )?
462        .into_result::<DeviceMarker>("get_relative_performance2")?;
463        Ok(_response.map(|x| x.relative_performance))
464    }
465}
466
467#[cfg(target_os = "fuchsia")]
468impl From<DeviceSynchronousProxy> for zx::NullableHandle {
469    fn from(value: DeviceSynchronousProxy) -> Self {
470        value.into_channel().into()
471    }
472}
473
474#[cfg(target_os = "fuchsia")]
475impl From<fidl::Channel> for DeviceSynchronousProxy {
476    fn from(value: fidl::Channel) -> Self {
477        Self::new(value)
478    }
479}
480
481#[cfg(target_os = "fuchsia")]
482impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
483    type Protocol = DeviceMarker;
484
485    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
486        Self::new(value.into_channel())
487    }
488}
489
490#[derive(Debug, Clone)]
491pub struct DeviceProxy {
492    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
493}
494
495impl fidl::endpoints::Proxy for DeviceProxy {
496    type Protocol = DeviceMarker;
497
498    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
499        Self::new(inner)
500    }
501
502    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
503        self.client.into_channel().map_err(|client| Self { client })
504    }
505
506    fn as_channel(&self) -> &::fidl::AsyncChannel {
507        self.client.as_channel()
508    }
509}
510
511impl DeviceProxy {
512    /// Create a new Proxy for fuchsia.hardware.cpu.ctrl/Device.
513    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
514        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
515        Self { client: fidl::client::Client::new(channel, protocol_name) }
516    }
517
518    /// Get a Stream of events from the remote end of the protocol.
519    ///
520    /// # Panics
521    ///
522    /// Panics if the event stream was already taken.
523    pub fn take_event_stream(&self) -> DeviceEventStream {
524        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
525    }
526
527    /// Returns information about a given operating point for this performance
528    /// domain.
529    pub fn r#get_operating_point_info(
530        &self,
531        mut opp: u32,
532    ) -> fidl::client::QueryResponseFut<
533        DeviceGetOperatingPointInfoResult,
534        fidl::encoding::DefaultFuchsiaResourceDialect,
535    > {
536        DeviceProxyInterface::r#get_operating_point_info(self, opp)
537    }
538
539    /// Gets the current operating point of the device.
540    pub fn r#get_current_operating_point(
541        &self,
542    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
543        DeviceProxyInterface::r#get_current_operating_point(self)
544    }
545
546    /// Set the operating point of this device to the requested operating point.
547    ///
548    /// Operating points are in numeric P-state order, such that the maximum
549    /// operating performance point is 0 and the minimum is n-1, where n is the
550    /// number of operating points returned by GetOperatingPointCount().
551    ///
552    /// The requested operating point may be clamped to the range [min, max]
553    /// when operating point limits are supported. See SetOperatingPointLimits
554    /// for details.
555    ///
556    /// Returns ZX_OK, if the device is in a working state and the operating
557    /// point is changed to requested_opp successfully. out_opp will be same as
558    /// requested_opp.
559    ///
560    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
561    /// [n-1, 0], where n is the number of operating points returned by
562    /// GetOperatingPointCount().
563    ///
564    /// Returns error status, if switching to the requested_opp was
565    /// unsuccessful. out_opp is the operating performance point (OPP) that the
566    /// device is currently in.
567    pub fn r#set_current_operating_point(
568        &self,
569        mut requested_opp: u32,
570    ) -> fidl::client::QueryResponseFut<
571        DeviceSetCurrentOperatingPointResult,
572        fidl::encoding::DefaultFuchsiaResourceDialect,
573    > {
574        DeviceProxyInterface::r#set_current_operating_point(self, requested_opp)
575    }
576
577    /// Sets the minimum operating point to use, particularly when the kernel
578    /// automatically controls the operating points of this device.
579    ///
580    /// See SetOperatingPointLimits for details on the semantics of operating
581    /// point limits.
582    ///
583    /// Returns ZX_OK on success.
584    ///
585    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
586    /// [n-1, 0], where n is the number of operating points returned by
587    /// GetOperatingPointCount().
588    ///
589    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
590    pub fn r#set_minimum_operating_point_limit(
591        &self,
592        mut minimum_opp: u32,
593    ) -> fidl::client::QueryResponseFut<
594        DeviceSetMinimumOperatingPointLimitResult,
595        fidl::encoding::DefaultFuchsiaResourceDialect,
596    > {
597        DeviceProxyInterface::r#set_minimum_operating_point_limit(self, minimum_opp)
598    }
599
600    /// Sets the maximum operating point to use, particularly when the kernel
601    /// automatically controls the operating points of this device.
602    ///
603    /// See SetOperatingPointLimits for details on the semantics of operating
604    /// point limits.
605    ///
606    /// Returns ZX_OK on success.
607    ///
608    /// Returns ZX_ERR_OUT_OF_RANGE if the maximum_opp is outside of the range
609    /// [n-1, 0], where n is the number of operating points returned by
610    /// GetOperatingPointCount().
611    ///
612    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
613    pub fn r#set_maximum_operating_point_limit(
614        &self,
615        mut maximum_opp: u32,
616    ) -> fidl::client::QueryResponseFut<
617        DeviceSetMaximumOperatingPointLimitResult,
618        fidl::encoding::DefaultFuchsiaResourceDialect,
619    > {
620        DeviceProxyInterface::r#set_maximum_operating_point_limit(self, maximum_opp)
621    }
622
623    /// Sets the operational boundaries (minimum and maximum operating points)
624    /// for the device, when supported.
625    ///
626    /// Limits define the allowable performance range for the performance
627    /// domain. They are primarily used for:
628    /// * Thermal Mitigation: Progressively lowering the maximum operating point
629    ///   (moving from 0 toward n-1) to reduce power dissipation.
630    /// * Performance Boosting: Raising the minimum operating point (moving
631    ///   from n-1 toward 0) when automatic performance matching is insufficient
632    ///   for the current workload.
633    ///
634    /// Limits are useful on platforms where ether hardware or the kernel
635    /// automatically manages performance. By setting boundaries, userspace can
636    /// enforce power and performance policies while allowing the underlying
637    /// system to react to high-fidelity signals in real-time.
638    ///
639    /// When limits are applied, the active operating point is clamped to the range:
640    /// `[max(minimum_opp, maximim_opp), maximum_opp]`.
641    ///
642    /// Note that `maximim_opp` and `minimum_opp` reside in the P-state range [n-1, 0].
643    /// This logic ensures that the `minimum_opp` can be adjusted independently while
644    /// always respecting the ceiling imposed by the `maximim_opp`.
645    ///
646    /// Set the operating point limits to (n-1, 0) to effectively remove the limits.
647    ///
648    /// Returns ZX_OK on success.
649    ///
650    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp or maximum_opp is outside
651    /// of the range [n-1, 0], where n is the number of operating points
652    /// returned by GetOperatingPointCount().
653    ///
654    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
655    pub fn r#set_operating_point_limits(
656        &self,
657        mut minimum_opp: u32,
658        mut maximum_opp: u32,
659    ) -> fidl::client::QueryResponseFut<
660        DeviceSetOperatingPointLimitsResult,
661        fidl::encoding::DefaultFuchsiaResourceDialect,
662    > {
663        DeviceProxyInterface::r#set_operating_point_limits(self, minimum_opp, maximum_opp)
664    }
665
666    /// Returns the current minimum and maximum operating point limits.
667    ///
668    /// Returns ZX_OK on success.
669    ///
670    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
671    pub fn r#get_current_operating_point_limits(
672        &self,
673    ) -> fidl::client::QueryResponseFut<
674        DeviceGetCurrentOperatingPointLimitsResult,
675        fidl::encoding::DefaultFuchsiaResourceDialect,
676    > {
677        DeviceProxyInterface::r#get_current_operating_point_limits(self)
678    }
679
680    /// Returns the number of operating points within this performance domain.
681    pub fn r#get_operating_point_count(
682        &self,
683    ) -> fidl::client::QueryResponseFut<
684        DeviceGetOperatingPointCountResult,
685        fidl::encoding::DefaultFuchsiaResourceDialect,
686    > {
687        DeviceProxyInterface::r#get_operating_point_count(self)
688    }
689
690    /// Returns the number of logical cores contained within this performance
691    /// domain.
692    pub fn r#get_num_logical_cores(
693        &self,
694    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
695        DeviceProxyInterface::r#get_num_logical_cores(self)
696    }
697
698    /// Returns a global system-wide core ID for the nth core in this
699    /// performance domain. `index` must be a value in the range [0, n) where
700    /// n is the value returned by GetNumLogicalCores().
701    pub fn r#get_logical_core_id(
702        &self,
703        mut index: u64,
704    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
705        DeviceProxyInterface::r#get_logical_core_id(self, index)
706    }
707
708    /// Returns the id of this performance domain within its package. This
709    /// number should be stable across boots, but clients should prefer to use
710    /// GetRelativePerformance to differentiate cores if possible.
711    pub fn r#get_domain_id(
712        &self,
713    ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
714        DeviceProxyInterface::r#get_domain_id(self)
715    }
716
717    /// The relative performance of this domain as configured by the platform,
718    /// if known. The highest performance domain should return 255, while others
719    /// should return N/255 fractional values relative to that domain.
720    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
721    pub fn r#get_relative_performance(
722        &self,
723    ) -> fidl::client::QueryResponseFut<
724        DeviceGetRelativePerformanceResult,
725        fidl::encoding::DefaultFuchsiaResourceDialect,
726    > {
727        DeviceProxyInterface::r#get_relative_performance(self)
728    }
729
730    /// The relative performance of this domain as configured by the platform,
731    /// if known.
732    ///
733    /// The relative performance is a unitless value. To calculate normalized
734    /// performance rates from the relative rates, a user would need to query
735    /// each performance domain to determine the maximum performance value
736    /// before calculating normalized values.
737    ///
738    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
739    pub fn r#get_relative_performance2(
740        &self,
741    ) -> fidl::client::QueryResponseFut<
742        DeviceGetRelativePerformance2Result,
743        fidl::encoding::DefaultFuchsiaResourceDialect,
744    > {
745        DeviceProxyInterface::r#get_relative_performance2(self)
746    }
747}
748
749impl DeviceProxyInterface for DeviceProxy {
750    type GetOperatingPointInfoResponseFut = fidl::client::QueryResponseFut<
751        DeviceGetOperatingPointInfoResult,
752        fidl::encoding::DefaultFuchsiaResourceDialect,
753    >;
754    fn r#get_operating_point_info(&self, mut opp: u32) -> Self::GetOperatingPointInfoResponseFut {
755        fn _decode(
756            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
757        ) -> Result<DeviceGetOperatingPointInfoResult, fidl::Error> {
758            let _response = fidl::client::decode_transaction_body::<
759                fidl::encoding::ResultType<DeviceGetOperatingPointInfoResponse, i32>,
760                fidl::encoding::DefaultFuchsiaResourceDialect,
761                0x6594a9234fc958e2,
762            >(_buf?)?;
763            Ok(_response.map(|x| x.info))
764        }
765        self.client.send_query_and_decode::<
766            DeviceGetOperatingPointInfoRequest,
767            DeviceGetOperatingPointInfoResult,
768        >(
769            (opp,),
770            0x6594a9234fc958e2,
771            fidl::encoding::DynamicFlags::empty(),
772            _decode,
773        )
774    }
775
776    type GetCurrentOperatingPointResponseFut =
777        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
778    fn r#get_current_operating_point(&self) -> Self::GetCurrentOperatingPointResponseFut {
779        fn _decode(
780            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
781        ) -> Result<u32, fidl::Error> {
782            let _response = fidl::client::decode_transaction_body::<
783                DeviceGetCurrentOperatingPointResponse,
784                fidl::encoding::DefaultFuchsiaResourceDialect,
785                0x52de67a5993f5fe1,
786            >(_buf?)?;
787            Ok(_response.out_opp)
788        }
789        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
790            (),
791            0x52de67a5993f5fe1,
792            fidl::encoding::DynamicFlags::empty(),
793            _decode,
794        )
795    }
796
797    type SetCurrentOperatingPointResponseFut = fidl::client::QueryResponseFut<
798        DeviceSetCurrentOperatingPointResult,
799        fidl::encoding::DefaultFuchsiaResourceDialect,
800    >;
801    fn r#set_current_operating_point(
802        &self,
803        mut requested_opp: u32,
804    ) -> Self::SetCurrentOperatingPointResponseFut {
805        fn _decode(
806            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
807        ) -> Result<DeviceSetCurrentOperatingPointResult, fidl::Error> {
808            let _response = fidl::client::decode_transaction_body::<
809                fidl::encoding::ResultType<DeviceSetCurrentOperatingPointResponse, i32>,
810                fidl::encoding::DefaultFuchsiaResourceDialect,
811                0x34a7828b5ca53fd,
812            >(_buf?)?;
813            Ok(_response.map(|x| x.out_opp))
814        }
815        self.client.send_query_and_decode::<
816            DeviceSetCurrentOperatingPointRequest,
817            DeviceSetCurrentOperatingPointResult,
818        >(
819            (requested_opp,),
820            0x34a7828b5ca53fd,
821            fidl::encoding::DynamicFlags::empty(),
822            _decode,
823        )
824    }
825
826    type SetMinimumOperatingPointLimitResponseFut = fidl::client::QueryResponseFut<
827        DeviceSetMinimumOperatingPointLimitResult,
828        fidl::encoding::DefaultFuchsiaResourceDialect,
829    >;
830    fn r#set_minimum_operating_point_limit(
831        &self,
832        mut minimum_opp: u32,
833    ) -> Self::SetMinimumOperatingPointLimitResponseFut {
834        fn _decode(
835            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
836        ) -> Result<DeviceSetMinimumOperatingPointLimitResult, fidl::Error> {
837            let _response = fidl::client::decode_transaction_body::<
838                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
839                fidl::encoding::DefaultFuchsiaResourceDialect,
840                0x5467de86fa3fdfe7,
841            >(_buf?)?;
842            Ok(_response.map(|x| x))
843        }
844        self.client.send_query_and_decode::<
845            DeviceSetMinimumOperatingPointLimitRequest,
846            DeviceSetMinimumOperatingPointLimitResult,
847        >(
848            (minimum_opp,),
849            0x5467de86fa3fdfe7,
850            fidl::encoding::DynamicFlags::empty(),
851            _decode,
852        )
853    }
854
855    type SetMaximumOperatingPointLimitResponseFut = fidl::client::QueryResponseFut<
856        DeviceSetMaximumOperatingPointLimitResult,
857        fidl::encoding::DefaultFuchsiaResourceDialect,
858    >;
859    fn r#set_maximum_operating_point_limit(
860        &self,
861        mut maximum_opp: u32,
862    ) -> Self::SetMaximumOperatingPointLimitResponseFut {
863        fn _decode(
864            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
865        ) -> Result<DeviceSetMaximumOperatingPointLimitResult, fidl::Error> {
866            let _response = fidl::client::decode_transaction_body::<
867                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
868                fidl::encoding::DefaultFuchsiaResourceDialect,
869                0x385fa4d74481fbfd,
870            >(_buf?)?;
871            Ok(_response.map(|x| x))
872        }
873        self.client.send_query_and_decode::<
874            DeviceSetMaximumOperatingPointLimitRequest,
875            DeviceSetMaximumOperatingPointLimitResult,
876        >(
877            (maximum_opp,),
878            0x385fa4d74481fbfd,
879            fidl::encoding::DynamicFlags::empty(),
880            _decode,
881        )
882    }
883
884    type SetOperatingPointLimitsResponseFut = fidl::client::QueryResponseFut<
885        DeviceSetOperatingPointLimitsResult,
886        fidl::encoding::DefaultFuchsiaResourceDialect,
887    >;
888    fn r#set_operating_point_limits(
889        &self,
890        mut minimum_opp: u32,
891        mut maximum_opp: u32,
892    ) -> Self::SetOperatingPointLimitsResponseFut {
893        fn _decode(
894            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
895        ) -> Result<DeviceSetOperatingPointLimitsResult, fidl::Error> {
896            let _response = fidl::client::decode_transaction_body::<
897                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
898                fidl::encoding::DefaultFuchsiaResourceDialect,
899                0x30aa7514dd598b23,
900            >(_buf?)?;
901            Ok(_response.map(|x| x))
902        }
903        self.client.send_query_and_decode::<
904            DeviceSetOperatingPointLimitsRequest,
905            DeviceSetOperatingPointLimitsResult,
906        >(
907            (minimum_opp, maximum_opp,),
908            0x30aa7514dd598b23,
909            fidl::encoding::DynamicFlags::empty(),
910            _decode,
911        )
912    }
913
914    type GetCurrentOperatingPointLimitsResponseFut = fidl::client::QueryResponseFut<
915        DeviceGetCurrentOperatingPointLimitsResult,
916        fidl::encoding::DefaultFuchsiaResourceDialect,
917    >;
918    fn r#get_current_operating_point_limits(
919        &self,
920    ) -> Self::GetCurrentOperatingPointLimitsResponseFut {
921        fn _decode(
922            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
923        ) -> Result<DeviceGetCurrentOperatingPointLimitsResult, fidl::Error> {
924            let _response = fidl::client::decode_transaction_body::<
925                fidl::encoding::ResultType<DeviceGetCurrentOperatingPointLimitsResponse, i32>,
926                fidl::encoding::DefaultFuchsiaResourceDialect,
927                0x7aefe3d765cfc6a7,
928            >(_buf?)?;
929            Ok(_response.map(|x| (x.minimum_opp, x.maximum_opp)))
930        }
931        self.client.send_query_and_decode::<
932            fidl::encoding::EmptyPayload,
933            DeviceGetCurrentOperatingPointLimitsResult,
934        >(
935            (),
936            0x7aefe3d765cfc6a7,
937            fidl::encoding::DynamicFlags::empty(),
938            _decode,
939        )
940    }
941
942    type GetOperatingPointCountResponseFut = fidl::client::QueryResponseFut<
943        DeviceGetOperatingPointCountResult,
944        fidl::encoding::DefaultFuchsiaResourceDialect,
945    >;
946    fn r#get_operating_point_count(&self) -> Self::GetOperatingPointCountResponseFut {
947        fn _decode(
948            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
949        ) -> Result<DeviceGetOperatingPointCountResult, fidl::Error> {
950            let _response = fidl::client::decode_transaction_body::<
951                fidl::encoding::ResultType<DeviceGetOperatingPointCountResponse, i32>,
952                fidl::encoding::DefaultFuchsiaResourceDialect,
953                0x13e70ec7131889ba,
954            >(_buf?)?;
955            Ok(_response.map(|x| x.count))
956        }
957        self.client.send_query_and_decode::<
958            fidl::encoding::EmptyPayload,
959            DeviceGetOperatingPointCountResult,
960        >(
961            (),
962            0x13e70ec7131889ba,
963            fidl::encoding::DynamicFlags::empty(),
964            _decode,
965        )
966    }
967
968    type GetNumLogicalCoresResponseFut =
969        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
970    fn r#get_num_logical_cores(&self) -> Self::GetNumLogicalCoresResponseFut {
971        fn _decode(
972            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
973        ) -> Result<u64, fidl::Error> {
974            let _response = fidl::client::decode_transaction_body::<
975                DeviceGetNumLogicalCoresResponse,
976                fidl::encoding::DefaultFuchsiaResourceDialect,
977                0x74e304c90ca165c5,
978            >(_buf?)?;
979            Ok(_response.count)
980        }
981        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
982            (),
983            0x74e304c90ca165c5,
984            fidl::encoding::DynamicFlags::empty(),
985            _decode,
986        )
987    }
988
989    type GetLogicalCoreIdResponseFut =
990        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
991    fn r#get_logical_core_id(&self, mut index: u64) -> Self::GetLogicalCoreIdResponseFut {
992        fn _decode(
993            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
994        ) -> Result<u64, fidl::Error> {
995            let _response = fidl::client::decode_transaction_body::<
996                DeviceGetLogicalCoreIdResponse,
997                fidl::encoding::DefaultFuchsiaResourceDialect,
998                0x7168f98ddbd26058,
999            >(_buf?)?;
1000            Ok(_response.id)
1001        }
1002        self.client.send_query_and_decode::<DeviceGetLogicalCoreIdRequest, u64>(
1003            (index,),
1004            0x7168f98ddbd26058,
1005            fidl::encoding::DynamicFlags::empty(),
1006            _decode,
1007        )
1008    }
1009
1010    type GetDomainIdResponseFut =
1011        fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1012    fn r#get_domain_id(&self) -> Self::GetDomainIdResponseFut {
1013        fn _decode(
1014            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1015        ) -> Result<u32, fidl::Error> {
1016            let _response = fidl::client::decode_transaction_body::<
1017                DeviceGetDomainIdResponse,
1018                fidl::encoding::DefaultFuchsiaResourceDialect,
1019                0x3030f85bdc1ef321,
1020            >(_buf?)?;
1021            Ok(_response.domain_id)
1022        }
1023        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
1024            (),
1025            0x3030f85bdc1ef321,
1026            fidl::encoding::DynamicFlags::empty(),
1027            _decode,
1028        )
1029    }
1030
1031    type GetRelativePerformanceResponseFut = fidl::client::QueryResponseFut<
1032        DeviceGetRelativePerformanceResult,
1033        fidl::encoding::DefaultFuchsiaResourceDialect,
1034    >;
1035    fn r#get_relative_performance(&self) -> Self::GetRelativePerformanceResponseFut {
1036        fn _decode(
1037            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1038        ) -> Result<DeviceGetRelativePerformanceResult, fidl::Error> {
1039            let _response = fidl::client::decode_transaction_body::<
1040                fidl::encoding::ResultType<DeviceGetRelativePerformanceResponse, i32>,
1041                fidl::encoding::DefaultFuchsiaResourceDialect,
1042                0x41c37eaf0c26a3d3,
1043            >(_buf?)?;
1044            Ok(_response.map(|x| x.relative_performance))
1045        }
1046        self.client.send_query_and_decode::<
1047            fidl::encoding::EmptyPayload,
1048            DeviceGetRelativePerformanceResult,
1049        >(
1050            (),
1051            0x41c37eaf0c26a3d3,
1052            fidl::encoding::DynamicFlags::empty(),
1053            _decode,
1054        )
1055    }
1056
1057    type GetRelativePerformance2ResponseFut = fidl::client::QueryResponseFut<
1058        DeviceGetRelativePerformance2Result,
1059        fidl::encoding::DefaultFuchsiaResourceDialect,
1060    >;
1061    fn r#get_relative_performance2(&self) -> Self::GetRelativePerformance2ResponseFut {
1062        fn _decode(
1063            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1064        ) -> Result<DeviceGetRelativePerformance2Result, fidl::Error> {
1065            let _response = fidl::client::decode_transaction_body::<
1066                fidl::encoding::FlexibleResultType<DeviceGetRelativePerformance2Response, i32>,
1067                fidl::encoding::DefaultFuchsiaResourceDialect,
1068                0x48831ad9a7fc2e38,
1069            >(_buf?)?
1070            .into_result::<DeviceMarker>("get_relative_performance2")?;
1071            Ok(_response.map(|x| x.relative_performance))
1072        }
1073        self.client.send_query_and_decode::<
1074            fidl::encoding::EmptyPayload,
1075            DeviceGetRelativePerformance2Result,
1076        >(
1077            (),
1078            0x48831ad9a7fc2e38,
1079            fidl::encoding::DynamicFlags::FLEXIBLE,
1080            _decode,
1081        )
1082    }
1083}
1084
1085pub struct DeviceEventStream {
1086    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1087}
1088
1089impl std::marker::Unpin for DeviceEventStream {}
1090
1091impl futures::stream::FusedStream for DeviceEventStream {
1092    fn is_terminated(&self) -> bool {
1093        self.event_receiver.is_terminated()
1094    }
1095}
1096
1097impl futures::Stream for DeviceEventStream {
1098    type Item = Result<DeviceEvent, fidl::Error>;
1099
1100    fn poll_next(
1101        mut self: std::pin::Pin<&mut Self>,
1102        cx: &mut std::task::Context<'_>,
1103    ) -> std::task::Poll<Option<Self::Item>> {
1104        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1105            &mut self.event_receiver,
1106            cx
1107        )?) {
1108            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1109            None => std::task::Poll::Ready(None),
1110        }
1111    }
1112}
1113
1114#[derive(Debug)]
1115pub enum DeviceEvent {
1116    #[non_exhaustive]
1117    _UnknownEvent {
1118        /// Ordinal of the event that was sent.
1119        ordinal: u64,
1120    },
1121}
1122
1123impl DeviceEvent {
1124    /// Decodes a message buffer as a [`DeviceEvent`].
1125    fn decode(
1126        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1127    ) -> Result<DeviceEvent, fidl::Error> {
1128        let (bytes, _handles) = buf.split_mut();
1129        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1130        debug_assert_eq!(tx_header.tx_id, 0);
1131        match tx_header.ordinal {
1132            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1133                Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1134            }
1135            _ => Err(fidl::Error::UnknownOrdinal {
1136                ordinal: tx_header.ordinal,
1137                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1138            }),
1139        }
1140    }
1141}
1142
1143/// A Stream of incoming requests for fuchsia.hardware.cpu.ctrl/Device.
1144pub struct DeviceRequestStream {
1145    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1146    is_terminated: bool,
1147}
1148
1149impl std::marker::Unpin for DeviceRequestStream {}
1150
1151impl futures::stream::FusedStream for DeviceRequestStream {
1152    fn is_terminated(&self) -> bool {
1153        self.is_terminated
1154    }
1155}
1156
1157impl fidl::endpoints::RequestStream for DeviceRequestStream {
1158    type Protocol = DeviceMarker;
1159    type ControlHandle = DeviceControlHandle;
1160
1161    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1162        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1163    }
1164
1165    fn control_handle(&self) -> Self::ControlHandle {
1166        DeviceControlHandle { inner: self.inner.clone() }
1167    }
1168
1169    fn into_inner(
1170        self,
1171    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1172    {
1173        (self.inner, self.is_terminated)
1174    }
1175
1176    fn from_inner(
1177        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1178        is_terminated: bool,
1179    ) -> Self {
1180        Self { inner, is_terminated }
1181    }
1182}
1183
1184impl futures::Stream for DeviceRequestStream {
1185    type Item = Result<DeviceRequest, fidl::Error>;
1186
1187    fn poll_next(
1188        mut self: std::pin::Pin<&mut Self>,
1189        cx: &mut std::task::Context<'_>,
1190    ) -> std::task::Poll<Option<Self::Item>> {
1191        let this = &mut *self;
1192        if this.inner.check_shutdown(cx) {
1193            this.is_terminated = true;
1194            return std::task::Poll::Ready(None);
1195        }
1196        if this.is_terminated {
1197            panic!("polled DeviceRequestStream after completion");
1198        }
1199        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1200            |bytes, handles| {
1201                match this.inner.channel().read_etc(cx, bytes, handles) {
1202                    std::task::Poll::Ready(Ok(())) => {}
1203                    std::task::Poll::Pending => return std::task::Poll::Pending,
1204                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1205                        this.is_terminated = true;
1206                        return std::task::Poll::Ready(None);
1207                    }
1208                    std::task::Poll::Ready(Err(e)) => {
1209                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1210                            e.into(),
1211                        ))));
1212                    }
1213                }
1214
1215                // A message has been received from the channel
1216                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1217
1218                std::task::Poll::Ready(Some(match header.ordinal {
1219                    0x6594a9234fc958e2 => {
1220                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1221                        let mut req = fidl::new_empty!(
1222                            DeviceGetOperatingPointInfoRequest,
1223                            fidl::encoding::DefaultFuchsiaResourceDialect
1224                        );
1225                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetOperatingPointInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1226                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1227                        Ok(DeviceRequest::GetOperatingPointInfo {
1228                            opp: req.opp,
1229
1230                            responder: DeviceGetOperatingPointInfoResponder {
1231                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1232                                tx_id: header.tx_id,
1233                            },
1234                        })
1235                    }
1236                    0x52de67a5993f5fe1 => {
1237                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1238                        let mut req = fidl::new_empty!(
1239                            fidl::encoding::EmptyPayload,
1240                            fidl::encoding::DefaultFuchsiaResourceDialect
1241                        );
1242                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1243                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1244                        Ok(DeviceRequest::GetCurrentOperatingPoint {
1245                            responder: DeviceGetCurrentOperatingPointResponder {
1246                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1247                                tx_id: header.tx_id,
1248                            },
1249                        })
1250                    }
1251                    0x34a7828b5ca53fd => {
1252                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1253                        let mut req = fidl::new_empty!(
1254                            DeviceSetCurrentOperatingPointRequest,
1255                            fidl::encoding::DefaultFuchsiaResourceDialect
1256                        );
1257                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetCurrentOperatingPointRequest>(&header, _body_bytes, handles, &mut req)?;
1258                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1259                        Ok(DeviceRequest::SetCurrentOperatingPoint {
1260                            requested_opp: req.requested_opp,
1261
1262                            responder: DeviceSetCurrentOperatingPointResponder {
1263                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1264                                tx_id: header.tx_id,
1265                            },
1266                        })
1267                    }
1268                    0x5467de86fa3fdfe7 => {
1269                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1270                        let mut req = fidl::new_empty!(
1271                            DeviceSetMinimumOperatingPointLimitRequest,
1272                            fidl::encoding::DefaultFuchsiaResourceDialect
1273                        );
1274                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetMinimumOperatingPointLimitRequest>(&header, _body_bytes, handles, &mut req)?;
1275                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1276                        Ok(DeviceRequest::SetMinimumOperatingPointLimit {
1277                            minimum_opp: req.minimum_opp,
1278
1279                            responder: DeviceSetMinimumOperatingPointLimitResponder {
1280                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1281                                tx_id: header.tx_id,
1282                            },
1283                        })
1284                    }
1285                    0x385fa4d74481fbfd => {
1286                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1287                        let mut req = fidl::new_empty!(
1288                            DeviceSetMaximumOperatingPointLimitRequest,
1289                            fidl::encoding::DefaultFuchsiaResourceDialect
1290                        );
1291                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetMaximumOperatingPointLimitRequest>(&header, _body_bytes, handles, &mut req)?;
1292                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1293                        Ok(DeviceRequest::SetMaximumOperatingPointLimit {
1294                            maximum_opp: req.maximum_opp,
1295
1296                            responder: DeviceSetMaximumOperatingPointLimitResponder {
1297                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1298                                tx_id: header.tx_id,
1299                            },
1300                        })
1301                    }
1302                    0x30aa7514dd598b23 => {
1303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1304                        let mut req = fidl::new_empty!(
1305                            DeviceSetOperatingPointLimitsRequest,
1306                            fidl::encoding::DefaultFuchsiaResourceDialect
1307                        );
1308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetOperatingPointLimitsRequest>(&header, _body_bytes, handles, &mut req)?;
1309                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1310                        Ok(DeviceRequest::SetOperatingPointLimits {
1311                            minimum_opp: req.minimum_opp,
1312                            maximum_opp: req.maximum_opp,
1313
1314                            responder: DeviceSetOperatingPointLimitsResponder {
1315                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1316                                tx_id: header.tx_id,
1317                            },
1318                        })
1319                    }
1320                    0x7aefe3d765cfc6a7 => {
1321                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1322                        let mut req = fidl::new_empty!(
1323                            fidl::encoding::EmptyPayload,
1324                            fidl::encoding::DefaultFuchsiaResourceDialect
1325                        );
1326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1327                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1328                        Ok(DeviceRequest::GetCurrentOperatingPointLimits {
1329                            responder: DeviceGetCurrentOperatingPointLimitsResponder {
1330                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1331                                tx_id: header.tx_id,
1332                            },
1333                        })
1334                    }
1335                    0x13e70ec7131889ba => {
1336                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1337                        let mut req = fidl::new_empty!(
1338                            fidl::encoding::EmptyPayload,
1339                            fidl::encoding::DefaultFuchsiaResourceDialect
1340                        );
1341                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1342                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1343                        Ok(DeviceRequest::GetOperatingPointCount {
1344                            responder: DeviceGetOperatingPointCountResponder {
1345                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1346                                tx_id: header.tx_id,
1347                            },
1348                        })
1349                    }
1350                    0x74e304c90ca165c5 => {
1351                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1352                        let mut req = fidl::new_empty!(
1353                            fidl::encoding::EmptyPayload,
1354                            fidl::encoding::DefaultFuchsiaResourceDialect
1355                        );
1356                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1357                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1358                        Ok(DeviceRequest::GetNumLogicalCores {
1359                            responder: DeviceGetNumLogicalCoresResponder {
1360                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1361                                tx_id: header.tx_id,
1362                            },
1363                        })
1364                    }
1365                    0x7168f98ddbd26058 => {
1366                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1367                        let mut req = fidl::new_empty!(
1368                            DeviceGetLogicalCoreIdRequest,
1369                            fidl::encoding::DefaultFuchsiaResourceDialect
1370                        );
1371                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetLogicalCoreIdRequest>(&header, _body_bytes, handles, &mut req)?;
1372                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1373                        Ok(DeviceRequest::GetLogicalCoreId {
1374                            index: req.index,
1375
1376                            responder: DeviceGetLogicalCoreIdResponder {
1377                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1378                                tx_id: header.tx_id,
1379                            },
1380                        })
1381                    }
1382                    0x3030f85bdc1ef321 => {
1383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1384                        let mut req = fidl::new_empty!(
1385                            fidl::encoding::EmptyPayload,
1386                            fidl::encoding::DefaultFuchsiaResourceDialect
1387                        );
1388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1389                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1390                        Ok(DeviceRequest::GetDomainId {
1391                            responder: DeviceGetDomainIdResponder {
1392                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1393                                tx_id: header.tx_id,
1394                            },
1395                        })
1396                    }
1397                    0x41c37eaf0c26a3d3 => {
1398                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1399                        let mut req = fidl::new_empty!(
1400                            fidl::encoding::EmptyPayload,
1401                            fidl::encoding::DefaultFuchsiaResourceDialect
1402                        );
1403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1404                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1405                        Ok(DeviceRequest::GetRelativePerformance {
1406                            responder: DeviceGetRelativePerformanceResponder {
1407                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1408                                tx_id: header.tx_id,
1409                            },
1410                        })
1411                    }
1412                    0x48831ad9a7fc2e38 => {
1413                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1414                        let mut req = fidl::new_empty!(
1415                            fidl::encoding::EmptyPayload,
1416                            fidl::encoding::DefaultFuchsiaResourceDialect
1417                        );
1418                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1419                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1420                        Ok(DeviceRequest::GetRelativePerformance2 {
1421                            responder: DeviceGetRelativePerformance2Responder {
1422                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1423                                tx_id: header.tx_id,
1424                            },
1425                        })
1426                    }
1427                    _ if header.tx_id == 0
1428                        && header
1429                            .dynamic_flags()
1430                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1431                    {
1432                        Ok(DeviceRequest::_UnknownMethod {
1433                            ordinal: header.ordinal,
1434                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1435                            method_type: fidl::MethodType::OneWay,
1436                        })
1437                    }
1438                    _ if header
1439                        .dynamic_flags()
1440                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1441                    {
1442                        this.inner.send_framework_err(
1443                            fidl::encoding::FrameworkErr::UnknownMethod,
1444                            header.tx_id,
1445                            header.ordinal,
1446                            header.dynamic_flags(),
1447                            (bytes, handles),
1448                        )?;
1449                        Ok(DeviceRequest::_UnknownMethod {
1450                            ordinal: header.ordinal,
1451                            control_handle: DeviceControlHandle { inner: this.inner.clone() },
1452                            method_type: fidl::MethodType::TwoWay,
1453                        })
1454                    }
1455                    _ => Err(fidl::Error::UnknownOrdinal {
1456                        ordinal: header.ordinal,
1457                        protocol_name:
1458                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1459                    }),
1460                }))
1461            },
1462        )
1463    }
1464}
1465
1466#[derive(Debug)]
1467pub enum DeviceRequest {
1468    /// Returns information about a given operating point for this performance
1469    /// domain.
1470    GetOperatingPointInfo { opp: u32, responder: DeviceGetOperatingPointInfoResponder },
1471    /// Gets the current operating point of the device.
1472    GetCurrentOperatingPoint { responder: DeviceGetCurrentOperatingPointResponder },
1473    /// Set the operating point of this device to the requested operating point.
1474    ///
1475    /// Operating points are in numeric P-state order, such that the maximum
1476    /// operating performance point is 0 and the minimum is n-1, where n is the
1477    /// number of operating points returned by GetOperatingPointCount().
1478    ///
1479    /// The requested operating point may be clamped to the range [min, max]
1480    /// when operating point limits are supported. See SetOperatingPointLimits
1481    /// for details.
1482    ///
1483    /// Returns ZX_OK, if the device is in a working state and the operating
1484    /// point is changed to requested_opp successfully. out_opp will be same as
1485    /// requested_opp.
1486    ///
1487    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
1488    /// [n-1, 0], where n is the number of operating points returned by
1489    /// GetOperatingPointCount().
1490    ///
1491    /// Returns error status, if switching to the requested_opp was
1492    /// unsuccessful. out_opp is the operating performance point (OPP) that the
1493    /// device is currently in.
1494    SetCurrentOperatingPoint {
1495        requested_opp: u32,
1496        responder: DeviceSetCurrentOperatingPointResponder,
1497    },
1498    /// Sets the minimum operating point to use, particularly when the kernel
1499    /// automatically controls the operating points of this device.
1500    ///
1501    /// See SetOperatingPointLimits for details on the semantics of operating
1502    /// point limits.
1503    ///
1504    /// Returns ZX_OK on success.
1505    ///
1506    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp is outside of the range
1507    /// [n-1, 0], where n is the number of operating points returned by
1508    /// GetOperatingPointCount().
1509    ///
1510    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
1511    SetMinimumOperatingPointLimit {
1512        minimum_opp: u32,
1513        responder: DeviceSetMinimumOperatingPointLimitResponder,
1514    },
1515    /// Sets the maximum operating point to use, particularly when the kernel
1516    /// automatically controls the operating points of this device.
1517    ///
1518    /// See SetOperatingPointLimits for details on the semantics of operating
1519    /// point limits.
1520    ///
1521    /// Returns ZX_OK on success.
1522    ///
1523    /// Returns ZX_ERR_OUT_OF_RANGE if the maximum_opp is outside of the range
1524    /// [n-1, 0], where n is the number of operating points returned by
1525    /// GetOperatingPointCount().
1526    ///
1527    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
1528    SetMaximumOperatingPointLimit {
1529        maximum_opp: u32,
1530        responder: DeviceSetMaximumOperatingPointLimitResponder,
1531    },
1532    /// Sets the operational boundaries (minimum and maximum operating points)
1533    /// for the device, when supported.
1534    ///
1535    /// Limits define the allowable performance range for the performance
1536    /// domain. They are primarily used for:
1537    /// * Thermal Mitigation: Progressively lowering the maximum operating point
1538    ///   (moving from 0 toward n-1) to reduce power dissipation.
1539    /// * Performance Boosting: Raising the minimum operating point (moving
1540    ///   from n-1 toward 0) when automatic performance matching is insufficient
1541    ///   for the current workload.
1542    ///
1543    /// Limits are useful on platforms where ether hardware or the kernel
1544    /// automatically manages performance. By setting boundaries, userspace can
1545    /// enforce power and performance policies while allowing the underlying
1546    /// system to react to high-fidelity signals in real-time.
1547    ///
1548    /// When limits are applied, the active operating point is clamped to the range:
1549    /// `[max(minimum_opp, maximim_opp), maximum_opp]`.
1550    ///
1551    /// Note that `maximim_opp` and `minimum_opp` reside in the P-state range [n-1, 0].
1552    /// This logic ensures that the `minimum_opp` can be adjusted independently while
1553    /// always respecting the ceiling imposed by the `maximim_opp`.
1554    ///
1555    /// Set the operating point limits to (n-1, 0) to effectively remove the limits.
1556    ///
1557    /// Returns ZX_OK on success.
1558    ///
1559    /// Returns ZX_ERR_OUT_OF_RANGE if the minimum_opp or maximum_opp is outside
1560    /// of the range [n-1, 0], where n is the number of operating points
1561    /// returned by GetOperatingPointCount().
1562    ///
1563    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
1564    SetOperatingPointLimits {
1565        minimum_opp: u32,
1566        maximum_opp: u32,
1567        responder: DeviceSetOperatingPointLimitsResponder,
1568    },
1569    /// Returns the current minimum and maximum operating point limits.
1570    ///
1571    /// Returns ZX_OK on success.
1572    ///
1573    /// Returns ZX_ERR_NOT_SUPPORTED if the device does not support limits.
1574    GetCurrentOperatingPointLimits { responder: DeviceGetCurrentOperatingPointLimitsResponder },
1575    /// Returns the number of operating points within this performance domain.
1576    GetOperatingPointCount { responder: DeviceGetOperatingPointCountResponder },
1577    /// Returns the number of logical cores contained within this performance
1578    /// domain.
1579    GetNumLogicalCores { responder: DeviceGetNumLogicalCoresResponder },
1580    /// Returns a global system-wide core ID for the nth core in this
1581    /// performance domain. `index` must be a value in the range [0, n) where
1582    /// n is the value returned by GetNumLogicalCores().
1583    GetLogicalCoreId { index: u64, responder: DeviceGetLogicalCoreIdResponder },
1584    /// Returns the id of this performance domain within its package. This
1585    /// number should be stable across boots, but clients should prefer to use
1586    /// GetRelativePerformance to differentiate cores if possible.
1587    GetDomainId { responder: DeviceGetDomainIdResponder },
1588    /// The relative performance of this domain as configured by the platform,
1589    /// if known. The highest performance domain should return 255, while others
1590    /// should return N/255 fractional values relative to that domain.
1591    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
1592    GetRelativePerformance { responder: DeviceGetRelativePerformanceResponder },
1593    /// The relative performance of this domain as configured by the platform,
1594    /// if known.
1595    ///
1596    /// The relative performance is a unitless value. To calculate normalized
1597    /// performance rates from the relative rates, a user would need to query
1598    /// each performance domain to determine the maximum performance value
1599    /// before calculating normalized values.
1600    ///
1601    /// Returns ZX_ERR_NOT_SUPPORTED if the performance level is unknown.
1602    GetRelativePerformance2 { responder: DeviceGetRelativePerformance2Responder },
1603    /// An interaction was received which does not match any known method.
1604    #[non_exhaustive]
1605    _UnknownMethod {
1606        /// Ordinal of the method that was called.
1607        ordinal: u64,
1608        control_handle: DeviceControlHandle,
1609        method_type: fidl::MethodType,
1610    },
1611}
1612
1613impl DeviceRequest {
1614    #[allow(irrefutable_let_patterns)]
1615    pub fn into_get_operating_point_info(
1616        self,
1617    ) -> Option<(u32, DeviceGetOperatingPointInfoResponder)> {
1618        if let DeviceRequest::GetOperatingPointInfo { opp, responder } = self {
1619            Some((opp, responder))
1620        } else {
1621            None
1622        }
1623    }
1624
1625    #[allow(irrefutable_let_patterns)]
1626    pub fn into_get_current_operating_point(
1627        self,
1628    ) -> Option<(DeviceGetCurrentOperatingPointResponder)> {
1629        if let DeviceRequest::GetCurrentOperatingPoint { responder } = self {
1630            Some((responder))
1631        } else {
1632            None
1633        }
1634    }
1635
1636    #[allow(irrefutable_let_patterns)]
1637    pub fn into_set_current_operating_point(
1638        self,
1639    ) -> Option<(u32, DeviceSetCurrentOperatingPointResponder)> {
1640        if let DeviceRequest::SetCurrentOperatingPoint { requested_opp, responder } = self {
1641            Some((requested_opp, responder))
1642        } else {
1643            None
1644        }
1645    }
1646
1647    #[allow(irrefutable_let_patterns)]
1648    pub fn into_set_minimum_operating_point_limit(
1649        self,
1650    ) -> Option<(u32, DeviceSetMinimumOperatingPointLimitResponder)> {
1651        if let DeviceRequest::SetMinimumOperatingPointLimit { minimum_opp, responder } = self {
1652            Some((minimum_opp, responder))
1653        } else {
1654            None
1655        }
1656    }
1657
1658    #[allow(irrefutable_let_patterns)]
1659    pub fn into_set_maximum_operating_point_limit(
1660        self,
1661    ) -> Option<(u32, DeviceSetMaximumOperatingPointLimitResponder)> {
1662        if let DeviceRequest::SetMaximumOperatingPointLimit { maximum_opp, responder } = self {
1663            Some((maximum_opp, responder))
1664        } else {
1665            None
1666        }
1667    }
1668
1669    #[allow(irrefutable_let_patterns)]
1670    pub fn into_set_operating_point_limits(
1671        self,
1672    ) -> Option<(u32, u32, DeviceSetOperatingPointLimitsResponder)> {
1673        if let DeviceRequest::SetOperatingPointLimits { minimum_opp, maximum_opp, responder } = self
1674        {
1675            Some((minimum_opp, maximum_opp, responder))
1676        } else {
1677            None
1678        }
1679    }
1680
1681    #[allow(irrefutable_let_patterns)]
1682    pub fn into_get_current_operating_point_limits(
1683        self,
1684    ) -> Option<(DeviceGetCurrentOperatingPointLimitsResponder)> {
1685        if let DeviceRequest::GetCurrentOperatingPointLimits { responder } = self {
1686            Some((responder))
1687        } else {
1688            None
1689        }
1690    }
1691
1692    #[allow(irrefutable_let_patterns)]
1693    pub fn into_get_operating_point_count(self) -> Option<(DeviceGetOperatingPointCountResponder)> {
1694        if let DeviceRequest::GetOperatingPointCount { responder } = self {
1695            Some((responder))
1696        } else {
1697            None
1698        }
1699    }
1700
1701    #[allow(irrefutable_let_patterns)]
1702    pub fn into_get_num_logical_cores(self) -> Option<(DeviceGetNumLogicalCoresResponder)> {
1703        if let DeviceRequest::GetNumLogicalCores { responder } = self {
1704            Some((responder))
1705        } else {
1706            None
1707        }
1708    }
1709
1710    #[allow(irrefutable_let_patterns)]
1711    pub fn into_get_logical_core_id(self) -> Option<(u64, DeviceGetLogicalCoreIdResponder)> {
1712        if let DeviceRequest::GetLogicalCoreId { index, responder } = self {
1713            Some((index, responder))
1714        } else {
1715            None
1716        }
1717    }
1718
1719    #[allow(irrefutable_let_patterns)]
1720    pub fn into_get_domain_id(self) -> Option<(DeviceGetDomainIdResponder)> {
1721        if let DeviceRequest::GetDomainId { responder } = self { Some((responder)) } else { None }
1722    }
1723
1724    #[allow(irrefutable_let_patterns)]
1725    pub fn into_get_relative_performance(self) -> Option<(DeviceGetRelativePerformanceResponder)> {
1726        if let DeviceRequest::GetRelativePerformance { responder } = self {
1727            Some((responder))
1728        } else {
1729            None
1730        }
1731    }
1732
1733    #[allow(irrefutable_let_patterns)]
1734    pub fn into_get_relative_performance2(
1735        self,
1736    ) -> Option<(DeviceGetRelativePerformance2Responder)> {
1737        if let DeviceRequest::GetRelativePerformance2 { responder } = self {
1738            Some((responder))
1739        } else {
1740            None
1741        }
1742    }
1743
1744    /// Name of the method defined in FIDL
1745    pub fn method_name(&self) -> &'static str {
1746        match *self {
1747            DeviceRequest::GetOperatingPointInfo { .. } => "get_operating_point_info",
1748            DeviceRequest::GetCurrentOperatingPoint { .. } => "get_current_operating_point",
1749            DeviceRequest::SetCurrentOperatingPoint { .. } => "set_current_operating_point",
1750            DeviceRequest::SetMinimumOperatingPointLimit { .. } => {
1751                "set_minimum_operating_point_limit"
1752            }
1753            DeviceRequest::SetMaximumOperatingPointLimit { .. } => {
1754                "set_maximum_operating_point_limit"
1755            }
1756            DeviceRequest::SetOperatingPointLimits { .. } => "set_operating_point_limits",
1757            DeviceRequest::GetCurrentOperatingPointLimits { .. } => {
1758                "get_current_operating_point_limits"
1759            }
1760            DeviceRequest::GetOperatingPointCount { .. } => "get_operating_point_count",
1761            DeviceRequest::GetNumLogicalCores { .. } => "get_num_logical_cores",
1762            DeviceRequest::GetLogicalCoreId { .. } => "get_logical_core_id",
1763            DeviceRequest::GetDomainId { .. } => "get_domain_id",
1764            DeviceRequest::GetRelativePerformance { .. } => "get_relative_performance",
1765            DeviceRequest::GetRelativePerformance2 { .. } => "get_relative_performance2",
1766            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1767                "unknown one-way method"
1768            }
1769            DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1770                "unknown two-way method"
1771            }
1772        }
1773    }
1774}
1775
1776#[derive(Debug, Clone)]
1777pub struct DeviceControlHandle {
1778    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1779}
1780
1781impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1782    fn shutdown(&self) {
1783        self.inner.shutdown()
1784    }
1785
1786    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1787        self.inner.shutdown_with_epitaph(status)
1788    }
1789
1790    fn is_closed(&self) -> bool {
1791        self.inner.channel().is_closed()
1792    }
1793    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1794        self.inner.channel().on_closed()
1795    }
1796
1797    #[cfg(target_os = "fuchsia")]
1798    fn signal_peer(
1799        &self,
1800        clear_mask: zx::Signals,
1801        set_mask: zx::Signals,
1802    ) -> Result<(), zx_status::Status> {
1803        use fidl::Peered;
1804        self.inner.channel().signal_peer(clear_mask, set_mask)
1805    }
1806}
1807
1808impl DeviceControlHandle {}
1809
1810#[must_use = "FIDL methods require a response to be sent"]
1811#[derive(Debug)]
1812pub struct DeviceGetOperatingPointInfoResponder {
1813    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1814    tx_id: u32,
1815}
1816
1817/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1818/// if the responder is dropped without sending a response, so that the client
1819/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1820impl std::ops::Drop for DeviceGetOperatingPointInfoResponder {
1821    fn drop(&mut self) {
1822        self.control_handle.shutdown();
1823        // Safety: drops once, never accessed again
1824        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1825    }
1826}
1827
1828impl fidl::endpoints::Responder for DeviceGetOperatingPointInfoResponder {
1829    type ControlHandle = DeviceControlHandle;
1830
1831    fn control_handle(&self) -> &DeviceControlHandle {
1832        &self.control_handle
1833    }
1834
1835    fn drop_without_shutdown(mut self) {
1836        // Safety: drops once, never accessed again due to mem::forget
1837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1838        // Prevent Drop from running (which would shut down the channel)
1839        std::mem::forget(self);
1840    }
1841}
1842
1843impl DeviceGetOperatingPointInfoResponder {
1844    /// Sends a response to the FIDL transaction.
1845    ///
1846    /// Sets the channel to shutdown if an error occurs.
1847    pub fn send(self, mut result: Result<&CpuOperatingPointInfo, i32>) -> Result<(), fidl::Error> {
1848        let _result = self.send_raw(result);
1849        if _result.is_err() {
1850            self.control_handle.shutdown();
1851        }
1852        self.drop_without_shutdown();
1853        _result
1854    }
1855
1856    /// Similar to "send" but does not shutdown the channel if an error occurs.
1857    pub fn send_no_shutdown_on_err(
1858        self,
1859        mut result: Result<&CpuOperatingPointInfo, i32>,
1860    ) -> Result<(), fidl::Error> {
1861        let _result = self.send_raw(result);
1862        self.drop_without_shutdown();
1863        _result
1864    }
1865
1866    fn send_raw(&self, mut result: Result<&CpuOperatingPointInfo, i32>) -> Result<(), fidl::Error> {
1867        self.control_handle.inner.send::<fidl::encoding::ResultType<
1868            DeviceGetOperatingPointInfoResponse,
1869            i32,
1870        >>(
1871            result.map(|info| (info,)),
1872            self.tx_id,
1873            0x6594a9234fc958e2,
1874            fidl::encoding::DynamicFlags::empty(),
1875        )
1876    }
1877}
1878
1879#[must_use = "FIDL methods require a response to be sent"]
1880#[derive(Debug)]
1881pub struct DeviceGetCurrentOperatingPointResponder {
1882    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1883    tx_id: u32,
1884}
1885
1886/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1887/// if the responder is dropped without sending a response, so that the client
1888/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1889impl std::ops::Drop for DeviceGetCurrentOperatingPointResponder {
1890    fn drop(&mut self) {
1891        self.control_handle.shutdown();
1892        // Safety: drops once, never accessed again
1893        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1894    }
1895}
1896
1897impl fidl::endpoints::Responder for DeviceGetCurrentOperatingPointResponder {
1898    type ControlHandle = DeviceControlHandle;
1899
1900    fn control_handle(&self) -> &DeviceControlHandle {
1901        &self.control_handle
1902    }
1903
1904    fn drop_without_shutdown(mut self) {
1905        // Safety: drops once, never accessed again due to mem::forget
1906        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1907        // Prevent Drop from running (which would shut down the channel)
1908        std::mem::forget(self);
1909    }
1910}
1911
1912impl DeviceGetCurrentOperatingPointResponder {
1913    /// Sends a response to the FIDL transaction.
1914    ///
1915    /// Sets the channel to shutdown if an error occurs.
1916    pub fn send(self, mut out_opp: u32) -> Result<(), fidl::Error> {
1917        let _result = self.send_raw(out_opp);
1918        if _result.is_err() {
1919            self.control_handle.shutdown();
1920        }
1921        self.drop_without_shutdown();
1922        _result
1923    }
1924
1925    /// Similar to "send" but does not shutdown the channel if an error occurs.
1926    pub fn send_no_shutdown_on_err(self, mut out_opp: u32) -> Result<(), fidl::Error> {
1927        let _result = self.send_raw(out_opp);
1928        self.drop_without_shutdown();
1929        _result
1930    }
1931
1932    fn send_raw(&self, mut out_opp: u32) -> Result<(), fidl::Error> {
1933        self.control_handle.inner.send::<DeviceGetCurrentOperatingPointResponse>(
1934            (out_opp,),
1935            self.tx_id,
1936            0x52de67a5993f5fe1,
1937            fidl::encoding::DynamicFlags::empty(),
1938        )
1939    }
1940}
1941
1942#[must_use = "FIDL methods require a response to be sent"]
1943#[derive(Debug)]
1944pub struct DeviceSetCurrentOperatingPointResponder {
1945    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1946    tx_id: u32,
1947}
1948
1949/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1950/// if the responder is dropped without sending a response, so that the client
1951/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1952impl std::ops::Drop for DeviceSetCurrentOperatingPointResponder {
1953    fn drop(&mut self) {
1954        self.control_handle.shutdown();
1955        // Safety: drops once, never accessed again
1956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1957    }
1958}
1959
1960impl fidl::endpoints::Responder for DeviceSetCurrentOperatingPointResponder {
1961    type ControlHandle = DeviceControlHandle;
1962
1963    fn control_handle(&self) -> &DeviceControlHandle {
1964        &self.control_handle
1965    }
1966
1967    fn drop_without_shutdown(mut self) {
1968        // Safety: drops once, never accessed again due to mem::forget
1969        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1970        // Prevent Drop from running (which would shut down the channel)
1971        std::mem::forget(self);
1972    }
1973}
1974
1975impl DeviceSetCurrentOperatingPointResponder {
1976    /// Sends a response to the FIDL transaction.
1977    ///
1978    /// Sets the channel to shutdown if an error occurs.
1979    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1980        let _result = self.send_raw(result);
1981        if _result.is_err() {
1982            self.control_handle.shutdown();
1983        }
1984        self.drop_without_shutdown();
1985        _result
1986    }
1987
1988    /// Similar to "send" but does not shutdown the channel if an error occurs.
1989    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1990        let _result = self.send_raw(result);
1991        self.drop_without_shutdown();
1992        _result
1993    }
1994
1995    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
1996        self.control_handle.inner.send::<fidl::encoding::ResultType<
1997            DeviceSetCurrentOperatingPointResponse,
1998            i32,
1999        >>(
2000            result.map(|out_opp| (out_opp,)),
2001            self.tx_id,
2002            0x34a7828b5ca53fd,
2003            fidl::encoding::DynamicFlags::empty(),
2004        )
2005    }
2006}
2007
2008#[must_use = "FIDL methods require a response to be sent"]
2009#[derive(Debug)]
2010pub struct DeviceSetMinimumOperatingPointLimitResponder {
2011    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2012    tx_id: u32,
2013}
2014
2015/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2016/// if the responder is dropped without sending a response, so that the client
2017/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2018impl std::ops::Drop for DeviceSetMinimumOperatingPointLimitResponder {
2019    fn drop(&mut self) {
2020        self.control_handle.shutdown();
2021        // Safety: drops once, never accessed again
2022        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2023    }
2024}
2025
2026impl fidl::endpoints::Responder for DeviceSetMinimumOperatingPointLimitResponder {
2027    type ControlHandle = DeviceControlHandle;
2028
2029    fn control_handle(&self) -> &DeviceControlHandle {
2030        &self.control_handle
2031    }
2032
2033    fn drop_without_shutdown(mut self) {
2034        // Safety: drops once, never accessed again due to mem::forget
2035        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2036        // Prevent Drop from running (which would shut down the channel)
2037        std::mem::forget(self);
2038    }
2039}
2040
2041impl DeviceSetMinimumOperatingPointLimitResponder {
2042    /// Sends a response to the FIDL transaction.
2043    ///
2044    /// Sets the channel to shutdown if an error occurs.
2045    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2046        let _result = self.send_raw(result);
2047        if _result.is_err() {
2048            self.control_handle.shutdown();
2049        }
2050        self.drop_without_shutdown();
2051        _result
2052    }
2053
2054    /// Similar to "send" but does not shutdown the channel if an error occurs.
2055    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2056        let _result = self.send_raw(result);
2057        self.drop_without_shutdown();
2058        _result
2059    }
2060
2061    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2062        self.control_handle
2063            .inner
2064            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2065                result,
2066                self.tx_id,
2067                0x5467de86fa3fdfe7,
2068                fidl::encoding::DynamicFlags::empty(),
2069            )
2070    }
2071}
2072
2073#[must_use = "FIDL methods require a response to be sent"]
2074#[derive(Debug)]
2075pub struct DeviceSetMaximumOperatingPointLimitResponder {
2076    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2077    tx_id: u32,
2078}
2079
2080/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2081/// if the responder is dropped without sending a response, so that the client
2082/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2083impl std::ops::Drop for DeviceSetMaximumOperatingPointLimitResponder {
2084    fn drop(&mut self) {
2085        self.control_handle.shutdown();
2086        // Safety: drops once, never accessed again
2087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2088    }
2089}
2090
2091impl fidl::endpoints::Responder for DeviceSetMaximumOperatingPointLimitResponder {
2092    type ControlHandle = DeviceControlHandle;
2093
2094    fn control_handle(&self) -> &DeviceControlHandle {
2095        &self.control_handle
2096    }
2097
2098    fn drop_without_shutdown(mut self) {
2099        // Safety: drops once, never accessed again due to mem::forget
2100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2101        // Prevent Drop from running (which would shut down the channel)
2102        std::mem::forget(self);
2103    }
2104}
2105
2106impl DeviceSetMaximumOperatingPointLimitResponder {
2107    /// Sends a response to the FIDL transaction.
2108    ///
2109    /// Sets the channel to shutdown if an error occurs.
2110    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2111        let _result = self.send_raw(result);
2112        if _result.is_err() {
2113            self.control_handle.shutdown();
2114        }
2115        self.drop_without_shutdown();
2116        _result
2117    }
2118
2119    /// Similar to "send" but does not shutdown the channel if an error occurs.
2120    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2121        let _result = self.send_raw(result);
2122        self.drop_without_shutdown();
2123        _result
2124    }
2125
2126    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2127        self.control_handle
2128            .inner
2129            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2130                result,
2131                self.tx_id,
2132                0x385fa4d74481fbfd,
2133                fidl::encoding::DynamicFlags::empty(),
2134            )
2135    }
2136}
2137
2138#[must_use = "FIDL methods require a response to be sent"]
2139#[derive(Debug)]
2140pub struct DeviceSetOperatingPointLimitsResponder {
2141    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2142    tx_id: u32,
2143}
2144
2145/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2146/// if the responder is dropped without sending a response, so that the client
2147/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2148impl std::ops::Drop for DeviceSetOperatingPointLimitsResponder {
2149    fn drop(&mut self) {
2150        self.control_handle.shutdown();
2151        // Safety: drops once, never accessed again
2152        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2153    }
2154}
2155
2156impl fidl::endpoints::Responder for DeviceSetOperatingPointLimitsResponder {
2157    type ControlHandle = DeviceControlHandle;
2158
2159    fn control_handle(&self) -> &DeviceControlHandle {
2160        &self.control_handle
2161    }
2162
2163    fn drop_without_shutdown(mut self) {
2164        // Safety: drops once, never accessed again due to mem::forget
2165        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2166        // Prevent Drop from running (which would shut down the channel)
2167        std::mem::forget(self);
2168    }
2169}
2170
2171impl DeviceSetOperatingPointLimitsResponder {
2172    /// Sends a response to the FIDL transaction.
2173    ///
2174    /// Sets the channel to shutdown if an error occurs.
2175    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2176        let _result = self.send_raw(result);
2177        if _result.is_err() {
2178            self.control_handle.shutdown();
2179        }
2180        self.drop_without_shutdown();
2181        _result
2182    }
2183
2184    /// Similar to "send" but does not shutdown the channel if an error occurs.
2185    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2186        let _result = self.send_raw(result);
2187        self.drop_without_shutdown();
2188        _result
2189    }
2190
2191    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2192        self.control_handle
2193            .inner
2194            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2195                result,
2196                self.tx_id,
2197                0x30aa7514dd598b23,
2198                fidl::encoding::DynamicFlags::empty(),
2199            )
2200    }
2201}
2202
2203#[must_use = "FIDL methods require a response to be sent"]
2204#[derive(Debug)]
2205pub struct DeviceGetCurrentOperatingPointLimitsResponder {
2206    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2207    tx_id: u32,
2208}
2209
2210/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2211/// if the responder is dropped without sending a response, so that the client
2212/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2213impl std::ops::Drop for DeviceGetCurrentOperatingPointLimitsResponder {
2214    fn drop(&mut self) {
2215        self.control_handle.shutdown();
2216        // Safety: drops once, never accessed again
2217        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2218    }
2219}
2220
2221impl fidl::endpoints::Responder for DeviceGetCurrentOperatingPointLimitsResponder {
2222    type ControlHandle = DeviceControlHandle;
2223
2224    fn control_handle(&self) -> &DeviceControlHandle {
2225        &self.control_handle
2226    }
2227
2228    fn drop_without_shutdown(mut self) {
2229        // Safety: drops once, never accessed again due to mem::forget
2230        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2231        // Prevent Drop from running (which would shut down the channel)
2232        std::mem::forget(self);
2233    }
2234}
2235
2236impl DeviceGetCurrentOperatingPointLimitsResponder {
2237    /// Sends a response to the FIDL transaction.
2238    ///
2239    /// Sets the channel to shutdown if an error occurs.
2240    pub fn send(self, mut result: Result<(u32, u32), i32>) -> Result<(), fidl::Error> {
2241        let _result = self.send_raw(result);
2242        if _result.is_err() {
2243            self.control_handle.shutdown();
2244        }
2245        self.drop_without_shutdown();
2246        _result
2247    }
2248
2249    /// Similar to "send" but does not shutdown the channel if an error occurs.
2250    pub fn send_no_shutdown_on_err(
2251        self,
2252        mut result: Result<(u32, u32), i32>,
2253    ) -> Result<(), fidl::Error> {
2254        let _result = self.send_raw(result);
2255        self.drop_without_shutdown();
2256        _result
2257    }
2258
2259    fn send_raw(&self, mut result: Result<(u32, u32), i32>) -> Result<(), fidl::Error> {
2260        self.control_handle.inner.send::<fidl::encoding::ResultType<
2261            DeviceGetCurrentOperatingPointLimitsResponse,
2262            i32,
2263        >>(
2264            result,
2265            self.tx_id,
2266            0x7aefe3d765cfc6a7,
2267            fidl::encoding::DynamicFlags::empty(),
2268        )
2269    }
2270}
2271
2272#[must_use = "FIDL methods require a response to be sent"]
2273#[derive(Debug)]
2274pub struct DeviceGetOperatingPointCountResponder {
2275    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2276    tx_id: u32,
2277}
2278
2279/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2280/// if the responder is dropped without sending a response, so that the client
2281/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2282impl std::ops::Drop for DeviceGetOperatingPointCountResponder {
2283    fn drop(&mut self) {
2284        self.control_handle.shutdown();
2285        // Safety: drops once, never accessed again
2286        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2287    }
2288}
2289
2290impl fidl::endpoints::Responder for DeviceGetOperatingPointCountResponder {
2291    type ControlHandle = DeviceControlHandle;
2292
2293    fn control_handle(&self) -> &DeviceControlHandle {
2294        &self.control_handle
2295    }
2296
2297    fn drop_without_shutdown(mut self) {
2298        // Safety: drops once, never accessed again due to mem::forget
2299        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2300        // Prevent Drop from running (which would shut down the channel)
2301        std::mem::forget(self);
2302    }
2303}
2304
2305impl DeviceGetOperatingPointCountResponder {
2306    /// Sends a response to the FIDL transaction.
2307    ///
2308    /// Sets the channel to shutdown if an error occurs.
2309    pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
2310        let _result = self.send_raw(result);
2311        if _result.is_err() {
2312            self.control_handle.shutdown();
2313        }
2314        self.drop_without_shutdown();
2315        _result
2316    }
2317
2318    /// Similar to "send" but does not shutdown the channel if an error occurs.
2319    pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
2320        let _result = self.send_raw(result);
2321        self.drop_without_shutdown();
2322        _result
2323    }
2324
2325    fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
2326        self.control_handle.inner.send::<fidl::encoding::ResultType<
2327            DeviceGetOperatingPointCountResponse,
2328            i32,
2329        >>(
2330            result.map(|count| (count,)),
2331            self.tx_id,
2332            0x13e70ec7131889ba,
2333            fidl::encoding::DynamicFlags::empty(),
2334        )
2335    }
2336}
2337
2338#[must_use = "FIDL methods require a response to be sent"]
2339#[derive(Debug)]
2340pub struct DeviceGetNumLogicalCoresResponder {
2341    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2342    tx_id: u32,
2343}
2344
2345/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2346/// if the responder is dropped without sending a response, so that the client
2347/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2348impl std::ops::Drop for DeviceGetNumLogicalCoresResponder {
2349    fn drop(&mut self) {
2350        self.control_handle.shutdown();
2351        // Safety: drops once, never accessed again
2352        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2353    }
2354}
2355
2356impl fidl::endpoints::Responder for DeviceGetNumLogicalCoresResponder {
2357    type ControlHandle = DeviceControlHandle;
2358
2359    fn control_handle(&self) -> &DeviceControlHandle {
2360        &self.control_handle
2361    }
2362
2363    fn drop_without_shutdown(mut self) {
2364        // Safety: drops once, never accessed again due to mem::forget
2365        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2366        // Prevent Drop from running (which would shut down the channel)
2367        std::mem::forget(self);
2368    }
2369}
2370
2371impl DeviceGetNumLogicalCoresResponder {
2372    /// Sends a response to the FIDL transaction.
2373    ///
2374    /// Sets the channel to shutdown if an error occurs.
2375    pub fn send(self, mut count: u64) -> Result<(), fidl::Error> {
2376        let _result = self.send_raw(count);
2377        if _result.is_err() {
2378            self.control_handle.shutdown();
2379        }
2380        self.drop_without_shutdown();
2381        _result
2382    }
2383
2384    /// Similar to "send" but does not shutdown the channel if an error occurs.
2385    pub fn send_no_shutdown_on_err(self, mut count: u64) -> Result<(), fidl::Error> {
2386        let _result = self.send_raw(count);
2387        self.drop_without_shutdown();
2388        _result
2389    }
2390
2391    fn send_raw(&self, mut count: u64) -> Result<(), fidl::Error> {
2392        self.control_handle.inner.send::<DeviceGetNumLogicalCoresResponse>(
2393            (count,),
2394            self.tx_id,
2395            0x74e304c90ca165c5,
2396            fidl::encoding::DynamicFlags::empty(),
2397        )
2398    }
2399}
2400
2401#[must_use = "FIDL methods require a response to be sent"]
2402#[derive(Debug)]
2403pub struct DeviceGetLogicalCoreIdResponder {
2404    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2405    tx_id: u32,
2406}
2407
2408/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2409/// if the responder is dropped without sending a response, so that the client
2410/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2411impl std::ops::Drop for DeviceGetLogicalCoreIdResponder {
2412    fn drop(&mut self) {
2413        self.control_handle.shutdown();
2414        // Safety: drops once, never accessed again
2415        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2416    }
2417}
2418
2419impl fidl::endpoints::Responder for DeviceGetLogicalCoreIdResponder {
2420    type ControlHandle = DeviceControlHandle;
2421
2422    fn control_handle(&self) -> &DeviceControlHandle {
2423        &self.control_handle
2424    }
2425
2426    fn drop_without_shutdown(mut self) {
2427        // Safety: drops once, never accessed again due to mem::forget
2428        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2429        // Prevent Drop from running (which would shut down the channel)
2430        std::mem::forget(self);
2431    }
2432}
2433
2434impl DeviceGetLogicalCoreIdResponder {
2435    /// Sends a response to the FIDL transaction.
2436    ///
2437    /// Sets the channel to shutdown if an error occurs.
2438    pub fn send(self, mut id: u64) -> Result<(), fidl::Error> {
2439        let _result = self.send_raw(id);
2440        if _result.is_err() {
2441            self.control_handle.shutdown();
2442        }
2443        self.drop_without_shutdown();
2444        _result
2445    }
2446
2447    /// Similar to "send" but does not shutdown the channel if an error occurs.
2448    pub fn send_no_shutdown_on_err(self, mut id: u64) -> Result<(), fidl::Error> {
2449        let _result = self.send_raw(id);
2450        self.drop_without_shutdown();
2451        _result
2452    }
2453
2454    fn send_raw(&self, mut id: u64) -> Result<(), fidl::Error> {
2455        self.control_handle.inner.send::<DeviceGetLogicalCoreIdResponse>(
2456            (id,),
2457            self.tx_id,
2458            0x7168f98ddbd26058,
2459            fidl::encoding::DynamicFlags::empty(),
2460        )
2461    }
2462}
2463
2464#[must_use = "FIDL methods require a response to be sent"]
2465#[derive(Debug)]
2466pub struct DeviceGetDomainIdResponder {
2467    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2468    tx_id: u32,
2469}
2470
2471/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2472/// if the responder is dropped without sending a response, so that the client
2473/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2474impl std::ops::Drop for DeviceGetDomainIdResponder {
2475    fn drop(&mut self) {
2476        self.control_handle.shutdown();
2477        // Safety: drops once, never accessed again
2478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2479    }
2480}
2481
2482impl fidl::endpoints::Responder for DeviceGetDomainIdResponder {
2483    type ControlHandle = DeviceControlHandle;
2484
2485    fn control_handle(&self) -> &DeviceControlHandle {
2486        &self.control_handle
2487    }
2488
2489    fn drop_without_shutdown(mut self) {
2490        // Safety: drops once, never accessed again due to mem::forget
2491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2492        // Prevent Drop from running (which would shut down the channel)
2493        std::mem::forget(self);
2494    }
2495}
2496
2497impl DeviceGetDomainIdResponder {
2498    /// Sends a response to the FIDL transaction.
2499    ///
2500    /// Sets the channel to shutdown if an error occurs.
2501    pub fn send(self, mut domain_id: u32) -> Result<(), fidl::Error> {
2502        let _result = self.send_raw(domain_id);
2503        if _result.is_err() {
2504            self.control_handle.shutdown();
2505        }
2506        self.drop_without_shutdown();
2507        _result
2508    }
2509
2510    /// Similar to "send" but does not shutdown the channel if an error occurs.
2511    pub fn send_no_shutdown_on_err(self, mut domain_id: u32) -> Result<(), fidl::Error> {
2512        let _result = self.send_raw(domain_id);
2513        self.drop_without_shutdown();
2514        _result
2515    }
2516
2517    fn send_raw(&self, mut domain_id: u32) -> Result<(), fidl::Error> {
2518        self.control_handle.inner.send::<DeviceGetDomainIdResponse>(
2519            (domain_id,),
2520            self.tx_id,
2521            0x3030f85bdc1ef321,
2522            fidl::encoding::DynamicFlags::empty(),
2523        )
2524    }
2525}
2526
2527#[must_use = "FIDL methods require a response to be sent"]
2528#[derive(Debug)]
2529pub struct DeviceGetRelativePerformanceResponder {
2530    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2531    tx_id: u32,
2532}
2533
2534/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2535/// if the responder is dropped without sending a response, so that the client
2536/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2537impl std::ops::Drop for DeviceGetRelativePerformanceResponder {
2538    fn drop(&mut self) {
2539        self.control_handle.shutdown();
2540        // Safety: drops once, never accessed again
2541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2542    }
2543}
2544
2545impl fidl::endpoints::Responder for DeviceGetRelativePerformanceResponder {
2546    type ControlHandle = DeviceControlHandle;
2547
2548    fn control_handle(&self) -> &DeviceControlHandle {
2549        &self.control_handle
2550    }
2551
2552    fn drop_without_shutdown(mut self) {
2553        // Safety: drops once, never accessed again due to mem::forget
2554        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2555        // Prevent Drop from running (which would shut down the channel)
2556        std::mem::forget(self);
2557    }
2558}
2559
2560impl DeviceGetRelativePerformanceResponder {
2561    /// Sends a response to the FIDL transaction.
2562    ///
2563    /// Sets the channel to shutdown if an error occurs.
2564    pub fn send(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
2565        let _result = self.send_raw(result);
2566        if _result.is_err() {
2567            self.control_handle.shutdown();
2568        }
2569        self.drop_without_shutdown();
2570        _result
2571    }
2572
2573    /// Similar to "send" but does not shutdown the channel if an error occurs.
2574    pub fn send_no_shutdown_on_err(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
2575        let _result = self.send_raw(result);
2576        self.drop_without_shutdown();
2577        _result
2578    }
2579
2580    fn send_raw(&self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
2581        self.control_handle.inner.send::<fidl::encoding::ResultType<
2582            DeviceGetRelativePerformanceResponse,
2583            i32,
2584        >>(
2585            result.map(|relative_performance| (relative_performance,)),
2586            self.tx_id,
2587            0x41c37eaf0c26a3d3,
2588            fidl::encoding::DynamicFlags::empty(),
2589        )
2590    }
2591}
2592
2593#[must_use = "FIDL methods require a response to be sent"]
2594#[derive(Debug)]
2595pub struct DeviceGetRelativePerformance2Responder {
2596    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2597    tx_id: u32,
2598}
2599
2600/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2601/// if the responder is dropped without sending a response, so that the client
2602/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2603impl std::ops::Drop for DeviceGetRelativePerformance2Responder {
2604    fn drop(&mut self) {
2605        self.control_handle.shutdown();
2606        // Safety: drops once, never accessed again
2607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2608    }
2609}
2610
2611impl fidl::endpoints::Responder for DeviceGetRelativePerformance2Responder {
2612    type ControlHandle = DeviceControlHandle;
2613
2614    fn control_handle(&self) -> &DeviceControlHandle {
2615        &self.control_handle
2616    }
2617
2618    fn drop_without_shutdown(mut self) {
2619        // Safety: drops once, never accessed again due to mem::forget
2620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2621        // Prevent Drop from running (which would shut down the channel)
2622        std::mem::forget(self);
2623    }
2624}
2625
2626impl DeviceGetRelativePerformance2Responder {
2627    /// Sends a response to the FIDL transaction.
2628    ///
2629    /// Sets the channel to shutdown if an error occurs.
2630    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
2631        let _result = self.send_raw(result);
2632        if _result.is_err() {
2633            self.control_handle.shutdown();
2634        }
2635        self.drop_without_shutdown();
2636        _result
2637    }
2638
2639    /// Similar to "send" but does not shutdown the channel if an error occurs.
2640    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
2641        let _result = self.send_raw(result);
2642        self.drop_without_shutdown();
2643        _result
2644    }
2645
2646    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
2647        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2648            DeviceGetRelativePerformance2Response,
2649            i32,
2650        >>(
2651            fidl::encoding::FlexibleResult::new(
2652                result.map(|relative_performance| (relative_performance,)),
2653            ),
2654            self.tx_id,
2655            0x48831ad9a7fc2e38,
2656            fidl::encoding::DynamicFlags::FLEXIBLE,
2657        )
2658    }
2659}
2660
2661#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2662pub struct ServiceMarker;
2663
2664#[cfg(target_os = "fuchsia")]
2665impl fidl::endpoints::ServiceMarker for ServiceMarker {
2666    type Proxy = ServiceProxy;
2667    type Request = ServiceRequest;
2668    const SERVICE_NAME: &'static str = "fuchsia.hardware.cpu.ctrl.Service";
2669}
2670
2671/// A request for one of the member protocols of Service.
2672///
2673#[cfg(target_os = "fuchsia")]
2674pub enum ServiceRequest {
2675    Device(DeviceRequestStream),
2676}
2677
2678#[cfg(target_os = "fuchsia")]
2679impl fidl::endpoints::ServiceRequest for ServiceRequest {
2680    type Service = ServiceMarker;
2681
2682    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2683        match name {
2684            "device" => Self::Device(
2685                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2686            ),
2687            _ => panic!("no such member protocol name for service Service"),
2688        }
2689    }
2690
2691    fn member_names() -> &'static [&'static str] {
2692        &["device"]
2693    }
2694}
2695#[cfg(target_os = "fuchsia")]
2696pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2697
2698#[cfg(target_os = "fuchsia")]
2699impl fidl::endpoints::ServiceProxy for ServiceProxy {
2700    type Service = ServiceMarker;
2701
2702    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2703        Self(opener)
2704    }
2705}
2706
2707#[cfg(target_os = "fuchsia")]
2708impl ServiceProxy {
2709    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
2710        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
2711        self.connect_channel_to_device(server_end)?;
2712        Ok(proxy)
2713    }
2714
2715    /// Like `connect_to_device`, but returns a sync proxy.
2716    /// See [`Self::connect_to_device`] for more details.
2717    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
2718        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
2719        self.connect_channel_to_device(server_end)?;
2720        Ok(proxy)
2721    }
2722
2723    /// Like `connect_to_device`, but accepts a server end.
2724    /// See [`Self::connect_to_device`] for more details.
2725    pub fn connect_channel_to_device(
2726        &self,
2727        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
2728    ) -> Result<(), fidl::Error> {
2729        self.0.open_member("device", server_end.into_channel())
2730    }
2731
2732    pub fn instance_name(&self) -> &str {
2733        self.0.instance_name()
2734    }
2735}
2736
2737mod internal {
2738    use super::*;
2739}