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