fidl_fuchsia_power_system/
fidl_fuchsia_power_system.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_system_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14pub type LeaseToken = fidl::EventPair;
15
16#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct ActivityGovernorAcquireWakeLeaseResponse {
18    /// The token that blocks hardware platform suspension.
19    pub token: fidl::EventPair,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23    for ActivityGovernorAcquireWakeLeaseResponse
24{
25}
26
27#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct ActivityGovernorTakeApplicationActivityLeaseResponse {
29    /// The token that blocks application activity from dropping below the
30    /// 'Active' state.
31    pub token: fidl::EventPair,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
35    for ActivityGovernorTakeApplicationActivityLeaseResponse
36{
37}
38
39#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct ActivityGovernorTakeWakeLeaseResponse {
41    /// The token that blocks hardware platform suspension.
42    pub token: fidl::EventPair,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
46    for ActivityGovernorTakeWakeLeaseResponse
47{
48}
49
50#[derive(Debug, Default, PartialEq)]
51pub struct ActivityGovernorRegisterListenerRequest {
52    /// The client end of the service that receives activity governor events.
53    ///
54    /// Required.
55    pub listener: Option<fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>>,
56    #[doc(hidden)]
57    pub __source_breaking: fidl::marker::SourceBreaking,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61    for ActivityGovernorRegisterListenerRequest
62{
63}
64
65/// Holds tokens to the application activity power element.
66///
67/// [`fuchsia.power.system/ApplicationActivityLevel`] defines the power levels supported by this power element.
68#[derive(Debug, Default, PartialEq)]
69pub struct ApplicationActivity {
70    pub assertive_dependency_token: Option<fidl::Event>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ApplicationActivity {}
76
77/// Holds tokens to the CPU power element.
78///
79/// [`fuchsia.power.system/CpuLevel`] defines the power levels supported by this power element.
80#[derive(Debug, Default, PartialEq)]
81pub struct Cpu {
82    pub assertive_dependency_token: Option<fidl::Event>,
83    #[doc(hidden)]
84    pub __source_breaking: fidl::marker::SourceBreaking,
85}
86
87impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {}
88
89#[derive(Debug, Default, PartialEq)]
90pub struct CpuElementManagerAddExecutionStateDependencyRequest {
91    /// The assertive dependency token representing the target power element
92    /// of the dependency.
93    /// Required.
94    pub dependency_token: Option<fidl::Event>,
95    /// The power level of the target power element.
96    /// Required.
97    pub power_level: Option<u8>,
98    #[doc(hidden)]
99    pub __source_breaking: fidl::marker::SourceBreaking,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
103    for CpuElementManagerAddExecutionStateDependencyRequest
104{
105}
106
107/// Holds a token to the execution state power element.
108///
109/// Power elements intentionally cannot take assertive dependencies on this power
110/// element. Elements that need to force the execution state to ACTIVE can use
111/// ApplicationActivity which provides more semantic meaning to the
112/// dependencies.
113///
114/// [`fuchsia.power.system/ExecutionStateLevel`] defines the power levels supported by this power element.
115#[derive(Debug, Default, PartialEq)]
116pub struct ExecutionState {
117    pub opportunistic_dependency_token: Option<fidl::Event>,
118    #[doc(hidden)]
119    pub __source_breaking: fidl::marker::SourceBreaking,
120}
121
122impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ExecutionState {}
123
124/// A collection of power elements that are managed by the activity governor.
125#[derive(Debug, Default, PartialEq)]
126pub struct PowerElements {
127    pub execution_state: Option<ExecutionState>,
128    pub application_activity: Option<ApplicationActivity>,
129    #[doc(hidden)]
130    pub __source_breaking: fidl::marker::SourceBreaking,
131}
132
133impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {}
134
135#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
136pub struct ActivityGovernorMarker;
137
138impl fidl::endpoints::ProtocolMarker for ActivityGovernorMarker {
139    type Proxy = ActivityGovernorProxy;
140    type RequestStream = ActivityGovernorRequestStream;
141    #[cfg(target_os = "fuchsia")]
142    type SynchronousProxy = ActivityGovernorSynchronousProxy;
143
144    const DEBUG_NAME: &'static str = "fuchsia.power.system.ActivityGovernor";
145}
146impl fidl::endpoints::DiscoverableProtocolMarker for ActivityGovernorMarker {}
147pub type ActivityGovernorAcquireWakeLeaseResult = Result<fidl::EventPair, AcquireWakeLeaseError>;
148
149pub trait ActivityGovernorProxyInterface: Send + Sync {
150    type GetPowerElementsResponseFut: std::future::Future<Output = Result<PowerElements, fidl::Error>>
151        + Send;
152    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut;
153    type TakeWakeLeaseResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
154        + Send;
155    fn r#take_wake_lease(&self, name: &str) -> Self::TakeWakeLeaseResponseFut;
156    type AcquireWakeLeaseResponseFut: std::future::Future<Output = Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error>>
157        + Send;
158    fn r#acquire_wake_lease(&self, name: &str) -> Self::AcquireWakeLeaseResponseFut;
159    type TakeApplicationActivityLeaseResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
160        + Send;
161    fn r#take_application_activity_lease(
162        &self,
163        name: &str,
164    ) -> Self::TakeApplicationActivityLeaseResponseFut;
165    type RegisterListenerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
166    fn r#register_listener(
167        &self,
168        payload: ActivityGovernorRegisterListenerRequest,
169    ) -> Self::RegisterListenerResponseFut;
170}
171#[derive(Debug)]
172#[cfg(target_os = "fuchsia")]
173pub struct ActivityGovernorSynchronousProxy {
174    client: fidl::client::sync::Client,
175}
176
177#[cfg(target_os = "fuchsia")]
178impl fidl::endpoints::SynchronousProxy for ActivityGovernorSynchronousProxy {
179    type Proxy = ActivityGovernorProxy;
180    type Protocol = ActivityGovernorMarker;
181
182    fn from_channel(inner: fidl::Channel) -> Self {
183        Self::new(inner)
184    }
185
186    fn into_channel(self) -> fidl::Channel {
187        self.client.into_channel()
188    }
189
190    fn as_channel(&self) -> &fidl::Channel {
191        self.client.as_channel()
192    }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl ActivityGovernorSynchronousProxy {
197    pub fn new(channel: fidl::Channel) -> Self {
198        let protocol_name = <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
199        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
200    }
201
202    pub fn into_channel(self) -> fidl::Channel {
203        self.client.into_channel()
204    }
205
206    /// Waits until an event arrives and returns it. It is safe for other
207    /// threads to make concurrent requests while waiting for an event.
208    pub fn wait_for_event(
209        &self,
210        deadline: zx::MonotonicInstant,
211    ) -> Result<ActivityGovernorEvent, fidl::Error> {
212        ActivityGovernorEvent::decode(self.client.wait_for_event(deadline)?)
213    }
214
215    /// Gets the power elements owned by the activity governor.
216    ///
217    /// If an error occurs while the server is registering a power element with
218    /// the power broker or an error occurs while creating a token for a power
219    /// element, then the channel to `ActivityGovernor` will be closed by the
220    /// server and no response will be returned.
221    pub fn r#get_power_elements(
222        &self,
223        ___deadline: zx::MonotonicInstant,
224    ) -> Result<PowerElements, fidl::Error> {
225        let _response = self.client.send_query::<
226            fidl::encoding::EmptyPayload,
227            fidl::encoding::FlexibleType<PowerElements>,
228        >(
229            (),
230            0x798003259dfb5672,
231            fidl::encoding::DynamicFlags::FLEXIBLE,
232            ___deadline,
233        )?
234        .into_result::<ActivityGovernorMarker>("get_power_elements")?;
235        Ok(_response)
236    }
237
238    /// Creates a lease that blocks suspension of the hardware platform.
239    ///
240    /// The hardware platform will not suspend as long as a valid
241    /// [`LeaseToken`] exists.
242    ///
243    /// If an error occurs while creating a token for the wake lease, then the
244    /// channel to `ActivityGovernor` will be closed by the server and no
245    /// response will be returned.
246    pub fn r#take_wake_lease(
247        &self,
248        mut name: &str,
249        ___deadline: zx::MonotonicInstant,
250    ) -> Result<fidl::EventPair, fidl::Error> {
251        let _response = self.client.send_query::<
252            ActivityGovernorTakeWakeLeaseRequest,
253            fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>,
254        >(
255            (name,),
256            0x291cfb42b2d3bf69,
257            fidl::encoding::DynamicFlags::FLEXIBLE,
258            ___deadline,
259        )?
260        .into_result::<ActivityGovernorMarker>("take_wake_lease")?;
261        Ok(_response.token)
262    }
263
264    /// Creates a lease that blocks suspension of the hardware platform.
265    ///
266    /// The hardware platform will not suspend as long as a valid
267    /// [`LeaseToken`] exists.
268    pub fn r#acquire_wake_lease(
269        &self,
270        mut name: &str,
271        ___deadline: zx::MonotonicInstant,
272    ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
273        let _response = self.client.send_query::<
274            ActivityGovernorAcquireWakeLeaseRequest,
275            fidl::encoding::FlexibleResultType<ActivityGovernorAcquireWakeLeaseResponse, AcquireWakeLeaseError>,
276        >(
277            (name,),
278            0x2de25abd8fa7c103,
279            fidl::encoding::DynamicFlags::FLEXIBLE,
280            ___deadline,
281        )?
282        .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
283        Ok(_response.map(|x| x.token))
284    }
285
286    /// Creates a lease that blocks the system from dropping below the Application
287    /// Activity 'Active' state. In particular, this blocks suspension of the
288    /// hardware platform.
289    ///
290    /// This method is _not_ safe to call during
291    /// ActivityGovernorListener.OnSuspendStarted.
292    ///
293    /// If an error occurs while creating a token for the activity lease, then the
294    /// channel to `ActivityGovernor` will be closed by the server and no
295    /// response will be returned.
296    pub fn r#take_application_activity_lease(
297        &self,
298        mut name: &str,
299        ___deadline: zx::MonotonicInstant,
300    ) -> Result<fidl::EventPair, fidl::Error> {
301        let _response = self.client.send_query::<
302            ActivityGovernorTakeApplicationActivityLeaseRequest,
303            fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
304        >(
305            (name,),
306            0x37cd5364de7ada14,
307            fidl::encoding::DynamicFlags::FLEXIBLE,
308            ___deadline,
309        )?
310        .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
311        Ok(_response.token)
312    }
313
314    /// Registers a listener for activity governor events.
315    ///
316    /// If there is an error in registering the listener, then the given
317    /// `ActivityGovernorListener` channel will be closed before the response
318    /// is sent.
319    ///
320    /// To unregister, close the `ActivityGovernorListener` channel.
321    pub fn r#register_listener(
322        &self,
323        mut payload: ActivityGovernorRegisterListenerRequest,
324        ___deadline: zx::MonotonicInstant,
325    ) -> Result<(), fidl::Error> {
326        let _response = self.client.send_query::<
327            ActivityGovernorRegisterListenerRequest,
328            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
329        >(
330            &mut payload,
331            0x836144d0722e5c1,
332            fidl::encoding::DynamicFlags::FLEXIBLE,
333            ___deadline,
334        )?
335        .into_result::<ActivityGovernorMarker>("register_listener")?;
336        Ok(_response)
337    }
338}
339
340#[cfg(target_os = "fuchsia")]
341impl From<ActivityGovernorSynchronousProxy> for zx::Handle {
342    fn from(value: ActivityGovernorSynchronousProxy) -> Self {
343        value.into_channel().into()
344    }
345}
346
347#[cfg(target_os = "fuchsia")]
348impl From<fidl::Channel> for ActivityGovernorSynchronousProxy {
349    fn from(value: fidl::Channel) -> Self {
350        Self::new(value)
351    }
352}
353
354#[derive(Debug, Clone)]
355pub struct ActivityGovernorProxy {
356    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
357}
358
359impl fidl::endpoints::Proxy for ActivityGovernorProxy {
360    type Protocol = ActivityGovernorMarker;
361
362    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
363        Self::new(inner)
364    }
365
366    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
367        self.client.into_channel().map_err(|client| Self { client })
368    }
369
370    fn as_channel(&self) -> &::fidl::AsyncChannel {
371        self.client.as_channel()
372    }
373}
374
375impl ActivityGovernorProxy {
376    /// Create a new Proxy for fuchsia.power.system/ActivityGovernor.
377    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
378        let protocol_name = <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
379        Self { client: fidl::client::Client::new(channel, protocol_name) }
380    }
381
382    /// Get a Stream of events from the remote end of the protocol.
383    ///
384    /// # Panics
385    ///
386    /// Panics if the event stream was already taken.
387    pub fn take_event_stream(&self) -> ActivityGovernorEventStream {
388        ActivityGovernorEventStream { event_receiver: self.client.take_event_receiver() }
389    }
390
391    /// Gets the power elements owned by the activity governor.
392    ///
393    /// If an error occurs while the server is registering a power element with
394    /// the power broker or an error occurs while creating a token for a power
395    /// element, then the channel to `ActivityGovernor` will be closed by the
396    /// server and no response will be returned.
397    pub fn r#get_power_elements(
398        &self,
399    ) -> fidl::client::QueryResponseFut<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
400    {
401        ActivityGovernorProxyInterface::r#get_power_elements(self)
402    }
403
404    /// Creates a lease that blocks suspension of the hardware platform.
405    ///
406    /// The hardware platform will not suspend as long as a valid
407    /// [`LeaseToken`] exists.
408    ///
409    /// If an error occurs while creating a token for the wake lease, then the
410    /// channel to `ActivityGovernor` will be closed by the server and no
411    /// response will be returned.
412    pub fn r#take_wake_lease(
413        &self,
414        mut name: &str,
415    ) -> fidl::client::QueryResponseFut<
416        fidl::EventPair,
417        fidl::encoding::DefaultFuchsiaResourceDialect,
418    > {
419        ActivityGovernorProxyInterface::r#take_wake_lease(self, name)
420    }
421
422    /// Creates a lease that blocks suspension of the hardware platform.
423    ///
424    /// The hardware platform will not suspend as long as a valid
425    /// [`LeaseToken`] exists.
426    pub fn r#acquire_wake_lease(
427        &self,
428        mut name: &str,
429    ) -> fidl::client::QueryResponseFut<
430        ActivityGovernorAcquireWakeLeaseResult,
431        fidl::encoding::DefaultFuchsiaResourceDialect,
432    > {
433        ActivityGovernorProxyInterface::r#acquire_wake_lease(self, name)
434    }
435
436    /// Creates a lease that blocks the system from dropping below the Application
437    /// Activity 'Active' state. In particular, this blocks suspension of the
438    /// hardware platform.
439    ///
440    /// This method is _not_ safe to call during
441    /// ActivityGovernorListener.OnSuspendStarted.
442    ///
443    /// If an error occurs while creating a token for the activity lease, then the
444    /// channel to `ActivityGovernor` will be closed by the server and no
445    /// response will be returned.
446    pub fn r#take_application_activity_lease(
447        &self,
448        mut name: &str,
449    ) -> fidl::client::QueryResponseFut<
450        fidl::EventPair,
451        fidl::encoding::DefaultFuchsiaResourceDialect,
452    > {
453        ActivityGovernorProxyInterface::r#take_application_activity_lease(self, name)
454    }
455
456    /// Registers a listener for activity governor events.
457    ///
458    /// If there is an error in registering the listener, then the given
459    /// `ActivityGovernorListener` channel will be closed before the response
460    /// is sent.
461    ///
462    /// To unregister, close the `ActivityGovernorListener` channel.
463    pub fn r#register_listener(
464        &self,
465        mut payload: ActivityGovernorRegisterListenerRequest,
466    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
467        ActivityGovernorProxyInterface::r#register_listener(self, payload)
468    }
469}
470
471impl ActivityGovernorProxyInterface for ActivityGovernorProxy {
472    type GetPowerElementsResponseFut = fidl::client::QueryResponseFut<
473        PowerElements,
474        fidl::encoding::DefaultFuchsiaResourceDialect,
475    >;
476    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut {
477        fn _decode(
478            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
479        ) -> Result<PowerElements, fidl::Error> {
480            let _response = fidl::client::decode_transaction_body::<
481                fidl::encoding::FlexibleType<PowerElements>,
482                fidl::encoding::DefaultFuchsiaResourceDialect,
483                0x798003259dfb5672,
484            >(_buf?)?
485            .into_result::<ActivityGovernorMarker>("get_power_elements")?;
486            Ok(_response)
487        }
488        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PowerElements>(
489            (),
490            0x798003259dfb5672,
491            fidl::encoding::DynamicFlags::FLEXIBLE,
492            _decode,
493        )
494    }
495
496    type TakeWakeLeaseResponseFut = fidl::client::QueryResponseFut<
497        fidl::EventPair,
498        fidl::encoding::DefaultFuchsiaResourceDialect,
499    >;
500    fn r#take_wake_lease(&self, mut name: &str) -> Self::TakeWakeLeaseResponseFut {
501        fn _decode(
502            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
503        ) -> Result<fidl::EventPair, fidl::Error> {
504            let _response = fidl::client::decode_transaction_body::<
505                fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>,
506                fidl::encoding::DefaultFuchsiaResourceDialect,
507                0x291cfb42b2d3bf69,
508            >(_buf?)?
509            .into_result::<ActivityGovernorMarker>("take_wake_lease")?;
510            Ok(_response.token)
511        }
512        self.client.send_query_and_decode::<ActivityGovernorTakeWakeLeaseRequest, fidl::EventPair>(
513            (name,),
514            0x291cfb42b2d3bf69,
515            fidl::encoding::DynamicFlags::FLEXIBLE,
516            _decode,
517        )
518    }
519
520    type AcquireWakeLeaseResponseFut = fidl::client::QueryResponseFut<
521        ActivityGovernorAcquireWakeLeaseResult,
522        fidl::encoding::DefaultFuchsiaResourceDialect,
523    >;
524    fn r#acquire_wake_lease(&self, mut name: &str) -> Self::AcquireWakeLeaseResponseFut {
525        fn _decode(
526            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
527        ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
528            let _response = fidl::client::decode_transaction_body::<
529                fidl::encoding::FlexibleResultType<
530                    ActivityGovernorAcquireWakeLeaseResponse,
531                    AcquireWakeLeaseError,
532                >,
533                fidl::encoding::DefaultFuchsiaResourceDialect,
534                0x2de25abd8fa7c103,
535            >(_buf?)?
536            .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
537            Ok(_response.map(|x| x.token))
538        }
539        self.client.send_query_and_decode::<
540            ActivityGovernorAcquireWakeLeaseRequest,
541            ActivityGovernorAcquireWakeLeaseResult,
542        >(
543            (name,),
544            0x2de25abd8fa7c103,
545            fidl::encoding::DynamicFlags::FLEXIBLE,
546            _decode,
547        )
548    }
549
550    type TakeApplicationActivityLeaseResponseFut = fidl::client::QueryResponseFut<
551        fidl::EventPair,
552        fidl::encoding::DefaultFuchsiaResourceDialect,
553    >;
554    fn r#take_application_activity_lease(
555        &self,
556        mut name: &str,
557    ) -> Self::TakeApplicationActivityLeaseResponseFut {
558        fn _decode(
559            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
560        ) -> Result<fidl::EventPair, fidl::Error> {
561            let _response = fidl::client::decode_transaction_body::<
562                fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
563                fidl::encoding::DefaultFuchsiaResourceDialect,
564                0x37cd5364de7ada14,
565            >(_buf?)?
566            .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
567            Ok(_response.token)
568        }
569        self.client.send_query_and_decode::<
570            ActivityGovernorTakeApplicationActivityLeaseRequest,
571            fidl::EventPair,
572        >(
573            (name,),
574            0x37cd5364de7ada14,
575            fidl::encoding::DynamicFlags::FLEXIBLE,
576            _decode,
577        )
578    }
579
580    type RegisterListenerResponseFut =
581        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
582    fn r#register_listener(
583        &self,
584        mut payload: ActivityGovernorRegisterListenerRequest,
585    ) -> Self::RegisterListenerResponseFut {
586        fn _decode(
587            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
588        ) -> Result<(), fidl::Error> {
589            let _response = fidl::client::decode_transaction_body::<
590                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
591                fidl::encoding::DefaultFuchsiaResourceDialect,
592                0x836144d0722e5c1,
593            >(_buf?)?
594            .into_result::<ActivityGovernorMarker>("register_listener")?;
595            Ok(_response)
596        }
597        self.client.send_query_and_decode::<ActivityGovernorRegisterListenerRequest, ()>(
598            &mut payload,
599            0x836144d0722e5c1,
600            fidl::encoding::DynamicFlags::FLEXIBLE,
601            _decode,
602        )
603    }
604}
605
606pub struct ActivityGovernorEventStream {
607    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
608}
609
610impl std::marker::Unpin for ActivityGovernorEventStream {}
611
612impl futures::stream::FusedStream for ActivityGovernorEventStream {
613    fn is_terminated(&self) -> bool {
614        self.event_receiver.is_terminated()
615    }
616}
617
618impl futures::Stream for ActivityGovernorEventStream {
619    type Item = Result<ActivityGovernorEvent, fidl::Error>;
620
621    fn poll_next(
622        mut self: std::pin::Pin<&mut Self>,
623        cx: &mut std::task::Context<'_>,
624    ) -> std::task::Poll<Option<Self::Item>> {
625        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
626            &mut self.event_receiver,
627            cx
628        )?) {
629            Some(buf) => std::task::Poll::Ready(Some(ActivityGovernorEvent::decode(buf))),
630            None => std::task::Poll::Ready(None),
631        }
632    }
633}
634
635#[derive(Debug)]
636pub enum ActivityGovernorEvent {
637    #[non_exhaustive]
638    _UnknownEvent {
639        /// Ordinal of the event that was sent.
640        ordinal: u64,
641    },
642}
643
644impl ActivityGovernorEvent {
645    /// Decodes a message buffer as a [`ActivityGovernorEvent`].
646    fn decode(
647        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
648    ) -> Result<ActivityGovernorEvent, fidl::Error> {
649        let (bytes, _handles) = buf.split_mut();
650        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
651        debug_assert_eq!(tx_header.tx_id, 0);
652        match tx_header.ordinal {
653            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
654                Ok(ActivityGovernorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
655            }
656            _ => Err(fidl::Error::UnknownOrdinal {
657                ordinal: tx_header.ordinal,
658                protocol_name:
659                    <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
660            }),
661        }
662    }
663}
664
665/// A Stream of incoming requests for fuchsia.power.system/ActivityGovernor.
666pub struct ActivityGovernorRequestStream {
667    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
668    is_terminated: bool,
669}
670
671impl std::marker::Unpin for ActivityGovernorRequestStream {}
672
673impl futures::stream::FusedStream for ActivityGovernorRequestStream {
674    fn is_terminated(&self) -> bool {
675        self.is_terminated
676    }
677}
678
679impl fidl::endpoints::RequestStream for ActivityGovernorRequestStream {
680    type Protocol = ActivityGovernorMarker;
681    type ControlHandle = ActivityGovernorControlHandle;
682
683    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
684        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
685    }
686
687    fn control_handle(&self) -> Self::ControlHandle {
688        ActivityGovernorControlHandle { inner: self.inner.clone() }
689    }
690
691    fn into_inner(
692        self,
693    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
694    {
695        (self.inner, self.is_terminated)
696    }
697
698    fn from_inner(
699        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
700        is_terminated: bool,
701    ) -> Self {
702        Self { inner, is_terminated }
703    }
704}
705
706impl futures::Stream for ActivityGovernorRequestStream {
707    type Item = Result<ActivityGovernorRequest, fidl::Error>;
708
709    fn poll_next(
710        mut self: std::pin::Pin<&mut Self>,
711        cx: &mut std::task::Context<'_>,
712    ) -> std::task::Poll<Option<Self::Item>> {
713        let this = &mut *self;
714        if this.inner.check_shutdown(cx) {
715            this.is_terminated = true;
716            return std::task::Poll::Ready(None);
717        }
718        if this.is_terminated {
719            panic!("polled ActivityGovernorRequestStream after completion");
720        }
721        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
722            |bytes, handles| {
723                match this.inner.channel().read_etc(cx, bytes, handles) {
724                    std::task::Poll::Ready(Ok(())) => {}
725                    std::task::Poll::Pending => return std::task::Poll::Pending,
726                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
727                        this.is_terminated = true;
728                        return std::task::Poll::Ready(None);
729                    }
730                    std::task::Poll::Ready(Err(e)) => {
731                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
732                            e.into(),
733                        ))))
734                    }
735                }
736
737                // A message has been received from the channel
738                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
739
740                std::task::Poll::Ready(Some(match header.ordinal {
741                    0x798003259dfb5672 => {
742                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
743                        let mut req = fidl::new_empty!(
744                            fidl::encoding::EmptyPayload,
745                            fidl::encoding::DefaultFuchsiaResourceDialect
746                        );
747                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
748                        let control_handle =
749                            ActivityGovernorControlHandle { inner: this.inner.clone() };
750                        Ok(ActivityGovernorRequest::GetPowerElements {
751                            responder: ActivityGovernorGetPowerElementsResponder {
752                                control_handle: std::mem::ManuallyDrop::new(control_handle),
753                                tx_id: header.tx_id,
754                            },
755                        })
756                    }
757                    0x291cfb42b2d3bf69 => {
758                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
759                        let mut req = fidl::new_empty!(
760                            ActivityGovernorTakeWakeLeaseRequest,
761                            fidl::encoding::DefaultFuchsiaResourceDialect
762                        );
763                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorTakeWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
764                        let control_handle =
765                            ActivityGovernorControlHandle { inner: this.inner.clone() };
766                        Ok(ActivityGovernorRequest::TakeWakeLease {
767                            name: req.name,
768
769                            responder: ActivityGovernorTakeWakeLeaseResponder {
770                                control_handle: std::mem::ManuallyDrop::new(control_handle),
771                                tx_id: header.tx_id,
772                            },
773                        })
774                    }
775                    0x2de25abd8fa7c103 => {
776                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
777                        let mut req = fidl::new_empty!(
778                            ActivityGovernorAcquireWakeLeaseRequest,
779                            fidl::encoding::DefaultFuchsiaResourceDialect
780                        );
781                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorAcquireWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
782                        let control_handle =
783                            ActivityGovernorControlHandle { inner: this.inner.clone() };
784                        Ok(ActivityGovernorRequest::AcquireWakeLease {
785                            name: req.name,
786
787                            responder: ActivityGovernorAcquireWakeLeaseResponder {
788                                control_handle: std::mem::ManuallyDrop::new(control_handle),
789                                tx_id: header.tx_id,
790                            },
791                        })
792                    }
793                    0x37cd5364de7ada14 => {
794                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
795                        let mut req = fidl::new_empty!(
796                            ActivityGovernorTakeApplicationActivityLeaseRequest,
797                            fidl::encoding::DefaultFuchsiaResourceDialect
798                        );
799                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorTakeApplicationActivityLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
800                        let control_handle =
801                            ActivityGovernorControlHandle { inner: this.inner.clone() };
802                        Ok(ActivityGovernorRequest::TakeApplicationActivityLease {
803                            name: req.name,
804
805                            responder: ActivityGovernorTakeApplicationActivityLeaseResponder {
806                                control_handle: std::mem::ManuallyDrop::new(control_handle),
807                                tx_id: header.tx_id,
808                            },
809                        })
810                    }
811                    0x836144d0722e5c1 => {
812                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
813                        let mut req = fidl::new_empty!(
814                            ActivityGovernorRegisterListenerRequest,
815                            fidl::encoding::DefaultFuchsiaResourceDialect
816                        );
817                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
818                        let control_handle =
819                            ActivityGovernorControlHandle { inner: this.inner.clone() };
820                        Ok(ActivityGovernorRequest::RegisterListener {
821                            payload: req,
822                            responder: ActivityGovernorRegisterListenerResponder {
823                                control_handle: std::mem::ManuallyDrop::new(control_handle),
824                                tx_id: header.tx_id,
825                            },
826                        })
827                    }
828                    _ if header.tx_id == 0
829                        && header
830                            .dynamic_flags()
831                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
832                    {
833                        Ok(ActivityGovernorRequest::_UnknownMethod {
834                            ordinal: header.ordinal,
835                            control_handle: ActivityGovernorControlHandle {
836                                inner: this.inner.clone(),
837                            },
838                            method_type: fidl::MethodType::OneWay,
839                        })
840                    }
841                    _ if header
842                        .dynamic_flags()
843                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
844                    {
845                        this.inner.send_framework_err(
846                            fidl::encoding::FrameworkErr::UnknownMethod,
847                            header.tx_id,
848                            header.ordinal,
849                            header.dynamic_flags(),
850                            (bytes, handles),
851                        )?;
852                        Ok(ActivityGovernorRequest::_UnknownMethod {
853                            ordinal: header.ordinal,
854                            control_handle: ActivityGovernorControlHandle {
855                                inner: this.inner.clone(),
856                            },
857                            method_type: fidl::MethodType::TwoWay,
858                        })
859                    }
860                    _ => Err(fidl::Error::UnknownOrdinal {
861                        ordinal: header.ordinal,
862                        protocol_name:
863                            <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
864                    }),
865                }))
866            },
867        )
868    }
869}
870
871/// A service for exposing events and power elements managed by the system
872/// activity governor (SAG).
873///
874/// SAG is responsible for managing the execution state of the hardware
875/// platform. The hardware platform consists of the components required to
876/// execute code on the device. This typically includes the CPU, memory,
877/// operating system, and other components required for these components to
878/// function (clock trees, power domains, etc.).
879#[derive(Debug)]
880pub enum ActivityGovernorRequest {
881    /// Gets the power elements owned by the activity governor.
882    ///
883    /// If an error occurs while the server is registering a power element with
884    /// the power broker or an error occurs while creating a token for a power
885    /// element, then the channel to `ActivityGovernor` will be closed by the
886    /// server and no response will be returned.
887    GetPowerElements { responder: ActivityGovernorGetPowerElementsResponder },
888    /// Creates a lease that blocks suspension of the hardware platform.
889    ///
890    /// The hardware platform will not suspend as long as a valid
891    /// [`LeaseToken`] exists.
892    ///
893    /// If an error occurs while creating a token for the wake lease, then the
894    /// channel to `ActivityGovernor` will be closed by the server and no
895    /// response will be returned.
896    TakeWakeLease { name: String, responder: ActivityGovernorTakeWakeLeaseResponder },
897    /// Creates a lease that blocks suspension of the hardware platform.
898    ///
899    /// The hardware platform will not suspend as long as a valid
900    /// [`LeaseToken`] exists.
901    AcquireWakeLease { name: String, responder: ActivityGovernorAcquireWakeLeaseResponder },
902    /// Creates a lease that blocks the system from dropping below the Application
903    /// Activity 'Active' state. In particular, this blocks suspension of the
904    /// hardware platform.
905    ///
906    /// This method is _not_ safe to call during
907    /// ActivityGovernorListener.OnSuspendStarted.
908    ///
909    /// If an error occurs while creating a token for the activity lease, then the
910    /// channel to `ActivityGovernor` will be closed by the server and no
911    /// response will be returned.
912    TakeApplicationActivityLease {
913        name: String,
914        responder: ActivityGovernorTakeApplicationActivityLeaseResponder,
915    },
916    /// Registers a listener for activity governor events.
917    ///
918    /// If there is an error in registering the listener, then the given
919    /// `ActivityGovernorListener` channel will be closed before the response
920    /// is sent.
921    ///
922    /// To unregister, close the `ActivityGovernorListener` channel.
923    RegisterListener {
924        payload: ActivityGovernorRegisterListenerRequest,
925        responder: ActivityGovernorRegisterListenerResponder,
926    },
927    /// An interaction was received which does not match any known method.
928    #[non_exhaustive]
929    _UnknownMethod {
930        /// Ordinal of the method that was called.
931        ordinal: u64,
932        control_handle: ActivityGovernorControlHandle,
933        method_type: fidl::MethodType,
934    },
935}
936
937impl ActivityGovernorRequest {
938    #[allow(irrefutable_let_patterns)]
939    pub fn into_get_power_elements(self) -> Option<(ActivityGovernorGetPowerElementsResponder)> {
940        if let ActivityGovernorRequest::GetPowerElements { responder } = self {
941            Some((responder))
942        } else {
943            None
944        }
945    }
946
947    #[allow(irrefutable_let_patterns)]
948    pub fn into_take_wake_lease(self) -> Option<(String, ActivityGovernorTakeWakeLeaseResponder)> {
949        if let ActivityGovernorRequest::TakeWakeLease { name, responder } = self {
950            Some((name, responder))
951        } else {
952            None
953        }
954    }
955
956    #[allow(irrefutable_let_patterns)]
957    pub fn into_acquire_wake_lease(
958        self,
959    ) -> Option<(String, ActivityGovernorAcquireWakeLeaseResponder)> {
960        if let ActivityGovernorRequest::AcquireWakeLease { name, responder } = self {
961            Some((name, responder))
962        } else {
963            None
964        }
965    }
966
967    #[allow(irrefutable_let_patterns)]
968    pub fn into_take_application_activity_lease(
969        self,
970    ) -> Option<(String, ActivityGovernorTakeApplicationActivityLeaseResponder)> {
971        if let ActivityGovernorRequest::TakeApplicationActivityLease { name, responder } = self {
972            Some((name, responder))
973        } else {
974            None
975        }
976    }
977
978    #[allow(irrefutable_let_patterns)]
979    pub fn into_register_listener(
980        self,
981    ) -> Option<(ActivityGovernorRegisterListenerRequest, ActivityGovernorRegisterListenerResponder)>
982    {
983        if let ActivityGovernorRequest::RegisterListener { payload, responder } = self {
984            Some((payload, responder))
985        } else {
986            None
987        }
988    }
989
990    /// Name of the method defined in FIDL
991    pub fn method_name(&self) -> &'static str {
992        match *self {
993            ActivityGovernorRequest::GetPowerElements { .. } => "get_power_elements",
994            ActivityGovernorRequest::TakeWakeLease { .. } => "take_wake_lease",
995            ActivityGovernorRequest::AcquireWakeLease { .. } => "acquire_wake_lease",
996            ActivityGovernorRequest::TakeApplicationActivityLease { .. } => {
997                "take_application_activity_lease"
998            }
999            ActivityGovernorRequest::RegisterListener { .. } => "register_listener",
1000            ActivityGovernorRequest::_UnknownMethod {
1001                method_type: fidl::MethodType::OneWay,
1002                ..
1003            } => "unknown one-way method",
1004            ActivityGovernorRequest::_UnknownMethod {
1005                method_type: fidl::MethodType::TwoWay,
1006                ..
1007            } => "unknown two-way method",
1008        }
1009    }
1010}
1011
1012#[derive(Debug, Clone)]
1013pub struct ActivityGovernorControlHandle {
1014    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1015}
1016
1017impl fidl::endpoints::ControlHandle for ActivityGovernorControlHandle {
1018    fn shutdown(&self) {
1019        self.inner.shutdown()
1020    }
1021    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1022        self.inner.shutdown_with_epitaph(status)
1023    }
1024
1025    fn is_closed(&self) -> bool {
1026        self.inner.channel().is_closed()
1027    }
1028    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1029        self.inner.channel().on_closed()
1030    }
1031
1032    #[cfg(target_os = "fuchsia")]
1033    fn signal_peer(
1034        &self,
1035        clear_mask: zx::Signals,
1036        set_mask: zx::Signals,
1037    ) -> Result<(), zx_status::Status> {
1038        use fidl::Peered;
1039        self.inner.channel().signal_peer(clear_mask, set_mask)
1040    }
1041}
1042
1043impl ActivityGovernorControlHandle {}
1044
1045#[must_use = "FIDL methods require a response to be sent"]
1046#[derive(Debug)]
1047pub struct ActivityGovernorGetPowerElementsResponder {
1048    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1049    tx_id: u32,
1050}
1051
1052/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::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 ActivityGovernorGetPowerElementsResponder {
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 ActivityGovernorGetPowerElementsResponder {
1064    type ControlHandle = ActivityGovernorControlHandle;
1065
1066    fn control_handle(&self) -> &ActivityGovernorControlHandle {
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 ActivityGovernorGetPowerElementsResponder {
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 payload: PowerElements) -> Result<(), fidl::Error> {
1083        let _result = self.send_raw(payload);
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(self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1093        let _result = self.send_raw(payload);
1094        self.drop_without_shutdown();
1095        _result
1096    }
1097
1098    fn send_raw(&self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1099        self.control_handle.inner.send::<fidl::encoding::FlexibleType<PowerElements>>(
1100            fidl::encoding::Flexible::new(&mut payload),
1101            self.tx_id,
1102            0x798003259dfb5672,
1103            fidl::encoding::DynamicFlags::FLEXIBLE,
1104        )
1105    }
1106}
1107
1108#[must_use = "FIDL methods require a response to be sent"]
1109#[derive(Debug)]
1110pub struct ActivityGovernorTakeWakeLeaseResponder {
1111    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1112    tx_id: u32,
1113}
1114
1115/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1116/// if the responder is dropped without sending a response, so that the client
1117/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1118impl std::ops::Drop for ActivityGovernorTakeWakeLeaseResponder {
1119    fn drop(&mut self) {
1120        self.control_handle.shutdown();
1121        // Safety: drops once, never accessed again
1122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1123    }
1124}
1125
1126impl fidl::endpoints::Responder for ActivityGovernorTakeWakeLeaseResponder {
1127    type ControlHandle = ActivityGovernorControlHandle;
1128
1129    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1130        &self.control_handle
1131    }
1132
1133    fn drop_without_shutdown(mut self) {
1134        // Safety: drops once, never accessed again due to mem::forget
1135        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1136        // Prevent Drop from running (which would shut down the channel)
1137        std::mem::forget(self);
1138    }
1139}
1140
1141impl ActivityGovernorTakeWakeLeaseResponder {
1142    /// Sends a response to the FIDL transaction.
1143    ///
1144    /// Sets the channel to shutdown if an error occurs.
1145    pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1146        let _result = self.send_raw(token);
1147        if _result.is_err() {
1148            self.control_handle.shutdown();
1149        }
1150        self.drop_without_shutdown();
1151        _result
1152    }
1153
1154    /// Similar to "send" but does not shutdown the channel if an error occurs.
1155    pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1156        let _result = self.send_raw(token);
1157        self.drop_without_shutdown();
1158        _result
1159    }
1160
1161    fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1162        self.control_handle
1163            .inner
1164            .send::<fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>>(
1165                fidl::encoding::Flexible::new((token,)),
1166                self.tx_id,
1167                0x291cfb42b2d3bf69,
1168                fidl::encoding::DynamicFlags::FLEXIBLE,
1169            )
1170    }
1171}
1172
1173#[must_use = "FIDL methods require a response to be sent"]
1174#[derive(Debug)]
1175pub struct ActivityGovernorAcquireWakeLeaseResponder {
1176    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1177    tx_id: u32,
1178}
1179
1180/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1181/// if the responder is dropped without sending a response, so that the client
1182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1183impl std::ops::Drop for ActivityGovernorAcquireWakeLeaseResponder {
1184    fn drop(&mut self) {
1185        self.control_handle.shutdown();
1186        // Safety: drops once, never accessed again
1187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1188    }
1189}
1190
1191impl fidl::endpoints::Responder for ActivityGovernorAcquireWakeLeaseResponder {
1192    type ControlHandle = ActivityGovernorControlHandle;
1193
1194    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1195        &self.control_handle
1196    }
1197
1198    fn drop_without_shutdown(mut self) {
1199        // Safety: drops once, never accessed again due to mem::forget
1200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1201        // Prevent Drop from running (which would shut down the channel)
1202        std::mem::forget(self);
1203    }
1204}
1205
1206impl ActivityGovernorAcquireWakeLeaseResponder {
1207    /// Sends a response to the FIDL transaction.
1208    ///
1209    /// Sets the channel to shutdown if an error occurs.
1210    pub fn send(
1211        self,
1212        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1213    ) -> Result<(), fidl::Error> {
1214        let _result = self.send_raw(result);
1215        if _result.is_err() {
1216            self.control_handle.shutdown();
1217        }
1218        self.drop_without_shutdown();
1219        _result
1220    }
1221
1222    /// Similar to "send" but does not shutdown the channel if an error occurs.
1223    pub fn send_no_shutdown_on_err(
1224        self,
1225        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1226    ) -> Result<(), fidl::Error> {
1227        let _result = self.send_raw(result);
1228        self.drop_without_shutdown();
1229        _result
1230    }
1231
1232    fn send_raw(
1233        &self,
1234        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1235    ) -> Result<(), fidl::Error> {
1236        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1237            ActivityGovernorAcquireWakeLeaseResponse,
1238            AcquireWakeLeaseError,
1239        >>(
1240            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1241            self.tx_id,
1242            0x2de25abd8fa7c103,
1243            fidl::encoding::DynamicFlags::FLEXIBLE,
1244        )
1245    }
1246}
1247
1248#[must_use = "FIDL methods require a response to be sent"]
1249#[derive(Debug)]
1250pub struct ActivityGovernorTakeApplicationActivityLeaseResponder {
1251    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1252    tx_id: u32,
1253}
1254
1255/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1256/// if the responder is dropped without sending a response, so that the client
1257/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1258impl std::ops::Drop for ActivityGovernorTakeApplicationActivityLeaseResponder {
1259    fn drop(&mut self) {
1260        self.control_handle.shutdown();
1261        // Safety: drops once, never accessed again
1262        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1263    }
1264}
1265
1266impl fidl::endpoints::Responder for ActivityGovernorTakeApplicationActivityLeaseResponder {
1267    type ControlHandle = ActivityGovernorControlHandle;
1268
1269    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1270        &self.control_handle
1271    }
1272
1273    fn drop_without_shutdown(mut self) {
1274        // Safety: drops once, never accessed again due to mem::forget
1275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1276        // Prevent Drop from running (which would shut down the channel)
1277        std::mem::forget(self);
1278    }
1279}
1280
1281impl ActivityGovernorTakeApplicationActivityLeaseResponder {
1282    /// Sends a response to the FIDL transaction.
1283    ///
1284    /// Sets the channel to shutdown if an error occurs.
1285    pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1286        let _result = self.send_raw(token);
1287        if _result.is_err() {
1288            self.control_handle.shutdown();
1289        }
1290        self.drop_without_shutdown();
1291        _result
1292    }
1293
1294    /// Similar to "send" but does not shutdown the channel if an error occurs.
1295    pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1296        let _result = self.send_raw(token);
1297        self.drop_without_shutdown();
1298        _result
1299    }
1300
1301    fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1302        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1303            ActivityGovernorTakeApplicationActivityLeaseResponse,
1304        >>(
1305            fidl::encoding::Flexible::new((token,)),
1306            self.tx_id,
1307            0x37cd5364de7ada14,
1308            fidl::encoding::DynamicFlags::FLEXIBLE,
1309        )
1310    }
1311}
1312
1313#[must_use = "FIDL methods require a response to be sent"]
1314#[derive(Debug)]
1315pub struct ActivityGovernorRegisterListenerResponder {
1316    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1317    tx_id: u32,
1318}
1319
1320/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1321/// if the responder is dropped without sending a response, so that the client
1322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1323impl std::ops::Drop for ActivityGovernorRegisterListenerResponder {
1324    fn drop(&mut self) {
1325        self.control_handle.shutdown();
1326        // Safety: drops once, never accessed again
1327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1328    }
1329}
1330
1331impl fidl::endpoints::Responder for ActivityGovernorRegisterListenerResponder {
1332    type ControlHandle = ActivityGovernorControlHandle;
1333
1334    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1335        &self.control_handle
1336    }
1337
1338    fn drop_without_shutdown(mut self) {
1339        // Safety: drops once, never accessed again due to mem::forget
1340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1341        // Prevent Drop from running (which would shut down the channel)
1342        std::mem::forget(self);
1343    }
1344}
1345
1346impl ActivityGovernorRegisterListenerResponder {
1347    /// Sends a response to the FIDL transaction.
1348    ///
1349    /// Sets the channel to shutdown if an error occurs.
1350    pub fn send(self) -> Result<(), fidl::Error> {
1351        let _result = self.send_raw();
1352        if _result.is_err() {
1353            self.control_handle.shutdown();
1354        }
1355        self.drop_without_shutdown();
1356        _result
1357    }
1358
1359    /// Similar to "send" but does not shutdown the channel if an error occurs.
1360    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1361        let _result = self.send_raw();
1362        self.drop_without_shutdown();
1363        _result
1364    }
1365
1366    fn send_raw(&self) -> Result<(), fidl::Error> {
1367        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1368            fidl::encoding::Flexible::new(()),
1369            self.tx_id,
1370            0x836144d0722e5c1,
1371            fidl::encoding::DynamicFlags::FLEXIBLE,
1372        )
1373    }
1374}
1375
1376#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1377pub struct ActivityGovernorListenerMarker;
1378
1379impl fidl::endpoints::ProtocolMarker for ActivityGovernorListenerMarker {
1380    type Proxy = ActivityGovernorListenerProxy;
1381    type RequestStream = ActivityGovernorListenerRequestStream;
1382    #[cfg(target_os = "fuchsia")]
1383    type SynchronousProxy = ActivityGovernorListenerSynchronousProxy;
1384
1385    const DEBUG_NAME: &'static str = "(anonymous) ActivityGovernorListener";
1386}
1387
1388pub trait ActivityGovernorListenerProxyInterface: Send + Sync {
1389    type OnResumeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1390    fn r#on_resume(&self) -> Self::OnResumeResponseFut;
1391    type OnSuspendStartedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1392    fn r#on_suspend_started(&self) -> Self::OnSuspendStartedResponseFut;
1393}
1394#[derive(Debug)]
1395#[cfg(target_os = "fuchsia")]
1396pub struct ActivityGovernorListenerSynchronousProxy {
1397    client: fidl::client::sync::Client,
1398}
1399
1400#[cfg(target_os = "fuchsia")]
1401impl fidl::endpoints::SynchronousProxy for ActivityGovernorListenerSynchronousProxy {
1402    type Proxy = ActivityGovernorListenerProxy;
1403    type Protocol = ActivityGovernorListenerMarker;
1404
1405    fn from_channel(inner: fidl::Channel) -> Self {
1406        Self::new(inner)
1407    }
1408
1409    fn into_channel(self) -> fidl::Channel {
1410        self.client.into_channel()
1411    }
1412
1413    fn as_channel(&self) -> &fidl::Channel {
1414        self.client.as_channel()
1415    }
1416}
1417
1418#[cfg(target_os = "fuchsia")]
1419impl ActivityGovernorListenerSynchronousProxy {
1420    pub fn new(channel: fidl::Channel) -> Self {
1421        let protocol_name =
1422            <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1423        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1424    }
1425
1426    pub fn into_channel(self) -> fidl::Channel {
1427        self.client.into_channel()
1428    }
1429
1430    /// Waits until an event arrives and returns it. It is safe for other
1431    /// threads to make concurrent requests while waiting for an event.
1432    pub fn wait_for_event(
1433        &self,
1434        deadline: zx::MonotonicInstant,
1435    ) -> Result<ActivityGovernorListenerEvent, fidl::Error> {
1436        ActivityGovernorListenerEvent::decode(self.client.wait_for_event(deadline)?)
1437    }
1438
1439    /// Called when the activity governor detects a system resume.
1440    ///
1441    /// This is only called when the wakeup reason returned by the platform
1442    /// requires a full system resume. All dependencies of
1443    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
1444    /// this call is issued, and the listener's OnSuspendStarted method will be
1445    /// invoked before that guarantee is removed.
1446    ///
1447    /// SAG does not block on the response to this method, so the listener may
1448    /// safely take actions that block on raising Execution State's power level.
1449    /// In particular, it is not affected by https://fxbug.dev/391429689.
1450    pub fn r#on_resume(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1451        let _response =
1452            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1453                (),
1454                0x5b48f847154cfd48,
1455                fidl::encoding::DynamicFlags::empty(),
1456                ___deadline,
1457            )?;
1458        Ok(_response)
1459    }
1460
1461    /// Called before the activity governor initiates a system suspension.
1462    ///
1463    /// The server is expected to respond once it has performed the operations
1464    /// it needs to prepare itself for suspend, if any. All dependencies of
1465    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
1466    /// duration of this call.
1467    ///
1468    /// It is not safe for this method to call
1469    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
1470    /// other action that blocks on raising Execution State above its Inactive
1471    /// level. (However, AcquireWakeLease does _not_ block in this way and is
1472    /// safe to call.) Doing so will currently result in a deadlock. This
1473    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
1474    pub fn r#on_suspend_started(
1475        &self,
1476        ___deadline: zx::MonotonicInstant,
1477    ) -> Result<(), fidl::Error> {
1478        let _response = self.client.send_query::<
1479            fidl::encoding::EmptyPayload,
1480            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1481        >(
1482            (),
1483            0x5858cc3412a8eabf,
1484            fidl::encoding::DynamicFlags::FLEXIBLE,
1485            ___deadline,
1486        )?
1487        .into_result::<ActivityGovernorListenerMarker>("on_suspend_started")?;
1488        Ok(_response)
1489    }
1490}
1491
1492#[cfg(target_os = "fuchsia")]
1493impl From<ActivityGovernorListenerSynchronousProxy> for zx::Handle {
1494    fn from(value: ActivityGovernorListenerSynchronousProxy) -> Self {
1495        value.into_channel().into()
1496    }
1497}
1498
1499#[cfg(target_os = "fuchsia")]
1500impl From<fidl::Channel> for ActivityGovernorListenerSynchronousProxy {
1501    fn from(value: fidl::Channel) -> Self {
1502        Self::new(value)
1503    }
1504}
1505
1506#[derive(Debug, Clone)]
1507pub struct ActivityGovernorListenerProxy {
1508    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1509}
1510
1511impl fidl::endpoints::Proxy for ActivityGovernorListenerProxy {
1512    type Protocol = ActivityGovernorListenerMarker;
1513
1514    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1515        Self::new(inner)
1516    }
1517
1518    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1519        self.client.into_channel().map_err(|client| Self { client })
1520    }
1521
1522    fn as_channel(&self) -> &::fidl::AsyncChannel {
1523        self.client.as_channel()
1524    }
1525}
1526
1527impl ActivityGovernorListenerProxy {
1528    /// Create a new Proxy for fuchsia.power.system/ActivityGovernorListener.
1529    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1530        let protocol_name =
1531            <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1532        Self { client: fidl::client::Client::new(channel, protocol_name) }
1533    }
1534
1535    /// Get a Stream of events from the remote end of the protocol.
1536    ///
1537    /// # Panics
1538    ///
1539    /// Panics if the event stream was already taken.
1540    pub fn take_event_stream(&self) -> ActivityGovernorListenerEventStream {
1541        ActivityGovernorListenerEventStream { event_receiver: self.client.take_event_receiver() }
1542    }
1543
1544    /// Called when the activity governor detects a system resume.
1545    ///
1546    /// This is only called when the wakeup reason returned by the platform
1547    /// requires a full system resume. All dependencies of
1548    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
1549    /// this call is issued, and the listener's OnSuspendStarted method will be
1550    /// invoked before that guarantee is removed.
1551    ///
1552    /// SAG does not block on the response to this method, so the listener may
1553    /// safely take actions that block on raising Execution State's power level.
1554    /// In particular, it is not affected by https://fxbug.dev/391429689.
1555    pub fn r#on_resume(
1556        &self,
1557    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1558        ActivityGovernorListenerProxyInterface::r#on_resume(self)
1559    }
1560
1561    /// Called before the activity governor initiates a system suspension.
1562    ///
1563    /// The server is expected to respond once it has performed the operations
1564    /// it needs to prepare itself for suspend, if any. All dependencies of
1565    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
1566    /// duration of this call.
1567    ///
1568    /// It is not safe for this method to call
1569    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
1570    /// other action that blocks on raising Execution State above its Inactive
1571    /// level. (However, AcquireWakeLease does _not_ block in this way and is
1572    /// safe to call.) Doing so will currently result in a deadlock. This
1573    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
1574    pub fn r#on_suspend_started(
1575        &self,
1576    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1577        ActivityGovernorListenerProxyInterface::r#on_suspend_started(self)
1578    }
1579}
1580
1581impl ActivityGovernorListenerProxyInterface for ActivityGovernorListenerProxy {
1582    type OnResumeResponseFut =
1583        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1584    fn r#on_resume(&self) -> Self::OnResumeResponseFut {
1585        fn _decode(
1586            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1587        ) -> Result<(), fidl::Error> {
1588            let _response = fidl::client::decode_transaction_body::<
1589                fidl::encoding::EmptyPayload,
1590                fidl::encoding::DefaultFuchsiaResourceDialect,
1591                0x5b48f847154cfd48,
1592            >(_buf?)?;
1593            Ok(_response)
1594        }
1595        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1596            (),
1597            0x5b48f847154cfd48,
1598            fidl::encoding::DynamicFlags::empty(),
1599            _decode,
1600        )
1601    }
1602
1603    type OnSuspendStartedResponseFut =
1604        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1605    fn r#on_suspend_started(&self) -> Self::OnSuspendStartedResponseFut {
1606        fn _decode(
1607            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1608        ) -> Result<(), fidl::Error> {
1609            let _response = fidl::client::decode_transaction_body::<
1610                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1611                fidl::encoding::DefaultFuchsiaResourceDialect,
1612                0x5858cc3412a8eabf,
1613            >(_buf?)?
1614            .into_result::<ActivityGovernorListenerMarker>("on_suspend_started")?;
1615            Ok(_response)
1616        }
1617        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1618            (),
1619            0x5858cc3412a8eabf,
1620            fidl::encoding::DynamicFlags::FLEXIBLE,
1621            _decode,
1622        )
1623    }
1624}
1625
1626pub struct ActivityGovernorListenerEventStream {
1627    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1628}
1629
1630impl std::marker::Unpin for ActivityGovernorListenerEventStream {}
1631
1632impl futures::stream::FusedStream for ActivityGovernorListenerEventStream {
1633    fn is_terminated(&self) -> bool {
1634        self.event_receiver.is_terminated()
1635    }
1636}
1637
1638impl futures::Stream for ActivityGovernorListenerEventStream {
1639    type Item = Result<ActivityGovernorListenerEvent, fidl::Error>;
1640
1641    fn poll_next(
1642        mut self: std::pin::Pin<&mut Self>,
1643        cx: &mut std::task::Context<'_>,
1644    ) -> std::task::Poll<Option<Self::Item>> {
1645        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1646            &mut self.event_receiver,
1647            cx
1648        )?) {
1649            Some(buf) => std::task::Poll::Ready(Some(ActivityGovernorListenerEvent::decode(buf))),
1650            None => std::task::Poll::Ready(None),
1651        }
1652    }
1653}
1654
1655#[derive(Debug)]
1656pub enum ActivityGovernorListenerEvent {
1657    #[non_exhaustive]
1658    _UnknownEvent {
1659        /// Ordinal of the event that was sent.
1660        ordinal: u64,
1661    },
1662}
1663
1664impl ActivityGovernorListenerEvent {
1665    /// Decodes a message buffer as a [`ActivityGovernorListenerEvent`].
1666    fn decode(
1667        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1668    ) -> Result<ActivityGovernorListenerEvent, fidl::Error> {
1669        let (bytes, _handles) = buf.split_mut();
1670        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1671        debug_assert_eq!(tx_header.tx_id, 0);
1672        match tx_header.ordinal {
1673            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1674                Ok(ActivityGovernorListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1675            }
1676            _ => Err(fidl::Error::UnknownOrdinal {
1677                ordinal: tx_header.ordinal,
1678                protocol_name:
1679                    <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1680            }),
1681        }
1682    }
1683}
1684
1685/// A Stream of incoming requests for fuchsia.power.system/ActivityGovernorListener.
1686pub struct ActivityGovernorListenerRequestStream {
1687    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1688    is_terminated: bool,
1689}
1690
1691impl std::marker::Unpin for ActivityGovernorListenerRequestStream {}
1692
1693impl futures::stream::FusedStream for ActivityGovernorListenerRequestStream {
1694    fn is_terminated(&self) -> bool {
1695        self.is_terminated
1696    }
1697}
1698
1699impl fidl::endpoints::RequestStream for ActivityGovernorListenerRequestStream {
1700    type Protocol = ActivityGovernorListenerMarker;
1701    type ControlHandle = ActivityGovernorListenerControlHandle;
1702
1703    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1704        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1705    }
1706
1707    fn control_handle(&self) -> Self::ControlHandle {
1708        ActivityGovernorListenerControlHandle { inner: self.inner.clone() }
1709    }
1710
1711    fn into_inner(
1712        self,
1713    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1714    {
1715        (self.inner, self.is_terminated)
1716    }
1717
1718    fn from_inner(
1719        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1720        is_terminated: bool,
1721    ) -> Self {
1722        Self { inner, is_terminated }
1723    }
1724}
1725
1726impl futures::Stream for ActivityGovernorListenerRequestStream {
1727    type Item = Result<ActivityGovernorListenerRequest, fidl::Error>;
1728
1729    fn poll_next(
1730        mut self: std::pin::Pin<&mut Self>,
1731        cx: &mut std::task::Context<'_>,
1732    ) -> std::task::Poll<Option<Self::Item>> {
1733        let this = &mut *self;
1734        if this.inner.check_shutdown(cx) {
1735            this.is_terminated = true;
1736            return std::task::Poll::Ready(None);
1737        }
1738        if this.is_terminated {
1739            panic!("polled ActivityGovernorListenerRequestStream after completion");
1740        }
1741        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1742            |bytes, handles| {
1743                match this.inner.channel().read_etc(cx, bytes, handles) {
1744                    std::task::Poll::Ready(Ok(())) => {}
1745                    std::task::Poll::Pending => return std::task::Poll::Pending,
1746                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1747                        this.is_terminated = true;
1748                        return std::task::Poll::Ready(None);
1749                    }
1750                    std::task::Poll::Ready(Err(e)) => {
1751                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1752                            e.into(),
1753                        ))))
1754                    }
1755                }
1756
1757                // A message has been received from the channel
1758                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1759
1760                std::task::Poll::Ready(Some(match header.ordinal {
1761                0x5b48f847154cfd48 => {
1762                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1763                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1764                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1765                    let control_handle = ActivityGovernorListenerControlHandle {
1766                        inner: this.inner.clone(),
1767                    };
1768                    Ok(ActivityGovernorListenerRequest::OnResume {
1769                        responder: ActivityGovernorListenerOnResumeResponder {
1770                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1771                            tx_id: header.tx_id,
1772                        },
1773                    })
1774                }
1775                0x5858cc3412a8eabf => {
1776                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1777                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1778                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1779                    let control_handle = ActivityGovernorListenerControlHandle {
1780                        inner: this.inner.clone(),
1781                    };
1782                    Ok(ActivityGovernorListenerRequest::OnSuspendStarted {
1783                        responder: ActivityGovernorListenerOnSuspendStartedResponder {
1784                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1785                            tx_id: header.tx_id,
1786                        },
1787                    })
1788                }
1789                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1790                    Ok(ActivityGovernorListenerRequest::_UnknownMethod {
1791                        ordinal: header.ordinal,
1792                        control_handle: ActivityGovernorListenerControlHandle { inner: this.inner.clone() },
1793                        method_type: fidl::MethodType::OneWay,
1794                    })
1795                }
1796                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1797                    this.inner.send_framework_err(
1798                        fidl::encoding::FrameworkErr::UnknownMethod,
1799                        header.tx_id,
1800                        header.ordinal,
1801                        header.dynamic_flags(),
1802                        (bytes, handles),
1803                    )?;
1804                    Ok(ActivityGovernorListenerRequest::_UnknownMethod {
1805                        ordinal: header.ordinal,
1806                        control_handle: ActivityGovernorListenerControlHandle { inner: this.inner.clone() },
1807                        method_type: fidl::MethodType::TwoWay,
1808                    })
1809                }
1810                _ => Err(fidl::Error::UnknownOrdinal {
1811                    ordinal: header.ordinal,
1812                    protocol_name: <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1813                }),
1814            }))
1815            },
1816        )
1817    }
1818}
1819
1820/// A listener for activity governor events.
1821#[derive(Debug)]
1822pub enum ActivityGovernorListenerRequest {
1823    /// Called when the activity governor detects a system resume.
1824    ///
1825    /// This is only called when the wakeup reason returned by the platform
1826    /// requires a full system resume. All dependencies of
1827    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
1828    /// this call is issued, and the listener's OnSuspendStarted method will be
1829    /// invoked before that guarantee is removed.
1830    ///
1831    /// SAG does not block on the response to this method, so the listener may
1832    /// safely take actions that block on raising Execution State's power level.
1833    /// In particular, it is not affected by https://fxbug.dev/391429689.
1834    OnResume { responder: ActivityGovernorListenerOnResumeResponder },
1835    /// Called before the activity governor initiates a system suspension.
1836    ///
1837    /// The server is expected to respond once it has performed the operations
1838    /// it needs to prepare itself for suspend, if any. All dependencies of
1839    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
1840    /// duration of this call.
1841    ///
1842    /// It is not safe for this method to call
1843    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
1844    /// other action that blocks on raising Execution State above its Inactive
1845    /// level. (However, AcquireWakeLease does _not_ block in this way and is
1846    /// safe to call.) Doing so will currently result in a deadlock. This
1847    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
1848    OnSuspendStarted { responder: ActivityGovernorListenerOnSuspendStartedResponder },
1849    /// An interaction was received which does not match any known method.
1850    #[non_exhaustive]
1851    _UnknownMethod {
1852        /// Ordinal of the method that was called.
1853        ordinal: u64,
1854        control_handle: ActivityGovernorListenerControlHandle,
1855        method_type: fidl::MethodType,
1856    },
1857}
1858
1859impl ActivityGovernorListenerRequest {
1860    #[allow(irrefutable_let_patterns)]
1861    pub fn into_on_resume(self) -> Option<(ActivityGovernorListenerOnResumeResponder)> {
1862        if let ActivityGovernorListenerRequest::OnResume { responder } = self {
1863            Some((responder))
1864        } else {
1865            None
1866        }
1867    }
1868
1869    #[allow(irrefutable_let_patterns)]
1870    pub fn into_on_suspend_started(
1871        self,
1872    ) -> Option<(ActivityGovernorListenerOnSuspendStartedResponder)> {
1873        if let ActivityGovernorListenerRequest::OnSuspendStarted { responder } = self {
1874            Some((responder))
1875        } else {
1876            None
1877        }
1878    }
1879
1880    /// Name of the method defined in FIDL
1881    pub fn method_name(&self) -> &'static str {
1882        match *self {
1883            ActivityGovernorListenerRequest::OnResume { .. } => "on_resume",
1884            ActivityGovernorListenerRequest::OnSuspendStarted { .. } => "on_suspend_started",
1885            ActivityGovernorListenerRequest::_UnknownMethod {
1886                method_type: fidl::MethodType::OneWay,
1887                ..
1888            } => "unknown one-way method",
1889            ActivityGovernorListenerRequest::_UnknownMethod {
1890                method_type: fidl::MethodType::TwoWay,
1891                ..
1892            } => "unknown two-way method",
1893        }
1894    }
1895}
1896
1897#[derive(Debug, Clone)]
1898pub struct ActivityGovernorListenerControlHandle {
1899    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1900}
1901
1902impl fidl::endpoints::ControlHandle for ActivityGovernorListenerControlHandle {
1903    fn shutdown(&self) {
1904        self.inner.shutdown()
1905    }
1906    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1907        self.inner.shutdown_with_epitaph(status)
1908    }
1909
1910    fn is_closed(&self) -> bool {
1911        self.inner.channel().is_closed()
1912    }
1913    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1914        self.inner.channel().on_closed()
1915    }
1916
1917    #[cfg(target_os = "fuchsia")]
1918    fn signal_peer(
1919        &self,
1920        clear_mask: zx::Signals,
1921        set_mask: zx::Signals,
1922    ) -> Result<(), zx_status::Status> {
1923        use fidl::Peered;
1924        self.inner.channel().signal_peer(clear_mask, set_mask)
1925    }
1926}
1927
1928impl ActivityGovernorListenerControlHandle {}
1929
1930#[must_use = "FIDL methods require a response to be sent"]
1931#[derive(Debug)]
1932pub struct ActivityGovernorListenerOnResumeResponder {
1933    control_handle: std::mem::ManuallyDrop<ActivityGovernorListenerControlHandle>,
1934    tx_id: u32,
1935}
1936
1937/// Set the the channel to be shutdown (see [`ActivityGovernorListenerControlHandle::shutdown`])
1938/// if the responder is dropped without sending a response, so that the client
1939/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1940impl std::ops::Drop for ActivityGovernorListenerOnResumeResponder {
1941    fn drop(&mut self) {
1942        self.control_handle.shutdown();
1943        // Safety: drops once, never accessed again
1944        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1945    }
1946}
1947
1948impl fidl::endpoints::Responder for ActivityGovernorListenerOnResumeResponder {
1949    type ControlHandle = ActivityGovernorListenerControlHandle;
1950
1951    fn control_handle(&self) -> &ActivityGovernorListenerControlHandle {
1952        &self.control_handle
1953    }
1954
1955    fn drop_without_shutdown(mut self) {
1956        // Safety: drops once, never accessed again due to mem::forget
1957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1958        // Prevent Drop from running (which would shut down the channel)
1959        std::mem::forget(self);
1960    }
1961}
1962
1963impl ActivityGovernorListenerOnResumeResponder {
1964    /// Sends a response to the FIDL transaction.
1965    ///
1966    /// Sets the channel to shutdown if an error occurs.
1967    pub fn send(self) -> Result<(), fidl::Error> {
1968        let _result = self.send_raw();
1969        if _result.is_err() {
1970            self.control_handle.shutdown();
1971        }
1972        self.drop_without_shutdown();
1973        _result
1974    }
1975
1976    /// Similar to "send" but does not shutdown the channel if an error occurs.
1977    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1978        let _result = self.send_raw();
1979        self.drop_without_shutdown();
1980        _result
1981    }
1982
1983    fn send_raw(&self) -> Result<(), fidl::Error> {
1984        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1985            (),
1986            self.tx_id,
1987            0x5b48f847154cfd48,
1988            fidl::encoding::DynamicFlags::empty(),
1989        )
1990    }
1991}
1992
1993#[must_use = "FIDL methods require a response to be sent"]
1994#[derive(Debug)]
1995pub struct ActivityGovernorListenerOnSuspendStartedResponder {
1996    control_handle: std::mem::ManuallyDrop<ActivityGovernorListenerControlHandle>,
1997    tx_id: u32,
1998}
1999
2000/// Set the the channel to be shutdown (see [`ActivityGovernorListenerControlHandle::shutdown`])
2001/// if the responder is dropped without sending a response, so that the client
2002/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2003impl std::ops::Drop for ActivityGovernorListenerOnSuspendStartedResponder {
2004    fn drop(&mut self) {
2005        self.control_handle.shutdown();
2006        // Safety: drops once, never accessed again
2007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2008    }
2009}
2010
2011impl fidl::endpoints::Responder for ActivityGovernorListenerOnSuspendStartedResponder {
2012    type ControlHandle = ActivityGovernorListenerControlHandle;
2013
2014    fn control_handle(&self) -> &ActivityGovernorListenerControlHandle {
2015        &self.control_handle
2016    }
2017
2018    fn drop_without_shutdown(mut self) {
2019        // Safety: drops once, never accessed again due to mem::forget
2020        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2021        // Prevent Drop from running (which would shut down the channel)
2022        std::mem::forget(self);
2023    }
2024}
2025
2026impl ActivityGovernorListenerOnSuspendStartedResponder {
2027    /// Sends a response to the FIDL transaction.
2028    ///
2029    /// Sets the channel to shutdown if an error occurs.
2030    pub fn send(self) -> Result<(), fidl::Error> {
2031        let _result = self.send_raw();
2032        if _result.is_err() {
2033            self.control_handle.shutdown();
2034        }
2035        self.drop_without_shutdown();
2036        _result
2037    }
2038
2039    /// Similar to "send" but does not shutdown the channel if an error occurs.
2040    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2041        let _result = self.send_raw();
2042        self.drop_without_shutdown();
2043        _result
2044    }
2045
2046    fn send_raw(&self) -> Result<(), fidl::Error> {
2047        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2048            fidl::encoding::Flexible::new(()),
2049            self.tx_id,
2050            0x5858cc3412a8eabf,
2051            fidl::encoding::DynamicFlags::FLEXIBLE,
2052        )
2053    }
2054}
2055
2056#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2057pub struct BootControlMarker;
2058
2059impl fidl::endpoints::ProtocolMarker for BootControlMarker {
2060    type Proxy = BootControlProxy;
2061    type RequestStream = BootControlRequestStream;
2062    #[cfg(target_os = "fuchsia")]
2063    type SynchronousProxy = BootControlSynchronousProxy;
2064
2065    const DEBUG_NAME: &'static str = "fuchsia.power.system.BootControl";
2066}
2067impl fidl::endpoints::DiscoverableProtocolMarker for BootControlMarker {}
2068
2069pub trait BootControlProxyInterface: Send + Sync {
2070    type SetBootCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2071    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut;
2072}
2073#[derive(Debug)]
2074#[cfg(target_os = "fuchsia")]
2075pub struct BootControlSynchronousProxy {
2076    client: fidl::client::sync::Client,
2077}
2078
2079#[cfg(target_os = "fuchsia")]
2080impl fidl::endpoints::SynchronousProxy for BootControlSynchronousProxy {
2081    type Proxy = BootControlProxy;
2082    type Protocol = BootControlMarker;
2083
2084    fn from_channel(inner: fidl::Channel) -> Self {
2085        Self::new(inner)
2086    }
2087
2088    fn into_channel(self) -> fidl::Channel {
2089        self.client.into_channel()
2090    }
2091
2092    fn as_channel(&self) -> &fidl::Channel {
2093        self.client.as_channel()
2094    }
2095}
2096
2097#[cfg(target_os = "fuchsia")]
2098impl BootControlSynchronousProxy {
2099    pub fn new(channel: fidl::Channel) -> Self {
2100        let protocol_name = <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2101        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2102    }
2103
2104    pub fn into_channel(self) -> fidl::Channel {
2105        self.client.into_channel()
2106    }
2107
2108    /// Waits until an event arrives and returns it. It is safe for other
2109    /// threads to make concurrent requests while waiting for an event.
2110    pub fn wait_for_event(
2111        &self,
2112        deadline: zx::MonotonicInstant,
2113    ) -> Result<BootControlEvent, fidl::Error> {
2114        BootControlEvent::decode(self.client.wait_for_event(deadline)?)
2115    }
2116
2117    /// Notify the SAG that the system has booted. SAG will not suspend the
2118    /// hardware platform until this method is called at least once per boot.
2119    pub fn r#set_boot_complete(
2120        &self,
2121        ___deadline: zx::MonotonicInstant,
2122    ) -> Result<(), fidl::Error> {
2123        let _response = self.client.send_query::<
2124            fidl::encoding::EmptyPayload,
2125            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2126        >(
2127            (),
2128            0x3c9b9f24ad3ca2b5,
2129            fidl::encoding::DynamicFlags::FLEXIBLE,
2130            ___deadline,
2131        )?
2132        .into_result::<BootControlMarker>("set_boot_complete")?;
2133        Ok(_response)
2134    }
2135}
2136
2137#[cfg(target_os = "fuchsia")]
2138impl From<BootControlSynchronousProxy> for zx::Handle {
2139    fn from(value: BootControlSynchronousProxy) -> Self {
2140        value.into_channel().into()
2141    }
2142}
2143
2144#[cfg(target_os = "fuchsia")]
2145impl From<fidl::Channel> for BootControlSynchronousProxy {
2146    fn from(value: fidl::Channel) -> Self {
2147        Self::new(value)
2148    }
2149}
2150
2151#[derive(Debug, Clone)]
2152pub struct BootControlProxy {
2153    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2154}
2155
2156impl fidl::endpoints::Proxy for BootControlProxy {
2157    type Protocol = BootControlMarker;
2158
2159    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2160        Self::new(inner)
2161    }
2162
2163    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2164        self.client.into_channel().map_err(|client| Self { client })
2165    }
2166
2167    fn as_channel(&self) -> &::fidl::AsyncChannel {
2168        self.client.as_channel()
2169    }
2170}
2171
2172impl BootControlProxy {
2173    /// Create a new Proxy for fuchsia.power.system/BootControl.
2174    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2175        let protocol_name = <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2176        Self { client: fidl::client::Client::new(channel, protocol_name) }
2177    }
2178
2179    /// Get a Stream of events from the remote end of the protocol.
2180    ///
2181    /// # Panics
2182    ///
2183    /// Panics if the event stream was already taken.
2184    pub fn take_event_stream(&self) -> BootControlEventStream {
2185        BootControlEventStream { event_receiver: self.client.take_event_receiver() }
2186    }
2187
2188    /// Notify the SAG that the system has booted. SAG will not suspend the
2189    /// hardware platform until this method is called at least once per boot.
2190    pub fn r#set_boot_complete(
2191        &self,
2192    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2193        BootControlProxyInterface::r#set_boot_complete(self)
2194    }
2195}
2196
2197impl BootControlProxyInterface for BootControlProxy {
2198    type SetBootCompleteResponseFut =
2199        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2200    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut {
2201        fn _decode(
2202            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2203        ) -> Result<(), fidl::Error> {
2204            let _response = fidl::client::decode_transaction_body::<
2205                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2206                fidl::encoding::DefaultFuchsiaResourceDialect,
2207                0x3c9b9f24ad3ca2b5,
2208            >(_buf?)?
2209            .into_result::<BootControlMarker>("set_boot_complete")?;
2210            Ok(_response)
2211        }
2212        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2213            (),
2214            0x3c9b9f24ad3ca2b5,
2215            fidl::encoding::DynamicFlags::FLEXIBLE,
2216            _decode,
2217        )
2218    }
2219}
2220
2221pub struct BootControlEventStream {
2222    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2223}
2224
2225impl std::marker::Unpin for BootControlEventStream {}
2226
2227impl futures::stream::FusedStream for BootControlEventStream {
2228    fn is_terminated(&self) -> bool {
2229        self.event_receiver.is_terminated()
2230    }
2231}
2232
2233impl futures::Stream for BootControlEventStream {
2234    type Item = Result<BootControlEvent, fidl::Error>;
2235
2236    fn poll_next(
2237        mut self: std::pin::Pin<&mut Self>,
2238        cx: &mut std::task::Context<'_>,
2239    ) -> std::task::Poll<Option<Self::Item>> {
2240        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2241            &mut self.event_receiver,
2242            cx
2243        )?) {
2244            Some(buf) => std::task::Poll::Ready(Some(BootControlEvent::decode(buf))),
2245            None => std::task::Poll::Ready(None),
2246        }
2247    }
2248}
2249
2250#[derive(Debug)]
2251pub enum BootControlEvent {
2252    #[non_exhaustive]
2253    _UnknownEvent {
2254        /// Ordinal of the event that was sent.
2255        ordinal: u64,
2256    },
2257}
2258
2259impl BootControlEvent {
2260    /// Decodes a message buffer as a [`BootControlEvent`].
2261    fn decode(
2262        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2263    ) -> Result<BootControlEvent, fidl::Error> {
2264        let (bytes, _handles) = buf.split_mut();
2265        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2266        debug_assert_eq!(tx_header.tx_id, 0);
2267        match tx_header.ordinal {
2268            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2269                Ok(BootControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2270            }
2271            _ => Err(fidl::Error::UnknownOrdinal {
2272                ordinal: tx_header.ordinal,
2273                protocol_name: <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2274            }),
2275        }
2276    }
2277}
2278
2279/// A Stream of incoming requests for fuchsia.power.system/BootControl.
2280pub struct BootControlRequestStream {
2281    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2282    is_terminated: bool,
2283}
2284
2285impl std::marker::Unpin for BootControlRequestStream {}
2286
2287impl futures::stream::FusedStream for BootControlRequestStream {
2288    fn is_terminated(&self) -> bool {
2289        self.is_terminated
2290    }
2291}
2292
2293impl fidl::endpoints::RequestStream for BootControlRequestStream {
2294    type Protocol = BootControlMarker;
2295    type ControlHandle = BootControlControlHandle;
2296
2297    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2298        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2299    }
2300
2301    fn control_handle(&self) -> Self::ControlHandle {
2302        BootControlControlHandle { inner: self.inner.clone() }
2303    }
2304
2305    fn into_inner(
2306        self,
2307    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2308    {
2309        (self.inner, self.is_terminated)
2310    }
2311
2312    fn from_inner(
2313        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2314        is_terminated: bool,
2315    ) -> Self {
2316        Self { inner, is_terminated }
2317    }
2318}
2319
2320impl futures::Stream for BootControlRequestStream {
2321    type Item = Result<BootControlRequest, fidl::Error>;
2322
2323    fn poll_next(
2324        mut self: std::pin::Pin<&mut Self>,
2325        cx: &mut std::task::Context<'_>,
2326    ) -> std::task::Poll<Option<Self::Item>> {
2327        let this = &mut *self;
2328        if this.inner.check_shutdown(cx) {
2329            this.is_terminated = true;
2330            return std::task::Poll::Ready(None);
2331        }
2332        if this.is_terminated {
2333            panic!("polled BootControlRequestStream after completion");
2334        }
2335        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2336            |bytes, handles| {
2337                match this.inner.channel().read_etc(cx, bytes, handles) {
2338                    std::task::Poll::Ready(Ok(())) => {}
2339                    std::task::Poll::Pending => return std::task::Poll::Pending,
2340                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2341                        this.is_terminated = true;
2342                        return std::task::Poll::Ready(None);
2343                    }
2344                    std::task::Poll::Ready(Err(e)) => {
2345                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2346                            e.into(),
2347                        ))))
2348                    }
2349                }
2350
2351                // A message has been received from the channel
2352                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2353
2354                std::task::Poll::Ready(Some(match header.ordinal {
2355                    0x3c9b9f24ad3ca2b5 => {
2356                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2357                        let mut req = fidl::new_empty!(
2358                            fidl::encoding::EmptyPayload,
2359                            fidl::encoding::DefaultFuchsiaResourceDialect
2360                        );
2361                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2362                        let control_handle = BootControlControlHandle { inner: this.inner.clone() };
2363                        Ok(BootControlRequest::SetBootComplete {
2364                            responder: BootControlSetBootCompleteResponder {
2365                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2366                                tx_id: header.tx_id,
2367                            },
2368                        })
2369                    }
2370                    _ if header.tx_id == 0
2371                        && header
2372                            .dynamic_flags()
2373                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2374                    {
2375                        Ok(BootControlRequest::_UnknownMethod {
2376                            ordinal: header.ordinal,
2377                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2378                            method_type: fidl::MethodType::OneWay,
2379                        })
2380                    }
2381                    _ if header
2382                        .dynamic_flags()
2383                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2384                    {
2385                        this.inner.send_framework_err(
2386                            fidl::encoding::FrameworkErr::UnknownMethod,
2387                            header.tx_id,
2388                            header.ordinal,
2389                            header.dynamic_flags(),
2390                            (bytes, handles),
2391                        )?;
2392                        Ok(BootControlRequest::_UnknownMethod {
2393                            ordinal: header.ordinal,
2394                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2395                            method_type: fidl::MethodType::TwoWay,
2396                        })
2397                    }
2398                    _ => Err(fidl::Error::UnknownOrdinal {
2399                        ordinal: header.ordinal,
2400                        protocol_name:
2401                            <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2402                    }),
2403                }))
2404            },
2405        )
2406    }
2407}
2408
2409/// A service that processes notification about the system boot state.
2410#[derive(Debug)]
2411pub enum BootControlRequest {
2412    /// Notify the SAG that the system has booted. SAG will not suspend the
2413    /// hardware platform until this method is called at least once per boot.
2414    SetBootComplete { responder: BootControlSetBootCompleteResponder },
2415    /// An interaction was received which does not match any known method.
2416    #[non_exhaustive]
2417    _UnknownMethod {
2418        /// Ordinal of the method that was called.
2419        ordinal: u64,
2420        control_handle: BootControlControlHandle,
2421        method_type: fidl::MethodType,
2422    },
2423}
2424
2425impl BootControlRequest {
2426    #[allow(irrefutable_let_patterns)]
2427    pub fn into_set_boot_complete(self) -> Option<(BootControlSetBootCompleteResponder)> {
2428        if let BootControlRequest::SetBootComplete { responder } = self {
2429            Some((responder))
2430        } else {
2431            None
2432        }
2433    }
2434
2435    /// Name of the method defined in FIDL
2436    pub fn method_name(&self) -> &'static str {
2437        match *self {
2438            BootControlRequest::SetBootComplete { .. } => "set_boot_complete",
2439            BootControlRequest::_UnknownMethod {
2440                method_type: fidl::MethodType::OneWay, ..
2441            } => "unknown one-way method",
2442            BootControlRequest::_UnknownMethod {
2443                method_type: fidl::MethodType::TwoWay, ..
2444            } => "unknown two-way method",
2445        }
2446    }
2447}
2448
2449#[derive(Debug, Clone)]
2450pub struct BootControlControlHandle {
2451    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2452}
2453
2454impl fidl::endpoints::ControlHandle for BootControlControlHandle {
2455    fn shutdown(&self) {
2456        self.inner.shutdown()
2457    }
2458    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2459        self.inner.shutdown_with_epitaph(status)
2460    }
2461
2462    fn is_closed(&self) -> bool {
2463        self.inner.channel().is_closed()
2464    }
2465    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2466        self.inner.channel().on_closed()
2467    }
2468
2469    #[cfg(target_os = "fuchsia")]
2470    fn signal_peer(
2471        &self,
2472        clear_mask: zx::Signals,
2473        set_mask: zx::Signals,
2474    ) -> Result<(), zx_status::Status> {
2475        use fidl::Peered;
2476        self.inner.channel().signal_peer(clear_mask, set_mask)
2477    }
2478}
2479
2480impl BootControlControlHandle {}
2481
2482#[must_use = "FIDL methods require a response to be sent"]
2483#[derive(Debug)]
2484pub struct BootControlSetBootCompleteResponder {
2485    control_handle: std::mem::ManuallyDrop<BootControlControlHandle>,
2486    tx_id: u32,
2487}
2488
2489/// Set the the channel to be shutdown (see [`BootControlControlHandle::shutdown`])
2490/// if the responder is dropped without sending a response, so that the client
2491/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2492impl std::ops::Drop for BootControlSetBootCompleteResponder {
2493    fn drop(&mut self) {
2494        self.control_handle.shutdown();
2495        // Safety: drops once, never accessed again
2496        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2497    }
2498}
2499
2500impl fidl::endpoints::Responder for BootControlSetBootCompleteResponder {
2501    type ControlHandle = BootControlControlHandle;
2502
2503    fn control_handle(&self) -> &BootControlControlHandle {
2504        &self.control_handle
2505    }
2506
2507    fn drop_without_shutdown(mut self) {
2508        // Safety: drops once, never accessed again due to mem::forget
2509        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2510        // Prevent Drop from running (which would shut down the channel)
2511        std::mem::forget(self);
2512    }
2513}
2514
2515impl BootControlSetBootCompleteResponder {
2516    /// Sends a response to the FIDL transaction.
2517    ///
2518    /// Sets the channel to shutdown if an error occurs.
2519    pub fn send(self) -> Result<(), fidl::Error> {
2520        let _result = self.send_raw();
2521        if _result.is_err() {
2522            self.control_handle.shutdown();
2523        }
2524        self.drop_without_shutdown();
2525        _result
2526    }
2527
2528    /// Similar to "send" but does not shutdown the channel if an error occurs.
2529    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2530        let _result = self.send_raw();
2531        self.drop_without_shutdown();
2532        _result
2533    }
2534
2535    fn send_raw(&self) -> Result<(), fidl::Error> {
2536        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2537            fidl::encoding::Flexible::new(()),
2538            self.tx_id,
2539            0x3c9b9f24ad3ca2b5,
2540            fidl::encoding::DynamicFlags::FLEXIBLE,
2541        )
2542    }
2543}
2544
2545#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2546pub struct CpuElementManagerMarker;
2547
2548impl fidl::endpoints::ProtocolMarker for CpuElementManagerMarker {
2549    type Proxy = CpuElementManagerProxy;
2550    type RequestStream = CpuElementManagerRequestStream;
2551    #[cfg(target_os = "fuchsia")]
2552    type SynchronousProxy = CpuElementManagerSynchronousProxy;
2553
2554    const DEBUG_NAME: &'static str = "fuchsia.power.system.CpuElementManager";
2555}
2556impl fidl::endpoints::DiscoverableProtocolMarker for CpuElementManagerMarker {}
2557pub type CpuElementManagerAddExecutionStateDependencyResult =
2558    Result<(), AddExecutionStateDependencyError>;
2559
2560pub trait CpuElementManagerProxyInterface: Send + Sync {
2561    type GetCpuDependencyTokenResponseFut: std::future::Future<Output = Result<Cpu, fidl::Error>>
2562        + Send;
2563    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut;
2564    type AddExecutionStateDependencyResponseFut: std::future::Future<
2565            Output = Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error>,
2566        > + Send;
2567    fn r#add_execution_state_dependency(
2568        &self,
2569        payload: CpuElementManagerAddExecutionStateDependencyRequest,
2570    ) -> Self::AddExecutionStateDependencyResponseFut;
2571}
2572#[derive(Debug)]
2573#[cfg(target_os = "fuchsia")]
2574pub struct CpuElementManagerSynchronousProxy {
2575    client: fidl::client::sync::Client,
2576}
2577
2578#[cfg(target_os = "fuchsia")]
2579impl fidl::endpoints::SynchronousProxy for CpuElementManagerSynchronousProxy {
2580    type Proxy = CpuElementManagerProxy;
2581    type Protocol = CpuElementManagerMarker;
2582
2583    fn from_channel(inner: fidl::Channel) -> Self {
2584        Self::new(inner)
2585    }
2586
2587    fn into_channel(self) -> fidl::Channel {
2588        self.client.into_channel()
2589    }
2590
2591    fn as_channel(&self) -> &fidl::Channel {
2592        self.client.as_channel()
2593    }
2594}
2595
2596#[cfg(target_os = "fuchsia")]
2597impl CpuElementManagerSynchronousProxy {
2598    pub fn new(channel: fidl::Channel) -> Self {
2599        let protocol_name =
2600            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2601        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2602    }
2603
2604    pub fn into_channel(self) -> fidl::Channel {
2605        self.client.into_channel()
2606    }
2607
2608    /// Waits until an event arrives and returns it. It is safe for other
2609    /// threads to make concurrent requests while waiting for an event.
2610    pub fn wait_for_event(
2611        &self,
2612        deadline: zx::MonotonicInstant,
2613    ) -> Result<CpuElementManagerEvent, fidl::Error> {
2614        CpuElementManagerEvent::decode(self.client.wait_for_event(deadline)?)
2615    }
2616
2617    /// Gets the assertive dependency token for the CPU power element.
2618    pub fn r#get_cpu_dependency_token(
2619        &self,
2620        ___deadline: zx::MonotonicInstant,
2621    ) -> Result<Cpu, fidl::Error> {
2622        let _response = self
2623            .client
2624            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<Cpu>>(
2625                (),
2626                0x2c43645ed70344ba,
2627                fidl::encoding::DynamicFlags::FLEXIBLE,
2628                ___deadline,
2629            )?
2630            .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
2631        Ok(_response)
2632    }
2633
2634    /// Adds a dependency from the Execution State power element to the target
2635    /// power element identified by [`dependency_token`] at [`power_level`].
2636    ///
2637    /// Once the Execution State power element is created, future calls will
2638    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2639    /// and no changes to Execution State dependencies will be made.
2640    ///
2641    /// If any required entries in the request are missing, the server will
2642    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2643    pub fn r#add_execution_state_dependency(
2644        &self,
2645        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2646        ___deadline: zx::MonotonicInstant,
2647    ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
2648        let _response = self.client.send_query::<
2649            CpuElementManagerAddExecutionStateDependencyRequest,
2650            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, AddExecutionStateDependencyError>,
2651        >(
2652            &mut payload,
2653            0xdf2f5ea2af76234,
2654            fidl::encoding::DynamicFlags::FLEXIBLE,
2655            ___deadline,
2656        )?
2657        .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
2658        Ok(_response.map(|x| x))
2659    }
2660}
2661
2662#[cfg(target_os = "fuchsia")]
2663impl From<CpuElementManagerSynchronousProxy> for zx::Handle {
2664    fn from(value: CpuElementManagerSynchronousProxy) -> Self {
2665        value.into_channel().into()
2666    }
2667}
2668
2669#[cfg(target_os = "fuchsia")]
2670impl From<fidl::Channel> for CpuElementManagerSynchronousProxy {
2671    fn from(value: fidl::Channel) -> Self {
2672        Self::new(value)
2673    }
2674}
2675
2676#[derive(Debug, Clone)]
2677pub struct CpuElementManagerProxy {
2678    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2679}
2680
2681impl fidl::endpoints::Proxy for CpuElementManagerProxy {
2682    type Protocol = CpuElementManagerMarker;
2683
2684    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2685        Self::new(inner)
2686    }
2687
2688    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2689        self.client.into_channel().map_err(|client| Self { client })
2690    }
2691
2692    fn as_channel(&self) -> &::fidl::AsyncChannel {
2693        self.client.as_channel()
2694    }
2695}
2696
2697impl CpuElementManagerProxy {
2698    /// Create a new Proxy for fuchsia.power.system/CpuElementManager.
2699    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2700        let protocol_name =
2701            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2702        Self { client: fidl::client::Client::new(channel, protocol_name) }
2703    }
2704
2705    /// Get a Stream of events from the remote end of the protocol.
2706    ///
2707    /// # Panics
2708    ///
2709    /// Panics if the event stream was already taken.
2710    pub fn take_event_stream(&self) -> CpuElementManagerEventStream {
2711        CpuElementManagerEventStream { event_receiver: self.client.take_event_receiver() }
2712    }
2713
2714    /// Gets the assertive dependency token for the CPU power element.
2715    pub fn r#get_cpu_dependency_token(
2716        &self,
2717    ) -> fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect> {
2718        CpuElementManagerProxyInterface::r#get_cpu_dependency_token(self)
2719    }
2720
2721    /// Adds a dependency from the Execution State power element to the target
2722    /// power element identified by [`dependency_token`] at [`power_level`].
2723    ///
2724    /// Once the Execution State power element is created, future calls will
2725    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2726    /// and no changes to Execution State dependencies will be made.
2727    ///
2728    /// If any required entries in the request are missing, the server will
2729    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2730    pub fn r#add_execution_state_dependency(
2731        &self,
2732        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2733    ) -> fidl::client::QueryResponseFut<
2734        CpuElementManagerAddExecutionStateDependencyResult,
2735        fidl::encoding::DefaultFuchsiaResourceDialect,
2736    > {
2737        CpuElementManagerProxyInterface::r#add_execution_state_dependency(self, payload)
2738    }
2739}
2740
2741impl CpuElementManagerProxyInterface for CpuElementManagerProxy {
2742    type GetCpuDependencyTokenResponseFut =
2743        fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>;
2744    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut {
2745        fn _decode(
2746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2747        ) -> Result<Cpu, fidl::Error> {
2748            let _response = fidl::client::decode_transaction_body::<
2749                fidl::encoding::FlexibleType<Cpu>,
2750                fidl::encoding::DefaultFuchsiaResourceDialect,
2751                0x2c43645ed70344ba,
2752            >(_buf?)?
2753            .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
2754            Ok(_response)
2755        }
2756        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Cpu>(
2757            (),
2758            0x2c43645ed70344ba,
2759            fidl::encoding::DynamicFlags::FLEXIBLE,
2760            _decode,
2761        )
2762    }
2763
2764    type AddExecutionStateDependencyResponseFut = fidl::client::QueryResponseFut<
2765        CpuElementManagerAddExecutionStateDependencyResult,
2766        fidl::encoding::DefaultFuchsiaResourceDialect,
2767    >;
2768    fn r#add_execution_state_dependency(
2769        &self,
2770        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2771    ) -> Self::AddExecutionStateDependencyResponseFut {
2772        fn _decode(
2773            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2774        ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
2775            let _response = fidl::client::decode_transaction_body::<
2776                fidl::encoding::FlexibleResultType<
2777                    fidl::encoding::EmptyStruct,
2778                    AddExecutionStateDependencyError,
2779                >,
2780                fidl::encoding::DefaultFuchsiaResourceDialect,
2781                0xdf2f5ea2af76234,
2782            >(_buf?)?
2783            .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
2784            Ok(_response.map(|x| x))
2785        }
2786        self.client.send_query_and_decode::<
2787            CpuElementManagerAddExecutionStateDependencyRequest,
2788            CpuElementManagerAddExecutionStateDependencyResult,
2789        >(
2790            &mut payload,
2791            0xdf2f5ea2af76234,
2792            fidl::encoding::DynamicFlags::FLEXIBLE,
2793            _decode,
2794        )
2795    }
2796}
2797
2798pub struct CpuElementManagerEventStream {
2799    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2800}
2801
2802impl std::marker::Unpin for CpuElementManagerEventStream {}
2803
2804impl futures::stream::FusedStream for CpuElementManagerEventStream {
2805    fn is_terminated(&self) -> bool {
2806        self.event_receiver.is_terminated()
2807    }
2808}
2809
2810impl futures::Stream for CpuElementManagerEventStream {
2811    type Item = Result<CpuElementManagerEvent, fidl::Error>;
2812
2813    fn poll_next(
2814        mut self: std::pin::Pin<&mut Self>,
2815        cx: &mut std::task::Context<'_>,
2816    ) -> std::task::Poll<Option<Self::Item>> {
2817        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2818            &mut self.event_receiver,
2819            cx
2820        )?) {
2821            Some(buf) => std::task::Poll::Ready(Some(CpuElementManagerEvent::decode(buf))),
2822            None => std::task::Poll::Ready(None),
2823        }
2824    }
2825}
2826
2827#[derive(Debug)]
2828pub enum CpuElementManagerEvent {
2829    #[non_exhaustive]
2830    _UnknownEvent {
2831        /// Ordinal of the event that was sent.
2832        ordinal: u64,
2833    },
2834}
2835
2836impl CpuElementManagerEvent {
2837    /// Decodes a message buffer as a [`CpuElementManagerEvent`].
2838    fn decode(
2839        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2840    ) -> Result<CpuElementManagerEvent, fidl::Error> {
2841        let (bytes, _handles) = buf.split_mut();
2842        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2843        debug_assert_eq!(tx_header.tx_id, 0);
2844        match tx_header.ordinal {
2845            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2846                Ok(CpuElementManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2847            }
2848            _ => Err(fidl::Error::UnknownOrdinal {
2849                ordinal: tx_header.ordinal,
2850                protocol_name:
2851                    <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2852            }),
2853        }
2854    }
2855}
2856
2857/// A Stream of incoming requests for fuchsia.power.system/CpuElementManager.
2858pub struct CpuElementManagerRequestStream {
2859    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2860    is_terminated: bool,
2861}
2862
2863impl std::marker::Unpin for CpuElementManagerRequestStream {}
2864
2865impl futures::stream::FusedStream for CpuElementManagerRequestStream {
2866    fn is_terminated(&self) -> bool {
2867        self.is_terminated
2868    }
2869}
2870
2871impl fidl::endpoints::RequestStream for CpuElementManagerRequestStream {
2872    type Protocol = CpuElementManagerMarker;
2873    type ControlHandle = CpuElementManagerControlHandle;
2874
2875    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2876        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2877    }
2878
2879    fn control_handle(&self) -> Self::ControlHandle {
2880        CpuElementManagerControlHandle { inner: self.inner.clone() }
2881    }
2882
2883    fn into_inner(
2884        self,
2885    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2886    {
2887        (self.inner, self.is_terminated)
2888    }
2889
2890    fn from_inner(
2891        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2892        is_terminated: bool,
2893    ) -> Self {
2894        Self { inner, is_terminated }
2895    }
2896}
2897
2898impl futures::Stream for CpuElementManagerRequestStream {
2899    type Item = Result<CpuElementManagerRequest, fidl::Error>;
2900
2901    fn poll_next(
2902        mut self: std::pin::Pin<&mut Self>,
2903        cx: &mut std::task::Context<'_>,
2904    ) -> std::task::Poll<Option<Self::Item>> {
2905        let this = &mut *self;
2906        if this.inner.check_shutdown(cx) {
2907            this.is_terminated = true;
2908            return std::task::Poll::Ready(None);
2909        }
2910        if this.is_terminated {
2911            panic!("polled CpuElementManagerRequestStream after completion");
2912        }
2913        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2914            |bytes, handles| {
2915                match this.inner.channel().read_etc(cx, bytes, handles) {
2916                    std::task::Poll::Ready(Ok(())) => {}
2917                    std::task::Poll::Pending => return std::task::Poll::Pending,
2918                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2919                        this.is_terminated = true;
2920                        return std::task::Poll::Ready(None);
2921                    }
2922                    std::task::Poll::Ready(Err(e)) => {
2923                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2924                            e.into(),
2925                        ))))
2926                    }
2927                }
2928
2929                // A message has been received from the channel
2930                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2931
2932                std::task::Poll::Ready(Some(match header.ordinal {
2933                    0x2c43645ed70344ba => {
2934                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2935                        let mut req = fidl::new_empty!(
2936                            fidl::encoding::EmptyPayload,
2937                            fidl::encoding::DefaultFuchsiaResourceDialect
2938                        );
2939                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2940                        let control_handle =
2941                            CpuElementManagerControlHandle { inner: this.inner.clone() };
2942                        Ok(CpuElementManagerRequest::GetCpuDependencyToken {
2943                            responder: CpuElementManagerGetCpuDependencyTokenResponder {
2944                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2945                                tx_id: header.tx_id,
2946                            },
2947                        })
2948                    }
2949                    0xdf2f5ea2af76234 => {
2950                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2951                        let mut req = fidl::new_empty!(
2952                            CpuElementManagerAddExecutionStateDependencyRequest,
2953                            fidl::encoding::DefaultFuchsiaResourceDialect
2954                        );
2955                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CpuElementManagerAddExecutionStateDependencyRequest>(&header, _body_bytes, handles, &mut req)?;
2956                        let control_handle =
2957                            CpuElementManagerControlHandle { inner: this.inner.clone() };
2958                        Ok(CpuElementManagerRequest::AddExecutionStateDependency {
2959                            payload: req,
2960                            responder: CpuElementManagerAddExecutionStateDependencyResponder {
2961                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2962                                tx_id: header.tx_id,
2963                            },
2964                        })
2965                    }
2966                    _ if header.tx_id == 0
2967                        && header
2968                            .dynamic_flags()
2969                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2970                    {
2971                        Ok(CpuElementManagerRequest::_UnknownMethod {
2972                            ordinal: header.ordinal,
2973                            control_handle: CpuElementManagerControlHandle {
2974                                inner: this.inner.clone(),
2975                            },
2976                            method_type: fidl::MethodType::OneWay,
2977                        })
2978                    }
2979                    _ if header
2980                        .dynamic_flags()
2981                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2982                    {
2983                        this.inner.send_framework_err(
2984                            fidl::encoding::FrameworkErr::UnknownMethod,
2985                            header.tx_id,
2986                            header.ordinal,
2987                            header.dynamic_flags(),
2988                            (bytes, handles),
2989                        )?;
2990                        Ok(CpuElementManagerRequest::_UnknownMethod {
2991                            ordinal: header.ordinal,
2992                            control_handle: CpuElementManagerControlHandle {
2993                                inner: this.inner.clone(),
2994                            },
2995                            method_type: fidl::MethodType::TwoWay,
2996                        })
2997                    }
2998                    _ => Err(fidl::Error::UnknownOrdinal {
2999                        ordinal: header.ordinal,
3000                        protocol_name:
3001                            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3002                    }),
3003                }))
3004            },
3005        )
3006    }
3007}
3008
3009/// A service that provides access to CPU-related power elements.
3010#[derive(Debug)]
3011pub enum CpuElementManagerRequest {
3012    /// Gets the assertive dependency token for the CPU power element.
3013    GetCpuDependencyToken { responder: CpuElementManagerGetCpuDependencyTokenResponder },
3014    /// Adds a dependency from the Execution State power element to the target
3015    /// power element identified by [`dependency_token`] at [`power_level`].
3016    ///
3017    /// Once the Execution State power element is created, future calls will
3018    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
3019    /// and no changes to Execution State dependencies will be made.
3020    ///
3021    /// If any required entries in the request are missing, the server will
3022    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
3023    AddExecutionStateDependency {
3024        payload: CpuElementManagerAddExecutionStateDependencyRequest,
3025        responder: CpuElementManagerAddExecutionStateDependencyResponder,
3026    },
3027    /// An interaction was received which does not match any known method.
3028    #[non_exhaustive]
3029    _UnknownMethod {
3030        /// Ordinal of the method that was called.
3031        ordinal: u64,
3032        control_handle: CpuElementManagerControlHandle,
3033        method_type: fidl::MethodType,
3034    },
3035}
3036
3037impl CpuElementManagerRequest {
3038    #[allow(irrefutable_let_patterns)]
3039    pub fn into_get_cpu_dependency_token(
3040        self,
3041    ) -> Option<(CpuElementManagerGetCpuDependencyTokenResponder)> {
3042        if let CpuElementManagerRequest::GetCpuDependencyToken { responder } = self {
3043            Some((responder))
3044        } else {
3045            None
3046        }
3047    }
3048
3049    #[allow(irrefutable_let_patterns)]
3050    pub fn into_add_execution_state_dependency(
3051        self,
3052    ) -> Option<(
3053        CpuElementManagerAddExecutionStateDependencyRequest,
3054        CpuElementManagerAddExecutionStateDependencyResponder,
3055    )> {
3056        if let CpuElementManagerRequest::AddExecutionStateDependency { payload, responder } = self {
3057            Some((payload, responder))
3058        } else {
3059            None
3060        }
3061    }
3062
3063    /// Name of the method defined in FIDL
3064    pub fn method_name(&self) -> &'static str {
3065        match *self {
3066            CpuElementManagerRequest::GetCpuDependencyToken { .. } => "get_cpu_dependency_token",
3067            CpuElementManagerRequest::AddExecutionStateDependency { .. } => {
3068                "add_execution_state_dependency"
3069            }
3070            CpuElementManagerRequest::_UnknownMethod {
3071                method_type: fidl::MethodType::OneWay,
3072                ..
3073            } => "unknown one-way method",
3074            CpuElementManagerRequest::_UnknownMethod {
3075                method_type: fidl::MethodType::TwoWay,
3076                ..
3077            } => "unknown two-way method",
3078        }
3079    }
3080}
3081
3082#[derive(Debug, Clone)]
3083pub struct CpuElementManagerControlHandle {
3084    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3085}
3086
3087impl fidl::endpoints::ControlHandle for CpuElementManagerControlHandle {
3088    fn shutdown(&self) {
3089        self.inner.shutdown()
3090    }
3091    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3092        self.inner.shutdown_with_epitaph(status)
3093    }
3094
3095    fn is_closed(&self) -> bool {
3096        self.inner.channel().is_closed()
3097    }
3098    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3099        self.inner.channel().on_closed()
3100    }
3101
3102    #[cfg(target_os = "fuchsia")]
3103    fn signal_peer(
3104        &self,
3105        clear_mask: zx::Signals,
3106        set_mask: zx::Signals,
3107    ) -> Result<(), zx_status::Status> {
3108        use fidl::Peered;
3109        self.inner.channel().signal_peer(clear_mask, set_mask)
3110    }
3111}
3112
3113impl CpuElementManagerControlHandle {}
3114
3115#[must_use = "FIDL methods require a response to be sent"]
3116#[derive(Debug)]
3117pub struct CpuElementManagerGetCpuDependencyTokenResponder {
3118    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
3119    tx_id: u32,
3120}
3121
3122/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
3123/// if the responder is dropped without sending a response, so that the client
3124/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3125impl std::ops::Drop for CpuElementManagerGetCpuDependencyTokenResponder {
3126    fn drop(&mut self) {
3127        self.control_handle.shutdown();
3128        // Safety: drops once, never accessed again
3129        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3130    }
3131}
3132
3133impl fidl::endpoints::Responder for CpuElementManagerGetCpuDependencyTokenResponder {
3134    type ControlHandle = CpuElementManagerControlHandle;
3135
3136    fn control_handle(&self) -> &CpuElementManagerControlHandle {
3137        &self.control_handle
3138    }
3139
3140    fn drop_without_shutdown(mut self) {
3141        // Safety: drops once, never accessed again due to mem::forget
3142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3143        // Prevent Drop from running (which would shut down the channel)
3144        std::mem::forget(self);
3145    }
3146}
3147
3148impl CpuElementManagerGetCpuDependencyTokenResponder {
3149    /// Sends a response to the FIDL transaction.
3150    ///
3151    /// Sets the channel to shutdown if an error occurs.
3152    pub fn send(self, mut payload: Cpu) -> Result<(), fidl::Error> {
3153        let _result = self.send_raw(payload);
3154        if _result.is_err() {
3155            self.control_handle.shutdown();
3156        }
3157        self.drop_without_shutdown();
3158        _result
3159    }
3160
3161    /// Similar to "send" but does not shutdown the channel if an error occurs.
3162    pub fn send_no_shutdown_on_err(self, mut payload: Cpu) -> Result<(), fidl::Error> {
3163        let _result = self.send_raw(payload);
3164        self.drop_without_shutdown();
3165        _result
3166    }
3167
3168    fn send_raw(&self, mut payload: Cpu) -> Result<(), fidl::Error> {
3169        self.control_handle.inner.send::<fidl::encoding::FlexibleType<Cpu>>(
3170            fidl::encoding::Flexible::new(&mut payload),
3171            self.tx_id,
3172            0x2c43645ed70344ba,
3173            fidl::encoding::DynamicFlags::FLEXIBLE,
3174        )
3175    }
3176}
3177
3178#[must_use = "FIDL methods require a response to be sent"]
3179#[derive(Debug)]
3180pub struct CpuElementManagerAddExecutionStateDependencyResponder {
3181    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
3182    tx_id: u32,
3183}
3184
3185/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
3186/// if the responder is dropped without sending a response, so that the client
3187/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3188impl std::ops::Drop for CpuElementManagerAddExecutionStateDependencyResponder {
3189    fn drop(&mut self) {
3190        self.control_handle.shutdown();
3191        // Safety: drops once, never accessed again
3192        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3193    }
3194}
3195
3196impl fidl::endpoints::Responder for CpuElementManagerAddExecutionStateDependencyResponder {
3197    type ControlHandle = CpuElementManagerControlHandle;
3198
3199    fn control_handle(&self) -> &CpuElementManagerControlHandle {
3200        &self.control_handle
3201    }
3202
3203    fn drop_without_shutdown(mut self) {
3204        // Safety: drops once, never accessed again due to mem::forget
3205        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3206        // Prevent Drop from running (which would shut down the channel)
3207        std::mem::forget(self);
3208    }
3209}
3210
3211impl CpuElementManagerAddExecutionStateDependencyResponder {
3212    /// Sends a response to the FIDL transaction.
3213    ///
3214    /// Sets the channel to shutdown if an error occurs.
3215    pub fn send(
3216        self,
3217        mut result: Result<(), AddExecutionStateDependencyError>,
3218    ) -> Result<(), fidl::Error> {
3219        let _result = self.send_raw(result);
3220        if _result.is_err() {
3221            self.control_handle.shutdown();
3222        }
3223        self.drop_without_shutdown();
3224        _result
3225    }
3226
3227    /// Similar to "send" but does not shutdown the channel if an error occurs.
3228    pub fn send_no_shutdown_on_err(
3229        self,
3230        mut result: Result<(), AddExecutionStateDependencyError>,
3231    ) -> Result<(), fidl::Error> {
3232        let _result = self.send_raw(result);
3233        self.drop_without_shutdown();
3234        _result
3235    }
3236
3237    fn send_raw(
3238        &self,
3239        mut result: Result<(), AddExecutionStateDependencyError>,
3240    ) -> Result<(), fidl::Error> {
3241        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3242            fidl::encoding::EmptyStruct,
3243            AddExecutionStateDependencyError,
3244        >>(
3245            fidl::encoding::FlexibleResult::new(result),
3246            self.tx_id,
3247            0xdf2f5ea2af76234,
3248            fidl::encoding::DynamicFlags::FLEXIBLE,
3249        )
3250    }
3251}
3252
3253mod internal {
3254    use super::*;
3255
3256    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
3257        type Borrowed<'a> = &'a mut Self;
3258        fn take_or_borrow<'a>(
3259            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3260        ) -> Self::Borrowed<'a> {
3261            value
3262        }
3263    }
3264
3265    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
3266        type Owned = Self;
3267
3268        #[inline(always)]
3269        fn inline_align(_context: fidl::encoding::Context) -> usize {
3270            4
3271        }
3272
3273        #[inline(always)]
3274        fn inline_size(_context: fidl::encoding::Context) -> usize {
3275            4
3276        }
3277    }
3278
3279    unsafe impl
3280        fidl::encoding::Encode<
3281            ActivityGovernorAcquireWakeLeaseResponse,
3282            fidl::encoding::DefaultFuchsiaResourceDialect,
3283        > for &mut ActivityGovernorAcquireWakeLeaseResponse
3284    {
3285        #[inline]
3286        unsafe fn encode(
3287            self,
3288            encoder: &mut fidl::encoding::Encoder<
3289                '_,
3290                fidl::encoding::DefaultFuchsiaResourceDialect,
3291            >,
3292            offset: usize,
3293            _depth: fidl::encoding::Depth,
3294        ) -> fidl::Result<()> {
3295            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
3296            // Delegate to tuple encoding.
3297            fidl::encoding::Encode::<
3298                ActivityGovernorAcquireWakeLeaseResponse,
3299                fidl::encoding::DefaultFuchsiaResourceDialect,
3300            >::encode(
3301                (<fidl::encoding::HandleType<
3302                    fidl::EventPair,
3303                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3304                    16387,
3305                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3306                    &mut self.token
3307                ),),
3308                encoder,
3309                offset,
3310                _depth,
3311            )
3312        }
3313    }
3314    unsafe impl<
3315            T0: fidl::encoding::Encode<
3316                fidl::encoding::HandleType<
3317                    fidl::EventPair,
3318                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3319                    16387,
3320                >,
3321                fidl::encoding::DefaultFuchsiaResourceDialect,
3322            >,
3323        >
3324        fidl::encoding::Encode<
3325            ActivityGovernorAcquireWakeLeaseResponse,
3326            fidl::encoding::DefaultFuchsiaResourceDialect,
3327        > for (T0,)
3328    {
3329        #[inline]
3330        unsafe fn encode(
3331            self,
3332            encoder: &mut fidl::encoding::Encoder<
3333                '_,
3334                fidl::encoding::DefaultFuchsiaResourceDialect,
3335            >,
3336            offset: usize,
3337            depth: fidl::encoding::Depth,
3338        ) -> fidl::Result<()> {
3339            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
3340            // Zero out padding regions. There's no need to apply masks
3341            // because the unmasked parts will be overwritten by fields.
3342            // Write the fields.
3343            self.0.encode(encoder, offset + 0, depth)?;
3344            Ok(())
3345        }
3346    }
3347
3348    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3349        for ActivityGovernorAcquireWakeLeaseResponse
3350    {
3351        #[inline(always)]
3352        fn new_empty() -> Self {
3353            Self {
3354                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3355            }
3356        }
3357
3358        #[inline]
3359        unsafe fn decode(
3360            &mut self,
3361            decoder: &mut fidl::encoding::Decoder<
3362                '_,
3363                fidl::encoding::DefaultFuchsiaResourceDialect,
3364            >,
3365            offset: usize,
3366            _depth: fidl::encoding::Depth,
3367        ) -> fidl::Result<()> {
3368            decoder.debug_check_bounds::<Self>(offset);
3369            // Verify that padding bytes are zero.
3370            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
3371            Ok(())
3372        }
3373    }
3374
3375    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
3376        type Borrowed<'a> = &'a mut Self;
3377        fn take_or_borrow<'a>(
3378            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3379        ) -> Self::Borrowed<'a> {
3380            value
3381        }
3382    }
3383
3384    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
3385        type Owned = Self;
3386
3387        #[inline(always)]
3388        fn inline_align(_context: fidl::encoding::Context) -> usize {
3389            4
3390        }
3391
3392        #[inline(always)]
3393        fn inline_size(_context: fidl::encoding::Context) -> usize {
3394            4
3395        }
3396    }
3397
3398    unsafe impl
3399        fidl::encoding::Encode<
3400            ActivityGovernorTakeApplicationActivityLeaseResponse,
3401            fidl::encoding::DefaultFuchsiaResourceDialect,
3402        > for &mut ActivityGovernorTakeApplicationActivityLeaseResponse
3403    {
3404        #[inline]
3405        unsafe fn encode(
3406            self,
3407            encoder: &mut fidl::encoding::Encoder<
3408                '_,
3409                fidl::encoding::DefaultFuchsiaResourceDialect,
3410            >,
3411            offset: usize,
3412            _depth: fidl::encoding::Depth,
3413        ) -> fidl::Result<()> {
3414            encoder
3415                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
3416            // Delegate to tuple encoding.
3417            fidl::encoding::Encode::<
3418                ActivityGovernorTakeApplicationActivityLeaseResponse,
3419                fidl::encoding::DefaultFuchsiaResourceDialect,
3420            >::encode(
3421                (<fidl::encoding::HandleType<
3422                    fidl::EventPair,
3423                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3424                    16387,
3425                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3426                    &mut self.token
3427                ),),
3428                encoder,
3429                offset,
3430                _depth,
3431            )
3432        }
3433    }
3434    unsafe impl<
3435            T0: fidl::encoding::Encode<
3436                fidl::encoding::HandleType<
3437                    fidl::EventPair,
3438                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3439                    16387,
3440                >,
3441                fidl::encoding::DefaultFuchsiaResourceDialect,
3442            >,
3443        >
3444        fidl::encoding::Encode<
3445            ActivityGovernorTakeApplicationActivityLeaseResponse,
3446            fidl::encoding::DefaultFuchsiaResourceDialect,
3447        > for (T0,)
3448    {
3449        #[inline]
3450        unsafe fn encode(
3451            self,
3452            encoder: &mut fidl::encoding::Encoder<
3453                '_,
3454                fidl::encoding::DefaultFuchsiaResourceDialect,
3455            >,
3456            offset: usize,
3457            depth: fidl::encoding::Depth,
3458        ) -> fidl::Result<()> {
3459            encoder
3460                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
3461            // Zero out padding regions. There's no need to apply masks
3462            // because the unmasked parts will be overwritten by fields.
3463            // Write the fields.
3464            self.0.encode(encoder, offset + 0, depth)?;
3465            Ok(())
3466        }
3467    }
3468
3469    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3470        for ActivityGovernorTakeApplicationActivityLeaseResponse
3471    {
3472        #[inline(always)]
3473        fn new_empty() -> Self {
3474            Self {
3475                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3476            }
3477        }
3478
3479        #[inline]
3480        unsafe fn decode(
3481            &mut self,
3482            decoder: &mut fidl::encoding::Decoder<
3483                '_,
3484                fidl::encoding::DefaultFuchsiaResourceDialect,
3485            >,
3486            offset: usize,
3487            _depth: fidl::encoding::Depth,
3488        ) -> fidl::Result<()> {
3489            decoder.debug_check_bounds::<Self>(offset);
3490            // Verify that padding bytes are zero.
3491            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
3492            Ok(())
3493        }
3494    }
3495
3496    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeWakeLeaseResponse {
3497        type Borrowed<'a> = &'a mut Self;
3498        fn take_or_borrow<'a>(
3499            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3500        ) -> Self::Borrowed<'a> {
3501            value
3502        }
3503    }
3504
3505    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeWakeLeaseResponse {
3506        type Owned = Self;
3507
3508        #[inline(always)]
3509        fn inline_align(_context: fidl::encoding::Context) -> usize {
3510            4
3511        }
3512
3513        #[inline(always)]
3514        fn inline_size(_context: fidl::encoding::Context) -> usize {
3515            4
3516        }
3517    }
3518
3519    unsafe impl
3520        fidl::encoding::Encode<
3521            ActivityGovernorTakeWakeLeaseResponse,
3522            fidl::encoding::DefaultFuchsiaResourceDialect,
3523        > for &mut ActivityGovernorTakeWakeLeaseResponse
3524    {
3525        #[inline]
3526        unsafe fn encode(
3527            self,
3528            encoder: &mut fidl::encoding::Encoder<
3529                '_,
3530                fidl::encoding::DefaultFuchsiaResourceDialect,
3531            >,
3532            offset: usize,
3533            _depth: fidl::encoding::Depth,
3534        ) -> fidl::Result<()> {
3535            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
3536            // Delegate to tuple encoding.
3537            fidl::encoding::Encode::<
3538                ActivityGovernorTakeWakeLeaseResponse,
3539                fidl::encoding::DefaultFuchsiaResourceDialect,
3540            >::encode(
3541                (<fidl::encoding::HandleType<
3542                    fidl::EventPair,
3543                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3544                    16387,
3545                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3546                    &mut self.token
3547                ),),
3548                encoder,
3549                offset,
3550                _depth,
3551            )
3552        }
3553    }
3554    unsafe impl<
3555            T0: fidl::encoding::Encode<
3556                fidl::encoding::HandleType<
3557                    fidl::EventPair,
3558                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3559                    16387,
3560                >,
3561                fidl::encoding::DefaultFuchsiaResourceDialect,
3562            >,
3563        >
3564        fidl::encoding::Encode<
3565            ActivityGovernorTakeWakeLeaseResponse,
3566            fidl::encoding::DefaultFuchsiaResourceDialect,
3567        > for (T0,)
3568    {
3569        #[inline]
3570        unsafe fn encode(
3571            self,
3572            encoder: &mut fidl::encoding::Encoder<
3573                '_,
3574                fidl::encoding::DefaultFuchsiaResourceDialect,
3575            >,
3576            offset: usize,
3577            depth: fidl::encoding::Depth,
3578        ) -> fidl::Result<()> {
3579            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
3580            // Zero out padding regions. There's no need to apply masks
3581            // because the unmasked parts will be overwritten by fields.
3582            // Write the fields.
3583            self.0.encode(encoder, offset + 0, depth)?;
3584            Ok(())
3585        }
3586    }
3587
3588    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3589        for ActivityGovernorTakeWakeLeaseResponse
3590    {
3591        #[inline(always)]
3592        fn new_empty() -> Self {
3593            Self {
3594                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3595            }
3596        }
3597
3598        #[inline]
3599        unsafe fn decode(
3600            &mut self,
3601            decoder: &mut fidl::encoding::Decoder<
3602                '_,
3603                fidl::encoding::DefaultFuchsiaResourceDialect,
3604            >,
3605            offset: usize,
3606            _depth: fidl::encoding::Depth,
3607        ) -> fidl::Result<()> {
3608            decoder.debug_check_bounds::<Self>(offset);
3609            // Verify that padding bytes are zero.
3610            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
3611            Ok(())
3612        }
3613    }
3614
3615    impl ActivityGovernorRegisterListenerRequest {
3616        #[inline(always)]
3617        fn max_ordinal_present(&self) -> u64 {
3618            if let Some(_) = self.listener {
3619                return 1;
3620            }
3621            0
3622        }
3623    }
3624
3625    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterListenerRequest {
3626        type Borrowed<'a> = &'a mut Self;
3627        fn take_or_borrow<'a>(
3628            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3629        ) -> Self::Borrowed<'a> {
3630            value
3631        }
3632    }
3633
3634    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterListenerRequest {
3635        type Owned = Self;
3636
3637        #[inline(always)]
3638        fn inline_align(_context: fidl::encoding::Context) -> usize {
3639            8
3640        }
3641
3642        #[inline(always)]
3643        fn inline_size(_context: fidl::encoding::Context) -> usize {
3644            16
3645        }
3646    }
3647
3648    unsafe impl
3649        fidl::encoding::Encode<
3650            ActivityGovernorRegisterListenerRequest,
3651            fidl::encoding::DefaultFuchsiaResourceDialect,
3652        > for &mut ActivityGovernorRegisterListenerRequest
3653    {
3654        unsafe fn encode(
3655            self,
3656            encoder: &mut fidl::encoding::Encoder<
3657                '_,
3658                fidl::encoding::DefaultFuchsiaResourceDialect,
3659            >,
3660            offset: usize,
3661            mut depth: fidl::encoding::Depth,
3662        ) -> fidl::Result<()> {
3663            encoder.debug_check_bounds::<ActivityGovernorRegisterListenerRequest>(offset);
3664            // Vector header
3665            let max_ordinal: u64 = self.max_ordinal_present();
3666            encoder.write_num(max_ordinal, offset);
3667            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3668            // Calling encoder.out_of_line_offset(0) is not allowed.
3669            if max_ordinal == 0 {
3670                return Ok(());
3671            }
3672            depth.increment()?;
3673            let envelope_size = 8;
3674            let bytes_len = max_ordinal as usize * envelope_size;
3675            #[allow(unused_variables)]
3676            let offset = encoder.out_of_line_offset(bytes_len);
3677            let mut _prev_end_offset: usize = 0;
3678            if 1 > max_ordinal {
3679                return Ok(());
3680            }
3681
3682            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3683            // are envelope_size bytes.
3684            let cur_offset: usize = (1 - 1) * envelope_size;
3685
3686            // Zero reserved fields.
3687            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3688
3689            // Safety:
3690            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3691            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3692            //   envelope_size bytes, there is always sufficient room.
3693            fidl::encoding::encode_in_envelope_optional::<
3694                fidl::encoding::Endpoint<
3695                    fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
3696                >,
3697                fidl::encoding::DefaultFuchsiaResourceDialect,
3698            >(
3699                self.listener.as_mut().map(
3700                    <fidl::encoding::Endpoint<
3701                        fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
3702                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3703                ),
3704                encoder,
3705                offset + cur_offset,
3706                depth,
3707            )?;
3708
3709            _prev_end_offset = cur_offset + envelope_size;
3710
3711            Ok(())
3712        }
3713    }
3714
3715    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3716        for ActivityGovernorRegisterListenerRequest
3717    {
3718        #[inline(always)]
3719        fn new_empty() -> Self {
3720            Self::default()
3721        }
3722
3723        unsafe fn decode(
3724            &mut self,
3725            decoder: &mut fidl::encoding::Decoder<
3726                '_,
3727                fidl::encoding::DefaultFuchsiaResourceDialect,
3728            >,
3729            offset: usize,
3730            mut depth: fidl::encoding::Depth,
3731        ) -> fidl::Result<()> {
3732            decoder.debug_check_bounds::<Self>(offset);
3733            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3734                None => return Err(fidl::Error::NotNullable),
3735                Some(len) => len,
3736            };
3737            // Calling decoder.out_of_line_offset(0) is not allowed.
3738            if len == 0 {
3739                return Ok(());
3740            };
3741            depth.increment()?;
3742            let envelope_size = 8;
3743            let bytes_len = len * envelope_size;
3744            let offset = decoder.out_of_line_offset(bytes_len)?;
3745            // Decode the envelope for each type.
3746            let mut _next_ordinal_to_read = 0;
3747            let mut next_offset = offset;
3748            let end_offset = offset + bytes_len;
3749            _next_ordinal_to_read += 1;
3750            if next_offset >= end_offset {
3751                return Ok(());
3752            }
3753
3754            // Decode unknown envelopes for gaps in ordinals.
3755            while _next_ordinal_to_read < 1 {
3756                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3757                _next_ordinal_to_read += 1;
3758                next_offset += envelope_size;
3759            }
3760
3761            let next_out_of_line = decoder.next_out_of_line();
3762            let handles_before = decoder.remaining_handles();
3763            if let Some((inlined, num_bytes, num_handles)) =
3764                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3765            {
3766                let member_inline_size = <fidl::encoding::Endpoint<
3767                    fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
3768                > as fidl::encoding::TypeMarker>::inline_size(
3769                    decoder.context
3770                );
3771                if inlined != (member_inline_size <= 4) {
3772                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3773                }
3774                let inner_offset;
3775                let mut inner_depth = depth.clone();
3776                if inlined {
3777                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3778                    inner_offset = next_offset;
3779                } else {
3780                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3781                    inner_depth.increment()?;
3782                }
3783                let val_ref = self.listener.get_or_insert_with(|| {
3784                    fidl::new_empty!(
3785                        fidl::encoding::Endpoint<
3786                            fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
3787                        >,
3788                        fidl::encoding::DefaultFuchsiaResourceDialect
3789                    )
3790                });
3791                fidl::decode!(
3792                    fidl::encoding::Endpoint<
3793                        fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
3794                    >,
3795                    fidl::encoding::DefaultFuchsiaResourceDialect,
3796                    val_ref,
3797                    decoder,
3798                    inner_offset,
3799                    inner_depth
3800                )?;
3801                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3802                {
3803                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3804                }
3805                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3806                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3807                }
3808            }
3809
3810            next_offset += envelope_size;
3811
3812            // Decode the remaining unknown envelopes.
3813            while next_offset < end_offset {
3814                _next_ordinal_to_read += 1;
3815                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3816                next_offset += envelope_size;
3817            }
3818
3819            Ok(())
3820        }
3821    }
3822
3823    impl ApplicationActivity {
3824        #[inline(always)]
3825        fn max_ordinal_present(&self) -> u64 {
3826            if let Some(_) = self.assertive_dependency_token {
3827                return 1;
3828            }
3829            0
3830        }
3831    }
3832
3833    impl fidl::encoding::ResourceTypeMarker for ApplicationActivity {
3834        type Borrowed<'a> = &'a mut Self;
3835        fn take_or_borrow<'a>(
3836            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3837        ) -> Self::Borrowed<'a> {
3838            value
3839        }
3840    }
3841
3842    unsafe impl fidl::encoding::TypeMarker for ApplicationActivity {
3843        type Owned = Self;
3844
3845        #[inline(always)]
3846        fn inline_align(_context: fidl::encoding::Context) -> usize {
3847            8
3848        }
3849
3850        #[inline(always)]
3851        fn inline_size(_context: fidl::encoding::Context) -> usize {
3852            16
3853        }
3854    }
3855
3856    unsafe impl
3857        fidl::encoding::Encode<ApplicationActivity, fidl::encoding::DefaultFuchsiaResourceDialect>
3858        for &mut ApplicationActivity
3859    {
3860        unsafe fn encode(
3861            self,
3862            encoder: &mut fidl::encoding::Encoder<
3863                '_,
3864                fidl::encoding::DefaultFuchsiaResourceDialect,
3865            >,
3866            offset: usize,
3867            mut depth: fidl::encoding::Depth,
3868        ) -> fidl::Result<()> {
3869            encoder.debug_check_bounds::<ApplicationActivity>(offset);
3870            // Vector header
3871            let max_ordinal: u64 = self.max_ordinal_present();
3872            encoder.write_num(max_ordinal, offset);
3873            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3874            // Calling encoder.out_of_line_offset(0) is not allowed.
3875            if max_ordinal == 0 {
3876                return Ok(());
3877            }
3878            depth.increment()?;
3879            let envelope_size = 8;
3880            let bytes_len = max_ordinal as usize * envelope_size;
3881            #[allow(unused_variables)]
3882            let offset = encoder.out_of_line_offset(bytes_len);
3883            let mut _prev_end_offset: usize = 0;
3884            if 1 > max_ordinal {
3885                return Ok(());
3886            }
3887
3888            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3889            // are envelope_size bytes.
3890            let cur_offset: usize = (1 - 1) * envelope_size;
3891
3892            // Zero reserved fields.
3893            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3894
3895            // Safety:
3896            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3897            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3898            //   envelope_size bytes, there is always sufficient room.
3899            fidl::encoding::encode_in_envelope_optional::<
3900                fidl::encoding::HandleType<
3901                    fidl::Event,
3902                    { fidl::ObjectType::EVENT.into_raw() },
3903                    2147483648,
3904                >,
3905                fidl::encoding::DefaultFuchsiaResourceDialect,
3906            >(
3907                self.assertive_dependency_token.as_mut().map(
3908                    <fidl::encoding::HandleType<
3909                        fidl::Event,
3910                        { fidl::ObjectType::EVENT.into_raw() },
3911                        2147483648,
3912                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3913                ),
3914                encoder,
3915                offset + cur_offset,
3916                depth,
3917            )?;
3918
3919            _prev_end_offset = cur_offset + envelope_size;
3920
3921            Ok(())
3922        }
3923    }
3924
3925    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3926        for ApplicationActivity
3927    {
3928        #[inline(always)]
3929        fn new_empty() -> Self {
3930            Self::default()
3931        }
3932
3933        unsafe fn decode(
3934            &mut self,
3935            decoder: &mut fidl::encoding::Decoder<
3936                '_,
3937                fidl::encoding::DefaultFuchsiaResourceDialect,
3938            >,
3939            offset: usize,
3940            mut depth: fidl::encoding::Depth,
3941        ) -> fidl::Result<()> {
3942            decoder.debug_check_bounds::<Self>(offset);
3943            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3944                None => return Err(fidl::Error::NotNullable),
3945                Some(len) => len,
3946            };
3947            // Calling decoder.out_of_line_offset(0) is not allowed.
3948            if len == 0 {
3949                return Ok(());
3950            };
3951            depth.increment()?;
3952            let envelope_size = 8;
3953            let bytes_len = len * envelope_size;
3954            let offset = decoder.out_of_line_offset(bytes_len)?;
3955            // Decode the envelope for each type.
3956            let mut _next_ordinal_to_read = 0;
3957            let mut next_offset = offset;
3958            let end_offset = offset + bytes_len;
3959            _next_ordinal_to_read += 1;
3960            if next_offset >= end_offset {
3961                return Ok(());
3962            }
3963
3964            // Decode unknown envelopes for gaps in ordinals.
3965            while _next_ordinal_to_read < 1 {
3966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3967                _next_ordinal_to_read += 1;
3968                next_offset += envelope_size;
3969            }
3970
3971            let next_out_of_line = decoder.next_out_of_line();
3972            let handles_before = decoder.remaining_handles();
3973            if let Some((inlined, num_bytes, num_handles)) =
3974                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3975            {
3976                let member_inline_size = <fidl::encoding::HandleType<
3977                    fidl::Event,
3978                    { fidl::ObjectType::EVENT.into_raw() },
3979                    2147483648,
3980                > as fidl::encoding::TypeMarker>::inline_size(
3981                    decoder.context
3982                );
3983                if inlined != (member_inline_size <= 4) {
3984                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3985                }
3986                let inner_offset;
3987                let mut inner_depth = depth.clone();
3988                if inlined {
3989                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3990                    inner_offset = next_offset;
3991                } else {
3992                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3993                    inner_depth.increment()?;
3994                }
3995                let val_ref =
3996                self.assertive_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3997                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3998                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3999                {
4000                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4001                }
4002                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4003                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4004                }
4005            }
4006
4007            next_offset += envelope_size;
4008
4009            // Decode the remaining unknown envelopes.
4010            while next_offset < end_offset {
4011                _next_ordinal_to_read += 1;
4012                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4013                next_offset += envelope_size;
4014            }
4015
4016            Ok(())
4017        }
4018    }
4019
4020    impl Cpu {
4021        #[inline(always)]
4022        fn max_ordinal_present(&self) -> u64 {
4023            if let Some(_) = self.assertive_dependency_token {
4024                return 1;
4025            }
4026            0
4027        }
4028    }
4029
4030    impl fidl::encoding::ResourceTypeMarker for Cpu {
4031        type Borrowed<'a> = &'a mut Self;
4032        fn take_or_borrow<'a>(
4033            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4034        ) -> Self::Borrowed<'a> {
4035            value
4036        }
4037    }
4038
4039    unsafe impl fidl::encoding::TypeMarker for Cpu {
4040        type Owned = Self;
4041
4042        #[inline(always)]
4043        fn inline_align(_context: fidl::encoding::Context) -> usize {
4044            8
4045        }
4046
4047        #[inline(always)]
4048        fn inline_size(_context: fidl::encoding::Context) -> usize {
4049            16
4050        }
4051    }
4052
4053    unsafe impl fidl::encoding::Encode<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>
4054        for &mut Cpu
4055    {
4056        unsafe fn encode(
4057            self,
4058            encoder: &mut fidl::encoding::Encoder<
4059                '_,
4060                fidl::encoding::DefaultFuchsiaResourceDialect,
4061            >,
4062            offset: usize,
4063            mut depth: fidl::encoding::Depth,
4064        ) -> fidl::Result<()> {
4065            encoder.debug_check_bounds::<Cpu>(offset);
4066            // Vector header
4067            let max_ordinal: u64 = self.max_ordinal_present();
4068            encoder.write_num(max_ordinal, offset);
4069            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4070            // Calling encoder.out_of_line_offset(0) is not allowed.
4071            if max_ordinal == 0 {
4072                return Ok(());
4073            }
4074            depth.increment()?;
4075            let envelope_size = 8;
4076            let bytes_len = max_ordinal as usize * envelope_size;
4077            #[allow(unused_variables)]
4078            let offset = encoder.out_of_line_offset(bytes_len);
4079            let mut _prev_end_offset: usize = 0;
4080            if 1 > max_ordinal {
4081                return Ok(());
4082            }
4083
4084            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4085            // are envelope_size bytes.
4086            let cur_offset: usize = (1 - 1) * envelope_size;
4087
4088            // Zero reserved fields.
4089            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4090
4091            // Safety:
4092            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4093            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4094            //   envelope_size bytes, there is always sufficient room.
4095            fidl::encoding::encode_in_envelope_optional::<
4096                fidl::encoding::HandleType<
4097                    fidl::Event,
4098                    { fidl::ObjectType::EVENT.into_raw() },
4099                    2147483648,
4100                >,
4101                fidl::encoding::DefaultFuchsiaResourceDialect,
4102            >(
4103                self.assertive_dependency_token.as_mut().map(
4104                    <fidl::encoding::HandleType<
4105                        fidl::Event,
4106                        { fidl::ObjectType::EVENT.into_raw() },
4107                        2147483648,
4108                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4109                ),
4110                encoder,
4111                offset + cur_offset,
4112                depth,
4113            )?;
4114
4115            _prev_end_offset = cur_offset + envelope_size;
4116
4117            Ok(())
4118        }
4119    }
4120
4121    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {
4122        #[inline(always)]
4123        fn new_empty() -> Self {
4124            Self::default()
4125        }
4126
4127        unsafe fn decode(
4128            &mut self,
4129            decoder: &mut fidl::encoding::Decoder<
4130                '_,
4131                fidl::encoding::DefaultFuchsiaResourceDialect,
4132            >,
4133            offset: usize,
4134            mut depth: fidl::encoding::Depth,
4135        ) -> fidl::Result<()> {
4136            decoder.debug_check_bounds::<Self>(offset);
4137            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4138                None => return Err(fidl::Error::NotNullable),
4139                Some(len) => len,
4140            };
4141            // Calling decoder.out_of_line_offset(0) is not allowed.
4142            if len == 0 {
4143                return Ok(());
4144            };
4145            depth.increment()?;
4146            let envelope_size = 8;
4147            let bytes_len = len * envelope_size;
4148            let offset = decoder.out_of_line_offset(bytes_len)?;
4149            // Decode the envelope for each type.
4150            let mut _next_ordinal_to_read = 0;
4151            let mut next_offset = offset;
4152            let end_offset = offset + bytes_len;
4153            _next_ordinal_to_read += 1;
4154            if next_offset >= end_offset {
4155                return Ok(());
4156            }
4157
4158            // Decode unknown envelopes for gaps in ordinals.
4159            while _next_ordinal_to_read < 1 {
4160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4161                _next_ordinal_to_read += 1;
4162                next_offset += envelope_size;
4163            }
4164
4165            let next_out_of_line = decoder.next_out_of_line();
4166            let handles_before = decoder.remaining_handles();
4167            if let Some((inlined, num_bytes, num_handles)) =
4168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4169            {
4170                let member_inline_size = <fidl::encoding::HandleType<
4171                    fidl::Event,
4172                    { fidl::ObjectType::EVENT.into_raw() },
4173                    2147483648,
4174                > as fidl::encoding::TypeMarker>::inline_size(
4175                    decoder.context
4176                );
4177                if inlined != (member_inline_size <= 4) {
4178                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4179                }
4180                let inner_offset;
4181                let mut inner_depth = depth.clone();
4182                if inlined {
4183                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4184                    inner_offset = next_offset;
4185                } else {
4186                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4187                    inner_depth.increment()?;
4188                }
4189                let val_ref =
4190                self.assertive_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4191                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4192                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4193                {
4194                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4195                }
4196                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4197                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4198                }
4199            }
4200
4201            next_offset += envelope_size;
4202
4203            // Decode the remaining unknown envelopes.
4204            while next_offset < end_offset {
4205                _next_ordinal_to_read += 1;
4206                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4207                next_offset += envelope_size;
4208            }
4209
4210            Ok(())
4211        }
4212    }
4213
4214    impl CpuElementManagerAddExecutionStateDependencyRequest {
4215        #[inline(always)]
4216        fn max_ordinal_present(&self) -> u64 {
4217            if let Some(_) = self.power_level {
4218                return 2;
4219            }
4220            if let Some(_) = self.dependency_token {
4221                return 1;
4222            }
4223            0
4224        }
4225    }
4226
4227    impl fidl::encoding::ResourceTypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
4228        type Borrowed<'a> = &'a mut Self;
4229        fn take_or_borrow<'a>(
4230            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4231        ) -> Self::Borrowed<'a> {
4232            value
4233        }
4234    }
4235
4236    unsafe impl fidl::encoding::TypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
4237        type Owned = Self;
4238
4239        #[inline(always)]
4240        fn inline_align(_context: fidl::encoding::Context) -> usize {
4241            8
4242        }
4243
4244        #[inline(always)]
4245        fn inline_size(_context: fidl::encoding::Context) -> usize {
4246            16
4247        }
4248    }
4249
4250    unsafe impl
4251        fidl::encoding::Encode<
4252            CpuElementManagerAddExecutionStateDependencyRequest,
4253            fidl::encoding::DefaultFuchsiaResourceDialect,
4254        > for &mut CpuElementManagerAddExecutionStateDependencyRequest
4255    {
4256        unsafe fn encode(
4257            self,
4258            encoder: &mut fidl::encoding::Encoder<
4259                '_,
4260                fidl::encoding::DefaultFuchsiaResourceDialect,
4261            >,
4262            offset: usize,
4263            mut depth: fidl::encoding::Depth,
4264        ) -> fidl::Result<()> {
4265            encoder
4266                .debug_check_bounds::<CpuElementManagerAddExecutionStateDependencyRequest>(offset);
4267            // Vector header
4268            let max_ordinal: u64 = self.max_ordinal_present();
4269            encoder.write_num(max_ordinal, offset);
4270            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4271            // Calling encoder.out_of_line_offset(0) is not allowed.
4272            if max_ordinal == 0 {
4273                return Ok(());
4274            }
4275            depth.increment()?;
4276            let envelope_size = 8;
4277            let bytes_len = max_ordinal as usize * envelope_size;
4278            #[allow(unused_variables)]
4279            let offset = encoder.out_of_line_offset(bytes_len);
4280            let mut _prev_end_offset: usize = 0;
4281            if 1 > max_ordinal {
4282                return Ok(());
4283            }
4284
4285            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4286            // are envelope_size bytes.
4287            let cur_offset: usize = (1 - 1) * envelope_size;
4288
4289            // Zero reserved fields.
4290            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4291
4292            // Safety:
4293            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4294            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4295            //   envelope_size bytes, there is always sufficient room.
4296            fidl::encoding::encode_in_envelope_optional::<
4297                fidl::encoding::HandleType<
4298                    fidl::Event,
4299                    { fidl::ObjectType::EVENT.into_raw() },
4300                    2147483648,
4301                >,
4302                fidl::encoding::DefaultFuchsiaResourceDialect,
4303            >(
4304                self.dependency_token.as_mut().map(
4305                    <fidl::encoding::HandleType<
4306                        fidl::Event,
4307                        { fidl::ObjectType::EVENT.into_raw() },
4308                        2147483648,
4309                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4310                ),
4311                encoder,
4312                offset + cur_offset,
4313                depth,
4314            )?;
4315
4316            _prev_end_offset = cur_offset + envelope_size;
4317            if 2 > max_ordinal {
4318                return Ok(());
4319            }
4320
4321            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4322            // are envelope_size bytes.
4323            let cur_offset: usize = (2 - 1) * envelope_size;
4324
4325            // Zero reserved fields.
4326            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4327
4328            // Safety:
4329            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4330            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4331            //   envelope_size bytes, there is always sufficient room.
4332            fidl::encoding::encode_in_envelope_optional::<
4333                u8,
4334                fidl::encoding::DefaultFuchsiaResourceDialect,
4335            >(
4336                self.power_level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
4337                encoder,
4338                offset + cur_offset,
4339                depth,
4340            )?;
4341
4342            _prev_end_offset = cur_offset + envelope_size;
4343
4344            Ok(())
4345        }
4346    }
4347
4348    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4349        for CpuElementManagerAddExecutionStateDependencyRequest
4350    {
4351        #[inline(always)]
4352        fn new_empty() -> Self {
4353            Self::default()
4354        }
4355
4356        unsafe fn decode(
4357            &mut self,
4358            decoder: &mut fidl::encoding::Decoder<
4359                '_,
4360                fidl::encoding::DefaultFuchsiaResourceDialect,
4361            >,
4362            offset: usize,
4363            mut depth: fidl::encoding::Depth,
4364        ) -> fidl::Result<()> {
4365            decoder.debug_check_bounds::<Self>(offset);
4366            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4367                None => return Err(fidl::Error::NotNullable),
4368                Some(len) => len,
4369            };
4370            // Calling decoder.out_of_line_offset(0) is not allowed.
4371            if len == 0 {
4372                return Ok(());
4373            };
4374            depth.increment()?;
4375            let envelope_size = 8;
4376            let bytes_len = len * envelope_size;
4377            let offset = decoder.out_of_line_offset(bytes_len)?;
4378            // Decode the envelope for each type.
4379            let mut _next_ordinal_to_read = 0;
4380            let mut next_offset = offset;
4381            let end_offset = offset + bytes_len;
4382            _next_ordinal_to_read += 1;
4383            if next_offset >= end_offset {
4384                return Ok(());
4385            }
4386
4387            // Decode unknown envelopes for gaps in ordinals.
4388            while _next_ordinal_to_read < 1 {
4389                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4390                _next_ordinal_to_read += 1;
4391                next_offset += envelope_size;
4392            }
4393
4394            let next_out_of_line = decoder.next_out_of_line();
4395            let handles_before = decoder.remaining_handles();
4396            if let Some((inlined, num_bytes, num_handles)) =
4397                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4398            {
4399                let member_inline_size = <fidl::encoding::HandleType<
4400                    fidl::Event,
4401                    { fidl::ObjectType::EVENT.into_raw() },
4402                    2147483648,
4403                > as fidl::encoding::TypeMarker>::inline_size(
4404                    decoder.context
4405                );
4406                if inlined != (member_inline_size <= 4) {
4407                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4408                }
4409                let inner_offset;
4410                let mut inner_depth = depth.clone();
4411                if inlined {
4412                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4413                    inner_offset = next_offset;
4414                } else {
4415                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4416                    inner_depth.increment()?;
4417                }
4418                let val_ref =
4419                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4420                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4421                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4422                {
4423                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4424                }
4425                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4426                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4427                }
4428            }
4429
4430            next_offset += envelope_size;
4431            _next_ordinal_to_read += 1;
4432            if next_offset >= end_offset {
4433                return Ok(());
4434            }
4435
4436            // Decode unknown envelopes for gaps in ordinals.
4437            while _next_ordinal_to_read < 2 {
4438                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4439                _next_ordinal_to_read += 1;
4440                next_offset += envelope_size;
4441            }
4442
4443            let next_out_of_line = decoder.next_out_of_line();
4444            let handles_before = decoder.remaining_handles();
4445            if let Some((inlined, num_bytes, num_handles)) =
4446                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4447            {
4448                let member_inline_size =
4449                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4450                if inlined != (member_inline_size <= 4) {
4451                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4452                }
4453                let inner_offset;
4454                let mut inner_depth = depth.clone();
4455                if inlined {
4456                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4457                    inner_offset = next_offset;
4458                } else {
4459                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4460                    inner_depth.increment()?;
4461                }
4462                let val_ref = self.power_level.get_or_insert_with(|| {
4463                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
4464                });
4465                fidl::decode!(
4466                    u8,
4467                    fidl::encoding::DefaultFuchsiaResourceDialect,
4468                    val_ref,
4469                    decoder,
4470                    inner_offset,
4471                    inner_depth
4472                )?;
4473                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4474                {
4475                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4476                }
4477                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4478                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4479                }
4480            }
4481
4482            next_offset += envelope_size;
4483
4484            // Decode the remaining unknown envelopes.
4485            while next_offset < end_offset {
4486                _next_ordinal_to_read += 1;
4487                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4488                next_offset += envelope_size;
4489            }
4490
4491            Ok(())
4492        }
4493    }
4494
4495    impl ExecutionState {
4496        #[inline(always)]
4497        fn max_ordinal_present(&self) -> u64 {
4498            if let Some(_) = self.opportunistic_dependency_token {
4499                return 1;
4500            }
4501            0
4502        }
4503    }
4504
4505    impl fidl::encoding::ResourceTypeMarker for ExecutionState {
4506        type Borrowed<'a> = &'a mut Self;
4507        fn take_or_borrow<'a>(
4508            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4509        ) -> Self::Borrowed<'a> {
4510            value
4511        }
4512    }
4513
4514    unsafe impl fidl::encoding::TypeMarker for ExecutionState {
4515        type Owned = Self;
4516
4517        #[inline(always)]
4518        fn inline_align(_context: fidl::encoding::Context) -> usize {
4519            8
4520        }
4521
4522        #[inline(always)]
4523        fn inline_size(_context: fidl::encoding::Context) -> usize {
4524            16
4525        }
4526    }
4527
4528    unsafe impl
4529        fidl::encoding::Encode<ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect>
4530        for &mut ExecutionState
4531    {
4532        unsafe fn encode(
4533            self,
4534            encoder: &mut fidl::encoding::Encoder<
4535                '_,
4536                fidl::encoding::DefaultFuchsiaResourceDialect,
4537            >,
4538            offset: usize,
4539            mut depth: fidl::encoding::Depth,
4540        ) -> fidl::Result<()> {
4541            encoder.debug_check_bounds::<ExecutionState>(offset);
4542            // Vector header
4543            let max_ordinal: u64 = self.max_ordinal_present();
4544            encoder.write_num(max_ordinal, offset);
4545            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4546            // Calling encoder.out_of_line_offset(0) is not allowed.
4547            if max_ordinal == 0 {
4548                return Ok(());
4549            }
4550            depth.increment()?;
4551            let envelope_size = 8;
4552            let bytes_len = max_ordinal as usize * envelope_size;
4553            #[allow(unused_variables)]
4554            let offset = encoder.out_of_line_offset(bytes_len);
4555            let mut _prev_end_offset: usize = 0;
4556            if 1 > max_ordinal {
4557                return Ok(());
4558            }
4559
4560            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4561            // are envelope_size bytes.
4562            let cur_offset: usize = (1 - 1) * envelope_size;
4563
4564            // Zero reserved fields.
4565            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4566
4567            // Safety:
4568            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4569            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4570            //   envelope_size bytes, there is always sufficient room.
4571            fidl::encoding::encode_in_envelope_optional::<
4572                fidl::encoding::HandleType<
4573                    fidl::Event,
4574                    { fidl::ObjectType::EVENT.into_raw() },
4575                    2147483648,
4576                >,
4577                fidl::encoding::DefaultFuchsiaResourceDialect,
4578            >(
4579                self.opportunistic_dependency_token.as_mut().map(
4580                    <fidl::encoding::HandleType<
4581                        fidl::Event,
4582                        { fidl::ObjectType::EVENT.into_raw() },
4583                        2147483648,
4584                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4585                ),
4586                encoder,
4587                offset + cur_offset,
4588                depth,
4589            )?;
4590
4591            _prev_end_offset = cur_offset + envelope_size;
4592
4593            Ok(())
4594        }
4595    }
4596
4597    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4598        for ExecutionState
4599    {
4600        #[inline(always)]
4601        fn new_empty() -> Self {
4602            Self::default()
4603        }
4604
4605        unsafe fn decode(
4606            &mut self,
4607            decoder: &mut fidl::encoding::Decoder<
4608                '_,
4609                fidl::encoding::DefaultFuchsiaResourceDialect,
4610            >,
4611            offset: usize,
4612            mut depth: fidl::encoding::Depth,
4613        ) -> fidl::Result<()> {
4614            decoder.debug_check_bounds::<Self>(offset);
4615            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4616                None => return Err(fidl::Error::NotNullable),
4617                Some(len) => len,
4618            };
4619            // Calling decoder.out_of_line_offset(0) is not allowed.
4620            if len == 0 {
4621                return Ok(());
4622            };
4623            depth.increment()?;
4624            let envelope_size = 8;
4625            let bytes_len = len * envelope_size;
4626            let offset = decoder.out_of_line_offset(bytes_len)?;
4627            // Decode the envelope for each type.
4628            let mut _next_ordinal_to_read = 0;
4629            let mut next_offset = offset;
4630            let end_offset = offset + bytes_len;
4631            _next_ordinal_to_read += 1;
4632            if next_offset >= end_offset {
4633                return Ok(());
4634            }
4635
4636            // Decode unknown envelopes for gaps in ordinals.
4637            while _next_ordinal_to_read < 1 {
4638                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4639                _next_ordinal_to_read += 1;
4640                next_offset += envelope_size;
4641            }
4642
4643            let next_out_of_line = decoder.next_out_of_line();
4644            let handles_before = decoder.remaining_handles();
4645            if let Some((inlined, num_bytes, num_handles)) =
4646                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4647            {
4648                let member_inline_size = <fidl::encoding::HandleType<
4649                    fidl::Event,
4650                    { fidl::ObjectType::EVENT.into_raw() },
4651                    2147483648,
4652                > as fidl::encoding::TypeMarker>::inline_size(
4653                    decoder.context
4654                );
4655                if inlined != (member_inline_size <= 4) {
4656                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4657                }
4658                let inner_offset;
4659                let mut inner_depth = depth.clone();
4660                if inlined {
4661                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4662                    inner_offset = next_offset;
4663                } else {
4664                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4665                    inner_depth.increment()?;
4666                }
4667                let val_ref =
4668                self.opportunistic_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4669                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4670                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4671                {
4672                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4673                }
4674                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4675                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4676                }
4677            }
4678
4679            next_offset += envelope_size;
4680
4681            // Decode the remaining unknown envelopes.
4682            while next_offset < end_offset {
4683                _next_ordinal_to_read += 1;
4684                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4685                next_offset += envelope_size;
4686            }
4687
4688            Ok(())
4689        }
4690    }
4691
4692    impl PowerElements {
4693        #[inline(always)]
4694        fn max_ordinal_present(&self) -> u64 {
4695            if let Some(_) = self.application_activity {
4696                return 3;
4697            }
4698            if let Some(_) = self.execution_state {
4699                return 1;
4700            }
4701            0
4702        }
4703    }
4704
4705    impl fidl::encoding::ResourceTypeMarker for PowerElements {
4706        type Borrowed<'a> = &'a mut Self;
4707        fn take_or_borrow<'a>(
4708            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4709        ) -> Self::Borrowed<'a> {
4710            value
4711        }
4712    }
4713
4714    unsafe impl fidl::encoding::TypeMarker for PowerElements {
4715        type Owned = Self;
4716
4717        #[inline(always)]
4718        fn inline_align(_context: fidl::encoding::Context) -> usize {
4719            8
4720        }
4721
4722        #[inline(always)]
4723        fn inline_size(_context: fidl::encoding::Context) -> usize {
4724            16
4725        }
4726    }
4727
4728    unsafe impl fidl::encoding::Encode<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
4729        for &mut PowerElements
4730    {
4731        unsafe fn encode(
4732            self,
4733            encoder: &mut fidl::encoding::Encoder<
4734                '_,
4735                fidl::encoding::DefaultFuchsiaResourceDialect,
4736            >,
4737            offset: usize,
4738            mut depth: fidl::encoding::Depth,
4739        ) -> fidl::Result<()> {
4740            encoder.debug_check_bounds::<PowerElements>(offset);
4741            // Vector header
4742            let max_ordinal: u64 = self.max_ordinal_present();
4743            encoder.write_num(max_ordinal, offset);
4744            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4745            // Calling encoder.out_of_line_offset(0) is not allowed.
4746            if max_ordinal == 0 {
4747                return Ok(());
4748            }
4749            depth.increment()?;
4750            let envelope_size = 8;
4751            let bytes_len = max_ordinal as usize * envelope_size;
4752            #[allow(unused_variables)]
4753            let offset = encoder.out_of_line_offset(bytes_len);
4754            let mut _prev_end_offset: usize = 0;
4755            if 1 > max_ordinal {
4756                return Ok(());
4757            }
4758
4759            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4760            // are envelope_size bytes.
4761            let cur_offset: usize = (1 - 1) * envelope_size;
4762
4763            // Zero reserved fields.
4764            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4765
4766            // Safety:
4767            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4768            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4769            //   envelope_size bytes, there is always sufficient room.
4770            fidl::encoding::encode_in_envelope_optional::<
4771                ExecutionState,
4772                fidl::encoding::DefaultFuchsiaResourceDialect,
4773            >(
4774                self.execution_state
4775                    .as_mut()
4776                    .map(<ExecutionState as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4777                encoder,
4778                offset + cur_offset,
4779                depth,
4780            )?;
4781
4782            _prev_end_offset = cur_offset + envelope_size;
4783            if 3 > max_ordinal {
4784                return Ok(());
4785            }
4786
4787            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4788            // are envelope_size bytes.
4789            let cur_offset: usize = (3 - 1) * envelope_size;
4790
4791            // Zero reserved fields.
4792            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4793
4794            // Safety:
4795            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4796            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4797            //   envelope_size bytes, there is always sufficient room.
4798            fidl::encoding::encode_in_envelope_optional::<
4799                ApplicationActivity,
4800                fidl::encoding::DefaultFuchsiaResourceDialect,
4801            >(
4802                self.application_activity.as_mut().map(
4803                    <ApplicationActivity as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4804                ),
4805                encoder,
4806                offset + cur_offset,
4807                depth,
4808            )?;
4809
4810            _prev_end_offset = cur_offset + envelope_size;
4811
4812            Ok(())
4813        }
4814    }
4815
4816    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {
4817        #[inline(always)]
4818        fn new_empty() -> Self {
4819            Self::default()
4820        }
4821
4822        unsafe fn decode(
4823            &mut self,
4824            decoder: &mut fidl::encoding::Decoder<
4825                '_,
4826                fidl::encoding::DefaultFuchsiaResourceDialect,
4827            >,
4828            offset: usize,
4829            mut depth: fidl::encoding::Depth,
4830        ) -> fidl::Result<()> {
4831            decoder.debug_check_bounds::<Self>(offset);
4832            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4833                None => return Err(fidl::Error::NotNullable),
4834                Some(len) => len,
4835            };
4836            // Calling decoder.out_of_line_offset(0) is not allowed.
4837            if len == 0 {
4838                return Ok(());
4839            };
4840            depth.increment()?;
4841            let envelope_size = 8;
4842            let bytes_len = len * envelope_size;
4843            let offset = decoder.out_of_line_offset(bytes_len)?;
4844            // Decode the envelope for each type.
4845            let mut _next_ordinal_to_read = 0;
4846            let mut next_offset = offset;
4847            let end_offset = offset + bytes_len;
4848            _next_ordinal_to_read += 1;
4849            if next_offset >= end_offset {
4850                return Ok(());
4851            }
4852
4853            // Decode unknown envelopes for gaps in ordinals.
4854            while _next_ordinal_to_read < 1 {
4855                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4856                _next_ordinal_to_read += 1;
4857                next_offset += envelope_size;
4858            }
4859
4860            let next_out_of_line = decoder.next_out_of_line();
4861            let handles_before = decoder.remaining_handles();
4862            if let Some((inlined, num_bytes, num_handles)) =
4863                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4864            {
4865                let member_inline_size =
4866                    <ExecutionState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4867                if inlined != (member_inline_size <= 4) {
4868                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4869                }
4870                let inner_offset;
4871                let mut inner_depth = depth.clone();
4872                if inlined {
4873                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4874                    inner_offset = next_offset;
4875                } else {
4876                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4877                    inner_depth.increment()?;
4878                }
4879                let val_ref = self.execution_state.get_or_insert_with(|| {
4880                    fidl::new_empty!(ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect)
4881                });
4882                fidl::decode!(
4883                    ExecutionState,
4884                    fidl::encoding::DefaultFuchsiaResourceDialect,
4885                    val_ref,
4886                    decoder,
4887                    inner_offset,
4888                    inner_depth
4889                )?;
4890                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4891                {
4892                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4893                }
4894                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4895                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4896                }
4897            }
4898
4899            next_offset += envelope_size;
4900            _next_ordinal_to_read += 1;
4901            if next_offset >= end_offset {
4902                return Ok(());
4903            }
4904
4905            // Decode unknown envelopes for gaps in ordinals.
4906            while _next_ordinal_to_read < 3 {
4907                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4908                _next_ordinal_to_read += 1;
4909                next_offset += envelope_size;
4910            }
4911
4912            let next_out_of_line = decoder.next_out_of_line();
4913            let handles_before = decoder.remaining_handles();
4914            if let Some((inlined, num_bytes, num_handles)) =
4915                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4916            {
4917                let member_inline_size =
4918                    <ApplicationActivity as fidl::encoding::TypeMarker>::inline_size(
4919                        decoder.context,
4920                    );
4921                if inlined != (member_inline_size <= 4) {
4922                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4923                }
4924                let inner_offset;
4925                let mut inner_depth = depth.clone();
4926                if inlined {
4927                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4928                    inner_offset = next_offset;
4929                } else {
4930                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4931                    inner_depth.increment()?;
4932                }
4933                let val_ref = self.application_activity.get_or_insert_with(|| {
4934                    fidl::new_empty!(
4935                        ApplicationActivity,
4936                        fidl::encoding::DefaultFuchsiaResourceDialect
4937                    )
4938                });
4939                fidl::decode!(
4940                    ApplicationActivity,
4941                    fidl::encoding::DefaultFuchsiaResourceDialect,
4942                    val_ref,
4943                    decoder,
4944                    inner_offset,
4945                    inner_depth
4946                )?;
4947                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4948                {
4949                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4950                }
4951                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4952                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4953                }
4954            }
4955
4956            next_offset += envelope_size;
4957
4958            // Decode the remaining unknown envelopes.
4959            while next_offset < end_offset {
4960                _next_ordinal_to_read += 1;
4961                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4962                next_offset += envelope_size;
4963            }
4964
4965            Ok(())
4966        }
4967    }
4968}