Skip to main content

fidl_fuchsia_power_cpu/
fidl_fuchsia_power_cpu.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_power_cpu__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DomainControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for DomainControllerMarker {
18    type Proxy = DomainControllerProxy;
19    type RequestStream = DomainControllerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DomainControllerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.power.cpu.DomainController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DomainControllerMarker {}
26pub type DomainControllerGetMaxFrequencyResult = Result<u64, GetMaxFrequencyError>;
27pub type DomainControllerSetMaxFrequencyResult = Result<(), SetMaxFrequencyError>;
28pub type DomainControllerClearMaxFrequencyResult = Result<(), ClearMaxFrequencyError>;
29
30pub trait DomainControllerProxyInterface: Send + Sync {
31    type ListDomainsResponseFut: std::future::Future<Output = Result<Vec<DomainInfo>, fidl::Error>>
32        + Send;
33    fn r#list_domains(&self) -> Self::ListDomainsResponseFut;
34    type GetMaxFrequencyResponseFut: std::future::Future<Output = Result<DomainControllerGetMaxFrequencyResult, fidl::Error>>
35        + Send;
36    fn r#get_max_frequency(&self, domain_id: u64) -> Self::GetMaxFrequencyResponseFut;
37    type SetMaxFrequencyResponseFut: std::future::Future<Output = Result<DomainControllerSetMaxFrequencyResult, fidl::Error>>
38        + Send;
39    fn r#set_max_frequency(
40        &self,
41        domain_id: u64,
42        frequency_index: u64,
43    ) -> Self::SetMaxFrequencyResponseFut;
44    type ClearMaxFrequencyResponseFut: std::future::Future<Output = Result<DomainControllerClearMaxFrequencyResult, fidl::Error>>
45        + Send;
46    fn r#clear_max_frequency(&self, domain_id: u64) -> Self::ClearMaxFrequencyResponseFut;
47}
48#[derive(Debug)]
49#[cfg(target_os = "fuchsia")]
50pub struct DomainControllerSynchronousProxy {
51    client: fidl::client::sync::Client,
52}
53
54#[cfg(target_os = "fuchsia")]
55impl fidl::endpoints::SynchronousProxy for DomainControllerSynchronousProxy {
56    type Proxy = DomainControllerProxy;
57    type Protocol = DomainControllerMarker;
58
59    fn from_channel(inner: fidl::Channel) -> Self {
60        Self::new(inner)
61    }
62
63    fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    fn as_channel(&self) -> &fidl::Channel {
68        self.client.as_channel()
69    }
70}
71
72#[cfg(target_os = "fuchsia")]
73impl DomainControllerSynchronousProxy {
74    pub fn new(channel: fidl::Channel) -> Self {
75        let protocol_name = <DomainControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
76        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
77    }
78
79    pub fn into_channel(self) -> fidl::Channel {
80        self.client.into_channel()
81    }
82
83    /// Waits until an event arrives and returns it. It is safe for other
84    /// threads to make concurrent requests while waiting for an event.
85    pub fn wait_for_event(
86        &self,
87        deadline: zx::MonotonicInstant,
88    ) -> Result<DomainControllerEvent, fidl::Error> {
89        DomainControllerEvent::decode(self.client.wait_for_event(deadline)?)
90    }
91
92    /// Lists info about each domain managed by the server.
93    ///
94    /// The server is guaranteed to fill all fields within `DomainInfo` unless
95    /// the field is explicitly marked as "Optional".
96    pub fn r#list_domains(
97        &self,
98        ___deadline: zx::MonotonicInstant,
99    ) -> Result<Vec<DomainInfo>, fidl::Error> {
100        let _response = self.client.send_query::<
101            fidl::encoding::EmptyPayload,
102            fidl::encoding::FlexibleType<DomainControllerListDomainsResponse>,
103        >(
104            (),
105            0x3dfa728011b3ee0c,
106            fidl::encoding::DynamicFlags::FLEXIBLE,
107            ___deadline,
108        )?
109        .into_result::<DomainControllerMarker>("list_domains")?;
110        Ok(_response.domains)
111    }
112
113    /// Gets the index of the max frequency the CPU can run at.
114    ///
115    /// `max_frequency_index` corresponds to the index of a frequency within
116    /// this domain's `available_frequencies_hz` list retrieved via
117    /// [`ListDomains`].
118    ///
119    /// If SetMaxFrequency has never been called, this will return the index
120    /// that corresponds to the highest available frequency for this domain.
121    ///
122    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
123    pub fn r#get_max_frequency(
124        &self,
125        mut domain_id: u64,
126        ___deadline: zx::MonotonicInstant,
127    ) -> Result<DomainControllerGetMaxFrequencyResult, fidl::Error> {
128        let _response = self.client.send_query::<
129            DomainControllerGetMaxFrequencyRequest,
130            fidl::encoding::FlexibleResultType<DomainControllerGetMaxFrequencyResponse, GetMaxFrequencyError>,
131        >(
132            (domain_id,),
133            0x6c8cc16cbd270f62,
134            fidl::encoding::DynamicFlags::FLEXIBLE,
135            ___deadline,
136        )?
137        .into_result::<DomainControllerMarker>("get_max_frequency")?;
138        Ok(_response.map(|x| x.max_frequency_index))
139    }
140
141    /// Sets the max frequency the CPU can run at.
142    ///
143    /// `frequency_index` must correspond to the index of a frequency within
144    /// this domain's `available_frequencies_hz` list retrieved via
145    /// [`ListDomains`].
146    ///
147    /// On products with Runtime Processor Power Management (RPPM), the CPU may
148    /// briefly exceed max frequency if power limits allow.
149    ///
150    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
151    /// If `frequency_index` is invalid, INVALID_ARGUMENTS is returned.
152    pub fn r#set_max_frequency(
153        &self,
154        mut domain_id: u64,
155        mut frequency_index: u64,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<DomainControllerSetMaxFrequencyResult, fidl::Error> {
158        let _response = self.client.send_query::<
159            DomainControllerSetMaxFrequencyRequest,
160            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, SetMaxFrequencyError>,
161        >(
162            (domain_id, frequency_index,),
163            0x427d7a45e538939e,
164            fidl::encoding::DynamicFlags::FLEXIBLE,
165            ___deadline,
166        )?
167        .into_result::<DomainControllerMarker>("set_max_frequency")?;
168        Ok(_response.map(|x| x))
169    }
170
171    /// Clears the max frequency limit the CPU can run at.
172    ///
173    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
174    pub fn r#clear_max_frequency(
175        &self,
176        mut domain_id: u64,
177        ___deadline: zx::MonotonicInstant,
178    ) -> Result<DomainControllerClearMaxFrequencyResult, fidl::Error> {
179        let _response = self.client.send_query::<
180            DomainControllerClearMaxFrequencyRequest,
181            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ClearMaxFrequencyError>,
182        >(
183            (domain_id,),
184            0x738116a31e202ba5,
185            fidl::encoding::DynamicFlags::FLEXIBLE,
186            ___deadline,
187        )?
188        .into_result::<DomainControllerMarker>("clear_max_frequency")?;
189        Ok(_response.map(|x| x))
190    }
191}
192
193#[cfg(target_os = "fuchsia")]
194impl From<DomainControllerSynchronousProxy> for zx::NullableHandle {
195    fn from(value: DomainControllerSynchronousProxy) -> Self {
196        value.into_channel().into()
197    }
198}
199
200#[cfg(target_os = "fuchsia")]
201impl From<fidl::Channel> for DomainControllerSynchronousProxy {
202    fn from(value: fidl::Channel) -> Self {
203        Self::new(value)
204    }
205}
206
207#[cfg(target_os = "fuchsia")]
208impl fidl::endpoints::FromClient for DomainControllerSynchronousProxy {
209    type Protocol = DomainControllerMarker;
210
211    fn from_client(value: fidl::endpoints::ClientEnd<DomainControllerMarker>) -> Self {
212        Self::new(value.into_channel())
213    }
214}
215
216#[derive(Debug, Clone)]
217pub struct DomainControllerProxy {
218    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
219}
220
221impl fidl::endpoints::Proxy for DomainControllerProxy {
222    type Protocol = DomainControllerMarker;
223
224    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
225        Self::new(inner)
226    }
227
228    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
229        self.client.into_channel().map_err(|client| Self { client })
230    }
231
232    fn as_channel(&self) -> &::fidl::AsyncChannel {
233        self.client.as_channel()
234    }
235}
236
237impl DomainControllerProxy {
238    /// Create a new Proxy for fuchsia.power.cpu/DomainController.
239    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
240        let protocol_name = <DomainControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
241        Self { client: fidl::client::Client::new(channel, protocol_name) }
242    }
243
244    /// Get a Stream of events from the remote end of the protocol.
245    ///
246    /// # Panics
247    ///
248    /// Panics if the event stream was already taken.
249    pub fn take_event_stream(&self) -> DomainControllerEventStream {
250        DomainControllerEventStream { event_receiver: self.client.take_event_receiver() }
251    }
252
253    /// Lists info about each domain managed by the server.
254    ///
255    /// The server is guaranteed to fill all fields within `DomainInfo` unless
256    /// the field is explicitly marked as "Optional".
257    pub fn r#list_domains(
258        &self,
259    ) -> fidl::client::QueryResponseFut<
260        Vec<DomainInfo>,
261        fidl::encoding::DefaultFuchsiaResourceDialect,
262    > {
263        DomainControllerProxyInterface::r#list_domains(self)
264    }
265
266    /// Gets the index of the max frequency the CPU can run at.
267    ///
268    /// `max_frequency_index` corresponds to the index of a frequency within
269    /// this domain's `available_frequencies_hz` list retrieved via
270    /// [`ListDomains`].
271    ///
272    /// If SetMaxFrequency has never been called, this will return the index
273    /// that corresponds to the highest available frequency for this domain.
274    ///
275    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
276    pub fn r#get_max_frequency(
277        &self,
278        mut domain_id: u64,
279    ) -> fidl::client::QueryResponseFut<
280        DomainControllerGetMaxFrequencyResult,
281        fidl::encoding::DefaultFuchsiaResourceDialect,
282    > {
283        DomainControllerProxyInterface::r#get_max_frequency(self, domain_id)
284    }
285
286    /// Sets the max frequency the CPU can run at.
287    ///
288    /// `frequency_index` must correspond to the index of a frequency within
289    /// this domain's `available_frequencies_hz` list retrieved via
290    /// [`ListDomains`].
291    ///
292    /// On products with Runtime Processor Power Management (RPPM), the CPU may
293    /// briefly exceed max frequency if power limits allow.
294    ///
295    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
296    /// If `frequency_index` is invalid, INVALID_ARGUMENTS is returned.
297    pub fn r#set_max_frequency(
298        &self,
299        mut domain_id: u64,
300        mut frequency_index: u64,
301    ) -> fidl::client::QueryResponseFut<
302        DomainControllerSetMaxFrequencyResult,
303        fidl::encoding::DefaultFuchsiaResourceDialect,
304    > {
305        DomainControllerProxyInterface::r#set_max_frequency(self, domain_id, frequency_index)
306    }
307
308    /// Clears the max frequency limit the CPU can run at.
309    ///
310    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
311    pub fn r#clear_max_frequency(
312        &self,
313        mut domain_id: u64,
314    ) -> fidl::client::QueryResponseFut<
315        DomainControllerClearMaxFrequencyResult,
316        fidl::encoding::DefaultFuchsiaResourceDialect,
317    > {
318        DomainControllerProxyInterface::r#clear_max_frequency(self, domain_id)
319    }
320}
321
322impl DomainControllerProxyInterface for DomainControllerProxy {
323    type ListDomainsResponseFut = fidl::client::QueryResponseFut<
324        Vec<DomainInfo>,
325        fidl::encoding::DefaultFuchsiaResourceDialect,
326    >;
327    fn r#list_domains(&self) -> Self::ListDomainsResponseFut {
328        fn _decode(
329            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
330        ) -> Result<Vec<DomainInfo>, fidl::Error> {
331            let _response = fidl::client::decode_transaction_body::<
332                fidl::encoding::FlexibleType<DomainControllerListDomainsResponse>,
333                fidl::encoding::DefaultFuchsiaResourceDialect,
334                0x3dfa728011b3ee0c,
335            >(_buf?)?
336            .into_result::<DomainControllerMarker>("list_domains")?;
337            Ok(_response.domains)
338        }
339        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<DomainInfo>>(
340            (),
341            0x3dfa728011b3ee0c,
342            fidl::encoding::DynamicFlags::FLEXIBLE,
343            _decode,
344        )
345    }
346
347    type GetMaxFrequencyResponseFut = fidl::client::QueryResponseFut<
348        DomainControllerGetMaxFrequencyResult,
349        fidl::encoding::DefaultFuchsiaResourceDialect,
350    >;
351    fn r#get_max_frequency(&self, mut domain_id: u64) -> Self::GetMaxFrequencyResponseFut {
352        fn _decode(
353            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
354        ) -> Result<DomainControllerGetMaxFrequencyResult, fidl::Error> {
355            let _response = fidl::client::decode_transaction_body::<
356                fidl::encoding::FlexibleResultType<
357                    DomainControllerGetMaxFrequencyResponse,
358                    GetMaxFrequencyError,
359                >,
360                fidl::encoding::DefaultFuchsiaResourceDialect,
361                0x6c8cc16cbd270f62,
362            >(_buf?)?
363            .into_result::<DomainControllerMarker>("get_max_frequency")?;
364            Ok(_response.map(|x| x.max_frequency_index))
365        }
366        self.client.send_query_and_decode::<
367            DomainControllerGetMaxFrequencyRequest,
368            DomainControllerGetMaxFrequencyResult,
369        >(
370            (domain_id,),
371            0x6c8cc16cbd270f62,
372            fidl::encoding::DynamicFlags::FLEXIBLE,
373            _decode,
374        )
375    }
376
377    type SetMaxFrequencyResponseFut = fidl::client::QueryResponseFut<
378        DomainControllerSetMaxFrequencyResult,
379        fidl::encoding::DefaultFuchsiaResourceDialect,
380    >;
381    fn r#set_max_frequency(
382        &self,
383        mut domain_id: u64,
384        mut frequency_index: u64,
385    ) -> Self::SetMaxFrequencyResponseFut {
386        fn _decode(
387            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
388        ) -> Result<DomainControllerSetMaxFrequencyResult, fidl::Error> {
389            let _response = fidl::client::decode_transaction_body::<
390                fidl::encoding::FlexibleResultType<
391                    fidl::encoding::EmptyStruct,
392                    SetMaxFrequencyError,
393                >,
394                fidl::encoding::DefaultFuchsiaResourceDialect,
395                0x427d7a45e538939e,
396            >(_buf?)?
397            .into_result::<DomainControllerMarker>("set_max_frequency")?;
398            Ok(_response.map(|x| x))
399        }
400        self.client.send_query_and_decode::<
401            DomainControllerSetMaxFrequencyRequest,
402            DomainControllerSetMaxFrequencyResult,
403        >(
404            (domain_id, frequency_index,),
405            0x427d7a45e538939e,
406            fidl::encoding::DynamicFlags::FLEXIBLE,
407            _decode,
408        )
409    }
410
411    type ClearMaxFrequencyResponseFut = fidl::client::QueryResponseFut<
412        DomainControllerClearMaxFrequencyResult,
413        fidl::encoding::DefaultFuchsiaResourceDialect,
414    >;
415    fn r#clear_max_frequency(&self, mut domain_id: u64) -> Self::ClearMaxFrequencyResponseFut {
416        fn _decode(
417            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
418        ) -> Result<DomainControllerClearMaxFrequencyResult, fidl::Error> {
419            let _response = fidl::client::decode_transaction_body::<
420                fidl::encoding::FlexibleResultType<
421                    fidl::encoding::EmptyStruct,
422                    ClearMaxFrequencyError,
423                >,
424                fidl::encoding::DefaultFuchsiaResourceDialect,
425                0x738116a31e202ba5,
426            >(_buf?)?
427            .into_result::<DomainControllerMarker>("clear_max_frequency")?;
428            Ok(_response.map(|x| x))
429        }
430        self.client.send_query_and_decode::<
431            DomainControllerClearMaxFrequencyRequest,
432            DomainControllerClearMaxFrequencyResult,
433        >(
434            (domain_id,),
435            0x738116a31e202ba5,
436            fidl::encoding::DynamicFlags::FLEXIBLE,
437            _decode,
438        )
439    }
440}
441
442pub struct DomainControllerEventStream {
443    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
444}
445
446impl std::marker::Unpin for DomainControllerEventStream {}
447
448impl futures::stream::FusedStream for DomainControllerEventStream {
449    fn is_terminated(&self) -> bool {
450        self.event_receiver.is_terminated()
451    }
452}
453
454impl futures::Stream for DomainControllerEventStream {
455    type Item = Result<DomainControllerEvent, fidl::Error>;
456
457    fn poll_next(
458        mut self: std::pin::Pin<&mut Self>,
459        cx: &mut std::task::Context<'_>,
460    ) -> std::task::Poll<Option<Self::Item>> {
461        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
462            &mut self.event_receiver,
463            cx
464        )?) {
465            Some(buf) => std::task::Poll::Ready(Some(DomainControllerEvent::decode(buf))),
466            None => std::task::Poll::Ready(None),
467        }
468    }
469}
470
471#[derive(Debug)]
472pub enum DomainControllerEvent {
473    #[non_exhaustive]
474    _UnknownEvent {
475        /// Ordinal of the event that was sent.
476        ordinal: u64,
477    },
478}
479
480impl DomainControllerEvent {
481    /// Decodes a message buffer as a [`DomainControllerEvent`].
482    fn decode(
483        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
484    ) -> Result<DomainControllerEvent, fidl::Error> {
485        let (bytes, _handles) = buf.split_mut();
486        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
487        debug_assert_eq!(tx_header.tx_id, 0);
488        match tx_header.ordinal {
489            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
490                Ok(DomainControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
491            }
492            _ => Err(fidl::Error::UnknownOrdinal {
493                ordinal: tx_header.ordinal,
494                protocol_name:
495                    <DomainControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
496            }),
497        }
498    }
499}
500
501/// A Stream of incoming requests for fuchsia.power.cpu/DomainController.
502pub struct DomainControllerRequestStream {
503    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
504    is_terminated: bool,
505}
506
507impl std::marker::Unpin for DomainControllerRequestStream {}
508
509impl futures::stream::FusedStream for DomainControllerRequestStream {
510    fn is_terminated(&self) -> bool {
511        self.is_terminated
512    }
513}
514
515impl fidl::endpoints::RequestStream for DomainControllerRequestStream {
516    type Protocol = DomainControllerMarker;
517    type ControlHandle = DomainControllerControlHandle;
518
519    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
520        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
521    }
522
523    fn control_handle(&self) -> Self::ControlHandle {
524        DomainControllerControlHandle { inner: self.inner.clone() }
525    }
526
527    fn into_inner(
528        self,
529    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
530    {
531        (self.inner, self.is_terminated)
532    }
533
534    fn from_inner(
535        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
536        is_terminated: bool,
537    ) -> Self {
538        Self { inner, is_terminated }
539    }
540}
541
542impl futures::Stream for DomainControllerRequestStream {
543    type Item = Result<DomainControllerRequest, fidl::Error>;
544
545    fn poll_next(
546        mut self: std::pin::Pin<&mut Self>,
547        cx: &mut std::task::Context<'_>,
548    ) -> std::task::Poll<Option<Self::Item>> {
549        let this = &mut *self;
550        if this.inner.check_shutdown(cx) {
551            this.is_terminated = true;
552            return std::task::Poll::Ready(None);
553        }
554        if this.is_terminated {
555            panic!("polled DomainControllerRequestStream after completion");
556        }
557        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
558            |bytes, handles| {
559                match this.inner.channel().read_etc(cx, bytes, handles) {
560                    std::task::Poll::Ready(Ok(())) => {}
561                    std::task::Poll::Pending => return std::task::Poll::Pending,
562                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
563                        this.is_terminated = true;
564                        return std::task::Poll::Ready(None);
565                    }
566                    std::task::Poll::Ready(Err(e)) => {
567                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
568                            e.into(),
569                        ))));
570                    }
571                }
572
573                // A message has been received from the channel
574                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
575
576                std::task::Poll::Ready(Some(match header.ordinal {
577                    0x3dfa728011b3ee0c => {
578                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
579                        let mut req = fidl::new_empty!(
580                            fidl::encoding::EmptyPayload,
581                            fidl::encoding::DefaultFuchsiaResourceDialect
582                        );
583                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
584                        let control_handle =
585                            DomainControllerControlHandle { inner: this.inner.clone() };
586                        Ok(DomainControllerRequest::ListDomains {
587                            responder: DomainControllerListDomainsResponder {
588                                control_handle: std::mem::ManuallyDrop::new(control_handle),
589                                tx_id: header.tx_id,
590                            },
591                        })
592                    }
593                    0x6c8cc16cbd270f62 => {
594                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
595                        let mut req = fidl::new_empty!(
596                            DomainControllerGetMaxFrequencyRequest,
597                            fidl::encoding::DefaultFuchsiaResourceDialect
598                        );
599                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DomainControllerGetMaxFrequencyRequest>(&header, _body_bytes, handles, &mut req)?;
600                        let control_handle =
601                            DomainControllerControlHandle { inner: this.inner.clone() };
602                        Ok(DomainControllerRequest::GetMaxFrequency {
603                            domain_id: req.domain_id,
604
605                            responder: DomainControllerGetMaxFrequencyResponder {
606                                control_handle: std::mem::ManuallyDrop::new(control_handle),
607                                tx_id: header.tx_id,
608                            },
609                        })
610                    }
611                    0x427d7a45e538939e => {
612                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
613                        let mut req = fidl::new_empty!(
614                            DomainControllerSetMaxFrequencyRequest,
615                            fidl::encoding::DefaultFuchsiaResourceDialect
616                        );
617                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DomainControllerSetMaxFrequencyRequest>(&header, _body_bytes, handles, &mut req)?;
618                        let control_handle =
619                            DomainControllerControlHandle { inner: this.inner.clone() };
620                        Ok(DomainControllerRequest::SetMaxFrequency {
621                            domain_id: req.domain_id,
622                            frequency_index: req.frequency_index,
623
624                            responder: DomainControllerSetMaxFrequencyResponder {
625                                control_handle: std::mem::ManuallyDrop::new(control_handle),
626                                tx_id: header.tx_id,
627                            },
628                        })
629                    }
630                    0x738116a31e202ba5 => {
631                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
632                        let mut req = fidl::new_empty!(
633                            DomainControllerClearMaxFrequencyRequest,
634                            fidl::encoding::DefaultFuchsiaResourceDialect
635                        );
636                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DomainControllerClearMaxFrequencyRequest>(&header, _body_bytes, handles, &mut req)?;
637                        let control_handle =
638                            DomainControllerControlHandle { inner: this.inner.clone() };
639                        Ok(DomainControllerRequest::ClearMaxFrequency {
640                            domain_id: req.domain_id,
641
642                            responder: DomainControllerClearMaxFrequencyResponder {
643                                control_handle: std::mem::ManuallyDrop::new(control_handle),
644                                tx_id: header.tx_id,
645                            },
646                        })
647                    }
648                    _ if header.tx_id == 0
649                        && header
650                            .dynamic_flags()
651                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
652                    {
653                        Ok(DomainControllerRequest::_UnknownMethod {
654                            ordinal: header.ordinal,
655                            control_handle: DomainControllerControlHandle {
656                                inner: this.inner.clone(),
657                            },
658                            method_type: fidl::MethodType::OneWay,
659                        })
660                    }
661                    _ if header
662                        .dynamic_flags()
663                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
664                    {
665                        this.inner.send_framework_err(
666                            fidl::encoding::FrameworkErr::UnknownMethod,
667                            header.tx_id,
668                            header.ordinal,
669                            header.dynamic_flags(),
670                            (bytes, handles),
671                        )?;
672                        Ok(DomainControllerRequest::_UnknownMethod {
673                            ordinal: header.ordinal,
674                            control_handle: DomainControllerControlHandle {
675                                inner: this.inner.clone(),
676                            },
677                            method_type: fidl::MethodType::TwoWay,
678                        })
679                    }
680                    _ => Err(fidl::Error::UnknownOrdinal {
681                        ordinal: header.ordinal,
682                        protocol_name:
683                            <DomainControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
684                    }),
685                }))
686            },
687        )
688    }
689}
690
691#[derive(Debug)]
692pub enum DomainControllerRequest {
693    /// Lists info about each domain managed by the server.
694    ///
695    /// The server is guaranteed to fill all fields within `DomainInfo` unless
696    /// the field is explicitly marked as "Optional".
697    ListDomains { responder: DomainControllerListDomainsResponder },
698    /// Gets the index of the max frequency the CPU can run at.
699    ///
700    /// `max_frequency_index` corresponds to the index of a frequency within
701    /// this domain's `available_frequencies_hz` list retrieved via
702    /// [`ListDomains`].
703    ///
704    /// If SetMaxFrequency has never been called, this will return the index
705    /// that corresponds to the highest available frequency for this domain.
706    ///
707    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
708    GetMaxFrequency { domain_id: u64, responder: DomainControllerGetMaxFrequencyResponder },
709    /// Sets the max frequency the CPU can run at.
710    ///
711    /// `frequency_index` must correspond to the index of a frequency within
712    /// this domain's `available_frequencies_hz` list retrieved via
713    /// [`ListDomains`].
714    ///
715    /// On products with Runtime Processor Power Management (RPPM), the CPU may
716    /// briefly exceed max frequency if power limits allow.
717    ///
718    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
719    /// If `frequency_index` is invalid, INVALID_ARGUMENTS is returned.
720    SetMaxFrequency {
721        domain_id: u64,
722        frequency_index: u64,
723        responder: DomainControllerSetMaxFrequencyResponder,
724    },
725    /// Clears the max frequency limit the CPU can run at.
726    ///
727    /// If `domain_id` is invalid, INVALID_ARGUMENTS is returned.
728    ClearMaxFrequency { domain_id: u64, responder: DomainControllerClearMaxFrequencyResponder },
729    /// An interaction was received which does not match any known method.
730    #[non_exhaustive]
731    _UnknownMethod {
732        /// Ordinal of the method that was called.
733        ordinal: u64,
734        control_handle: DomainControllerControlHandle,
735        method_type: fidl::MethodType,
736    },
737}
738
739impl DomainControllerRequest {
740    #[allow(irrefutable_let_patterns)]
741    pub fn into_list_domains(self) -> Option<(DomainControllerListDomainsResponder)> {
742        if let DomainControllerRequest::ListDomains { responder } = self {
743            Some((responder))
744        } else {
745            None
746        }
747    }
748
749    #[allow(irrefutable_let_patterns)]
750    pub fn into_get_max_frequency(self) -> Option<(u64, DomainControllerGetMaxFrequencyResponder)> {
751        if let DomainControllerRequest::GetMaxFrequency { domain_id, responder } = self {
752            Some((domain_id, responder))
753        } else {
754            None
755        }
756    }
757
758    #[allow(irrefutable_let_patterns)]
759    pub fn into_set_max_frequency(
760        self,
761    ) -> Option<(u64, u64, DomainControllerSetMaxFrequencyResponder)> {
762        if let DomainControllerRequest::SetMaxFrequency { domain_id, frequency_index, responder } =
763            self
764        {
765            Some((domain_id, frequency_index, responder))
766        } else {
767            None
768        }
769    }
770
771    #[allow(irrefutable_let_patterns)]
772    pub fn into_clear_max_frequency(
773        self,
774    ) -> Option<(u64, DomainControllerClearMaxFrequencyResponder)> {
775        if let DomainControllerRequest::ClearMaxFrequency { domain_id, responder } = self {
776            Some((domain_id, responder))
777        } else {
778            None
779        }
780    }
781
782    /// Name of the method defined in FIDL
783    pub fn method_name(&self) -> &'static str {
784        match *self {
785            DomainControllerRequest::ListDomains { .. } => "list_domains",
786            DomainControllerRequest::GetMaxFrequency { .. } => "get_max_frequency",
787            DomainControllerRequest::SetMaxFrequency { .. } => "set_max_frequency",
788            DomainControllerRequest::ClearMaxFrequency { .. } => "clear_max_frequency",
789            DomainControllerRequest::_UnknownMethod {
790                method_type: fidl::MethodType::OneWay,
791                ..
792            } => "unknown one-way method",
793            DomainControllerRequest::_UnknownMethod {
794                method_type: fidl::MethodType::TwoWay,
795                ..
796            } => "unknown two-way method",
797        }
798    }
799}
800
801#[derive(Debug, Clone)]
802pub struct DomainControllerControlHandle {
803    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
804}
805
806impl fidl::endpoints::ControlHandle for DomainControllerControlHandle {
807    fn shutdown(&self) {
808        self.inner.shutdown()
809    }
810
811    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
812        self.inner.shutdown_with_epitaph(status)
813    }
814
815    fn is_closed(&self) -> bool {
816        self.inner.channel().is_closed()
817    }
818    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
819        self.inner.channel().on_closed()
820    }
821
822    #[cfg(target_os = "fuchsia")]
823    fn signal_peer(
824        &self,
825        clear_mask: zx::Signals,
826        set_mask: zx::Signals,
827    ) -> Result<(), zx_status::Status> {
828        use fidl::Peered;
829        self.inner.channel().signal_peer(clear_mask, set_mask)
830    }
831}
832
833impl DomainControllerControlHandle {}
834
835#[must_use = "FIDL methods require a response to be sent"]
836#[derive(Debug)]
837pub struct DomainControllerListDomainsResponder {
838    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
839    tx_id: u32,
840}
841
842/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
843/// if the responder is dropped without sending a response, so that the client
844/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
845impl std::ops::Drop for DomainControllerListDomainsResponder {
846    fn drop(&mut self) {
847        self.control_handle.shutdown();
848        // Safety: drops once, never accessed again
849        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
850    }
851}
852
853impl fidl::endpoints::Responder for DomainControllerListDomainsResponder {
854    type ControlHandle = DomainControllerControlHandle;
855
856    fn control_handle(&self) -> &DomainControllerControlHandle {
857        &self.control_handle
858    }
859
860    fn drop_without_shutdown(mut self) {
861        // Safety: drops once, never accessed again due to mem::forget
862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
863        // Prevent Drop from running (which would shut down the channel)
864        std::mem::forget(self);
865    }
866}
867
868impl DomainControllerListDomainsResponder {
869    /// Sends a response to the FIDL transaction.
870    ///
871    /// Sets the channel to shutdown if an error occurs.
872    pub fn send(self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
873        let _result = self.send_raw(domains);
874        if _result.is_err() {
875            self.control_handle.shutdown();
876        }
877        self.drop_without_shutdown();
878        _result
879    }
880
881    /// Similar to "send" but does not shutdown the channel if an error occurs.
882    pub fn send_no_shutdown_on_err(self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
883        let _result = self.send_raw(domains);
884        self.drop_without_shutdown();
885        _result
886    }
887
888    fn send_raw(&self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
889        self.control_handle
890            .inner
891            .send::<fidl::encoding::FlexibleType<DomainControllerListDomainsResponse>>(
892                fidl::encoding::Flexible::new((domains,)),
893                self.tx_id,
894                0x3dfa728011b3ee0c,
895                fidl::encoding::DynamicFlags::FLEXIBLE,
896            )
897    }
898}
899
900#[must_use = "FIDL methods require a response to be sent"]
901#[derive(Debug)]
902pub struct DomainControllerGetMaxFrequencyResponder {
903    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
904    tx_id: u32,
905}
906
907/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
908/// if the responder is dropped without sending a response, so that the client
909/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
910impl std::ops::Drop for DomainControllerGetMaxFrequencyResponder {
911    fn drop(&mut self) {
912        self.control_handle.shutdown();
913        // Safety: drops once, never accessed again
914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
915    }
916}
917
918impl fidl::endpoints::Responder for DomainControllerGetMaxFrequencyResponder {
919    type ControlHandle = DomainControllerControlHandle;
920
921    fn control_handle(&self) -> &DomainControllerControlHandle {
922        &self.control_handle
923    }
924
925    fn drop_without_shutdown(mut self) {
926        // Safety: drops once, never accessed again due to mem::forget
927        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
928        // Prevent Drop from running (which would shut down the channel)
929        std::mem::forget(self);
930    }
931}
932
933impl DomainControllerGetMaxFrequencyResponder {
934    /// Sends a response to the FIDL transaction.
935    ///
936    /// Sets the channel to shutdown if an error occurs.
937    pub fn send(self, mut result: Result<u64, GetMaxFrequencyError>) -> Result<(), fidl::Error> {
938        let _result = self.send_raw(result);
939        if _result.is_err() {
940            self.control_handle.shutdown();
941        }
942        self.drop_without_shutdown();
943        _result
944    }
945
946    /// Similar to "send" but does not shutdown the channel if an error occurs.
947    pub fn send_no_shutdown_on_err(
948        self,
949        mut result: Result<u64, GetMaxFrequencyError>,
950    ) -> Result<(), fidl::Error> {
951        let _result = self.send_raw(result);
952        self.drop_without_shutdown();
953        _result
954    }
955
956    fn send_raw(&self, mut result: Result<u64, GetMaxFrequencyError>) -> Result<(), fidl::Error> {
957        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
958            DomainControllerGetMaxFrequencyResponse,
959            GetMaxFrequencyError,
960        >>(
961            fidl::encoding::FlexibleResult::new(
962                result.map(|max_frequency_index| (max_frequency_index,)),
963            ),
964            self.tx_id,
965            0x6c8cc16cbd270f62,
966            fidl::encoding::DynamicFlags::FLEXIBLE,
967        )
968    }
969}
970
971#[must_use = "FIDL methods require a response to be sent"]
972#[derive(Debug)]
973pub struct DomainControllerSetMaxFrequencyResponder {
974    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
975    tx_id: u32,
976}
977
978/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
979/// if the responder is dropped without sending a response, so that the client
980/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
981impl std::ops::Drop for DomainControllerSetMaxFrequencyResponder {
982    fn drop(&mut self) {
983        self.control_handle.shutdown();
984        // Safety: drops once, never accessed again
985        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
986    }
987}
988
989impl fidl::endpoints::Responder for DomainControllerSetMaxFrequencyResponder {
990    type ControlHandle = DomainControllerControlHandle;
991
992    fn control_handle(&self) -> &DomainControllerControlHandle {
993        &self.control_handle
994    }
995
996    fn drop_without_shutdown(mut self) {
997        // Safety: drops once, never accessed again due to mem::forget
998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
999        // Prevent Drop from running (which would shut down the channel)
1000        std::mem::forget(self);
1001    }
1002}
1003
1004impl DomainControllerSetMaxFrequencyResponder {
1005    /// Sends a response to the FIDL transaction.
1006    ///
1007    /// Sets the channel to shutdown if an error occurs.
1008    pub fn send(self, mut result: Result<(), SetMaxFrequencyError>) -> Result<(), fidl::Error> {
1009        let _result = self.send_raw(result);
1010        if _result.is_err() {
1011            self.control_handle.shutdown();
1012        }
1013        self.drop_without_shutdown();
1014        _result
1015    }
1016
1017    /// Similar to "send" but does not shutdown the channel if an error occurs.
1018    pub fn send_no_shutdown_on_err(
1019        self,
1020        mut result: Result<(), SetMaxFrequencyError>,
1021    ) -> Result<(), fidl::Error> {
1022        let _result = self.send_raw(result);
1023        self.drop_without_shutdown();
1024        _result
1025    }
1026
1027    fn send_raw(&self, mut result: Result<(), SetMaxFrequencyError>) -> Result<(), fidl::Error> {
1028        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1029            fidl::encoding::EmptyStruct,
1030            SetMaxFrequencyError,
1031        >>(
1032            fidl::encoding::FlexibleResult::new(result),
1033            self.tx_id,
1034            0x427d7a45e538939e,
1035            fidl::encoding::DynamicFlags::FLEXIBLE,
1036        )
1037    }
1038}
1039
1040#[must_use = "FIDL methods require a response to be sent"]
1041#[derive(Debug)]
1042pub struct DomainControllerClearMaxFrequencyResponder {
1043    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
1044    tx_id: u32,
1045}
1046
1047/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
1048/// if the responder is dropped without sending a response, so that the client
1049/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1050impl std::ops::Drop for DomainControllerClearMaxFrequencyResponder {
1051    fn drop(&mut self) {
1052        self.control_handle.shutdown();
1053        // Safety: drops once, never accessed again
1054        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1055    }
1056}
1057
1058impl fidl::endpoints::Responder for DomainControllerClearMaxFrequencyResponder {
1059    type ControlHandle = DomainControllerControlHandle;
1060
1061    fn control_handle(&self) -> &DomainControllerControlHandle {
1062        &self.control_handle
1063    }
1064
1065    fn drop_without_shutdown(mut self) {
1066        // Safety: drops once, never accessed again due to mem::forget
1067        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1068        // Prevent Drop from running (which would shut down the channel)
1069        std::mem::forget(self);
1070    }
1071}
1072
1073impl DomainControllerClearMaxFrequencyResponder {
1074    /// Sends a response to the FIDL transaction.
1075    ///
1076    /// Sets the channel to shutdown if an error occurs.
1077    pub fn send(self, mut result: Result<(), ClearMaxFrequencyError>) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw(result);
1079        if _result.is_err() {
1080            self.control_handle.shutdown();
1081        }
1082        self.drop_without_shutdown();
1083        _result
1084    }
1085
1086    /// Similar to "send" but does not shutdown the channel if an error occurs.
1087    pub fn send_no_shutdown_on_err(
1088        self,
1089        mut result: Result<(), ClearMaxFrequencyError>,
1090    ) -> Result<(), fidl::Error> {
1091        let _result = self.send_raw(result);
1092        self.drop_without_shutdown();
1093        _result
1094    }
1095
1096    fn send_raw(&self, mut result: Result<(), ClearMaxFrequencyError>) -> Result<(), fidl::Error> {
1097        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1098            fidl::encoding::EmptyStruct,
1099            ClearMaxFrequencyError,
1100        >>(
1101            fidl::encoding::FlexibleResult::new(result),
1102            self.tx_id,
1103            0x738116a31e202ba5,
1104            fidl::encoding::DynamicFlags::FLEXIBLE,
1105        )
1106    }
1107}
1108
1109mod internal {
1110    use super::*;
1111}