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 fidl::endpoints::ControlHandle for DomainControllerControlHandle {
812    fn shutdown(&self) {
813        self.inner.shutdown()
814    }
815
816    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
817        self.inner.shutdown_with_epitaph(status)
818    }
819
820    fn is_closed(&self) -> bool {
821        self.inner.channel().is_closed()
822    }
823    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
824        self.inner.channel().on_closed()
825    }
826
827    #[cfg(target_os = "fuchsia")]
828    fn signal_peer(
829        &self,
830        clear_mask: zx::Signals,
831        set_mask: zx::Signals,
832    ) -> Result<(), zx_status::Status> {
833        use fidl::Peered;
834        self.inner.channel().signal_peer(clear_mask, set_mask)
835    }
836}
837
838impl DomainControllerControlHandle {}
839
840#[must_use = "FIDL methods require a response to be sent"]
841#[derive(Debug)]
842pub struct DomainControllerListDomainsResponder {
843    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
844    tx_id: u32,
845}
846
847/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
848/// if the responder is dropped without sending a response, so that the client
849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
850impl std::ops::Drop for DomainControllerListDomainsResponder {
851    fn drop(&mut self) {
852        self.control_handle.shutdown();
853        // Safety: drops once, never accessed again
854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
855    }
856}
857
858impl fidl::endpoints::Responder for DomainControllerListDomainsResponder {
859    type ControlHandle = DomainControllerControlHandle;
860
861    fn control_handle(&self) -> &DomainControllerControlHandle {
862        &self.control_handle
863    }
864
865    fn drop_without_shutdown(mut self) {
866        // Safety: drops once, never accessed again due to mem::forget
867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
868        // Prevent Drop from running (which would shut down the channel)
869        std::mem::forget(self);
870    }
871}
872
873impl DomainControllerListDomainsResponder {
874    /// Sends a response to the FIDL transaction.
875    ///
876    /// Sets the channel to shutdown if an error occurs.
877    pub fn send(self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
878        let _result = self.send_raw(domains);
879        if _result.is_err() {
880            self.control_handle.shutdown();
881        }
882        self.drop_without_shutdown();
883        _result
884    }
885
886    /// Similar to "send" but does not shutdown the channel if an error occurs.
887    pub fn send_no_shutdown_on_err(self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
888        let _result = self.send_raw(domains);
889        self.drop_without_shutdown();
890        _result
891    }
892
893    fn send_raw(&self, mut domains: &[DomainInfo]) -> Result<(), fidl::Error> {
894        self.control_handle
895            .inner
896            .send::<fidl::encoding::FlexibleType<DomainControllerListDomainsResponse>>(
897                fidl::encoding::Flexible::new((domains,)),
898                self.tx_id,
899                0x3dfa728011b3ee0c,
900                fidl::encoding::DynamicFlags::FLEXIBLE,
901            )
902    }
903}
904
905#[must_use = "FIDL methods require a response to be sent"]
906#[derive(Debug)]
907pub struct DomainControllerGetMaxFrequencyResponder {
908    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
909    tx_id: u32,
910}
911
912/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
913/// if the responder is dropped without sending a response, so that the client
914/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
915impl std::ops::Drop for DomainControllerGetMaxFrequencyResponder {
916    fn drop(&mut self) {
917        self.control_handle.shutdown();
918        // Safety: drops once, never accessed again
919        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
920    }
921}
922
923impl fidl::endpoints::Responder for DomainControllerGetMaxFrequencyResponder {
924    type ControlHandle = DomainControllerControlHandle;
925
926    fn control_handle(&self) -> &DomainControllerControlHandle {
927        &self.control_handle
928    }
929
930    fn drop_without_shutdown(mut self) {
931        // Safety: drops once, never accessed again due to mem::forget
932        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
933        // Prevent Drop from running (which would shut down the channel)
934        std::mem::forget(self);
935    }
936}
937
938impl DomainControllerGetMaxFrequencyResponder {
939    /// Sends a response to the FIDL transaction.
940    ///
941    /// Sets the channel to shutdown if an error occurs.
942    pub fn send(self, mut result: Result<u64, GetMaxFrequencyError>) -> Result<(), fidl::Error> {
943        let _result = self.send_raw(result);
944        if _result.is_err() {
945            self.control_handle.shutdown();
946        }
947        self.drop_without_shutdown();
948        _result
949    }
950
951    /// Similar to "send" but does not shutdown the channel if an error occurs.
952    pub fn send_no_shutdown_on_err(
953        self,
954        mut result: Result<u64, GetMaxFrequencyError>,
955    ) -> Result<(), fidl::Error> {
956        let _result = self.send_raw(result);
957        self.drop_without_shutdown();
958        _result
959    }
960
961    fn send_raw(&self, mut result: Result<u64, GetMaxFrequencyError>) -> Result<(), fidl::Error> {
962        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
963            DomainControllerGetMaxFrequencyResponse,
964            GetMaxFrequencyError,
965        >>(
966            fidl::encoding::FlexibleResult::new(
967                result.map(|max_frequency_index| (max_frequency_index,)),
968            ),
969            self.tx_id,
970            0x6c8cc16cbd270f62,
971            fidl::encoding::DynamicFlags::FLEXIBLE,
972        )
973    }
974}
975
976#[must_use = "FIDL methods require a response to be sent"]
977#[derive(Debug)]
978pub struct DomainControllerSetMaxFrequencyResponder {
979    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
980    tx_id: u32,
981}
982
983/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
984/// if the responder is dropped without sending a response, so that the client
985/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
986impl std::ops::Drop for DomainControllerSetMaxFrequencyResponder {
987    fn drop(&mut self) {
988        self.control_handle.shutdown();
989        // Safety: drops once, never accessed again
990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
991    }
992}
993
994impl fidl::endpoints::Responder for DomainControllerSetMaxFrequencyResponder {
995    type ControlHandle = DomainControllerControlHandle;
996
997    fn control_handle(&self) -> &DomainControllerControlHandle {
998        &self.control_handle
999    }
1000
1001    fn drop_without_shutdown(mut self) {
1002        // Safety: drops once, never accessed again due to mem::forget
1003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1004        // Prevent Drop from running (which would shut down the channel)
1005        std::mem::forget(self);
1006    }
1007}
1008
1009impl DomainControllerSetMaxFrequencyResponder {
1010    /// Sends a response to the FIDL transaction.
1011    ///
1012    /// Sets the channel to shutdown if an error occurs.
1013    pub fn send(self, mut result: Result<(), SetMaxFrequencyError>) -> Result<(), fidl::Error> {
1014        let _result = self.send_raw(result);
1015        if _result.is_err() {
1016            self.control_handle.shutdown();
1017        }
1018        self.drop_without_shutdown();
1019        _result
1020    }
1021
1022    /// Similar to "send" but does not shutdown the channel if an error occurs.
1023    pub fn send_no_shutdown_on_err(
1024        self,
1025        mut result: Result<(), SetMaxFrequencyError>,
1026    ) -> Result<(), fidl::Error> {
1027        let _result = self.send_raw(result);
1028        self.drop_without_shutdown();
1029        _result
1030    }
1031
1032    fn send_raw(&self, mut result: Result<(), SetMaxFrequencyError>) -> Result<(), fidl::Error> {
1033        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1034            fidl::encoding::EmptyStruct,
1035            SetMaxFrequencyError,
1036        >>(
1037            fidl::encoding::FlexibleResult::new(result),
1038            self.tx_id,
1039            0x427d7a45e538939e,
1040            fidl::encoding::DynamicFlags::FLEXIBLE,
1041        )
1042    }
1043}
1044
1045#[must_use = "FIDL methods require a response to be sent"]
1046#[derive(Debug)]
1047pub struct DomainControllerClearMaxFrequencyResponder {
1048    control_handle: std::mem::ManuallyDrop<DomainControllerControlHandle>,
1049    tx_id: u32,
1050}
1051
1052/// Set the the channel to be shutdown (see [`DomainControllerControlHandle::shutdown`])
1053/// if the responder is dropped without sending a response, so that the client
1054/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1055impl std::ops::Drop for DomainControllerClearMaxFrequencyResponder {
1056    fn drop(&mut self) {
1057        self.control_handle.shutdown();
1058        // Safety: drops once, never accessed again
1059        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1060    }
1061}
1062
1063impl fidl::endpoints::Responder for DomainControllerClearMaxFrequencyResponder {
1064    type ControlHandle = DomainControllerControlHandle;
1065
1066    fn control_handle(&self) -> &DomainControllerControlHandle {
1067        &self.control_handle
1068    }
1069
1070    fn drop_without_shutdown(mut self) {
1071        // Safety: drops once, never accessed again due to mem::forget
1072        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1073        // Prevent Drop from running (which would shut down the channel)
1074        std::mem::forget(self);
1075    }
1076}
1077
1078impl DomainControllerClearMaxFrequencyResponder {
1079    /// Sends a response to the FIDL transaction.
1080    ///
1081    /// Sets the channel to shutdown if an error occurs.
1082    pub fn send(self, mut result: Result<(), ClearMaxFrequencyError>) -> Result<(), fidl::Error> {
1083        let _result = self.send_raw(result);
1084        if _result.is_err() {
1085            self.control_handle.shutdown();
1086        }
1087        self.drop_without_shutdown();
1088        _result
1089    }
1090
1091    /// Similar to "send" but does not shutdown the channel if an error occurs.
1092    pub fn send_no_shutdown_on_err(
1093        self,
1094        mut result: Result<(), ClearMaxFrequencyError>,
1095    ) -> Result<(), fidl::Error> {
1096        let _result = self.send_raw(result);
1097        self.drop_without_shutdown();
1098        _result
1099    }
1100
1101    fn send_raw(&self, mut result: Result<(), ClearMaxFrequencyError>) -> Result<(), fidl::Error> {
1102        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1103            fidl::encoding::EmptyStruct,
1104            ClearMaxFrequencyError,
1105        >>(
1106            fidl::encoding::FlexibleResult::new(result),
1107            self.tx_id,
1108            0x738116a31e202ba5,
1109            fidl::encoding::DynamicFlags::FLEXIBLE,
1110        )
1111    }
1112}
1113
1114mod internal {
1115    use super::*;
1116}