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