Skip to main content

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 ActivityGovernorAcquireWakeLeaseWithTokenRequest {
18    /// The name of the lease.
19    ///
20    /// The name cannot be empty but is not required to be globally unique.
21    pub name: String,
22    /// The server side of the token that blocks hardware platform
23    /// suspension. The caller should give out handles to the client side
24    /// of the `LeaseToken` which is peered to this `server_token`.
25    pub server_token: fidl::EventPair,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
29    for ActivityGovernorAcquireWakeLeaseWithTokenRequest
30{
31}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct ActivityGovernorAcquireUnmonitoredWakeLeaseResponse {
35    /// The token that blocks hardware platform suspension.
36    pub token: fidl::EventPair,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for ActivityGovernorAcquireUnmonitoredWakeLeaseResponse
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct ActivityGovernorAcquireWakeLeaseResponse {
46    /// The token that blocks hardware platform suspension.
47    pub token: fidl::EventPair,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
51    for ActivityGovernorAcquireWakeLeaseResponse
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct ActivityGovernorRegisterSuspendBlockerResponse {
57    /// The token that blocks hardware platform suspension.
58    pub token: fidl::EventPair,
59}
60
61impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
62    for ActivityGovernorRegisterSuspendBlockerResponse
63{
64}
65
66#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct ActivityGovernorTakeApplicationActivityLeaseResponse {
68    /// The token that blocks application activity from dropping below the
69    /// 'Active' state.
70    pub token: fidl::EventPair,
71}
72
73impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
74    for ActivityGovernorTakeApplicationActivityLeaseResponse
75{
76}
77
78#[derive(Debug, Default, PartialEq)]
79pub struct ActivityGovernorRegisterSuspendBlockerRequest {
80    /// The client end of the SuspendBlocker service.
81    ///
82    /// Required.
83    pub suspend_blocker: Option<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
84    /// The name of the suspend blocker.
85    ///
86    /// Required.
87    ///
88    /// The name cannot be empty but is not required to be globally unique.
89    pub name: Option<String>,
90    #[doc(hidden)]
91    pub __source_breaking: fidl::marker::SourceBreaking,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
95    for ActivityGovernorRegisterSuspendBlockerRequest
96{
97}
98
99/// Holds tokens to the application activity power element.
100///
101/// [`fuchsia.power.system/ApplicationActivityLevel`] defines the power levels supported by this power element.
102#[derive(Debug, Default, PartialEq)]
103pub struct ApplicationActivity {
104    pub assertive_dependency_token: Option<fidl::Event>,
105    #[doc(hidden)]
106    pub __source_breaking: fidl::marker::SourceBreaking,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ApplicationActivity {}
110
111/// Holds tokens to the CPU power element.
112///
113/// [`fuchsia.power.system/CpuLevel`] defines the power levels supported by this power element.
114#[derive(Debug, Default, PartialEq)]
115pub struct Cpu {
116    pub assertive_dependency_token: Option<fidl::Event>,
117    #[doc(hidden)]
118    pub __source_breaking: fidl::marker::SourceBreaking,
119}
120
121impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {}
122
123#[derive(Debug, Default, PartialEq)]
124pub struct CpuElementManagerAddExecutionStateDependencyRequest {
125    /// The assertive dependency token representing the target power element
126    /// of the dependency.
127    /// Required.
128    pub dependency_token: Option<fidl::Event>,
129    /// The power level of the target power element.
130    /// Required.
131    pub power_level: Option<u8>,
132    #[doc(hidden)]
133    pub __source_breaking: fidl::marker::SourceBreaking,
134}
135
136impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
137    for CpuElementManagerAddExecutionStateDependencyRequest
138{
139}
140
141/// Holds the dependency token for the Execution State power element.
142#[derive(Debug, Default, PartialEq)]
143pub struct ExecutionState {
144    pub dependency_token: Option<fidl::Event>,
145    #[doc(hidden)]
146    pub __source_breaking: fidl::marker::SourceBreaking,
147}
148
149impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ExecutionState {}
150
151#[derive(Debug, Default, PartialEq)]
152pub struct ExecutionStateManagerAddApplicationActivityDependencyRequest {
153    /// The dependency token representing the target power element of this dependency.
154    /// Required.
155    pub dependency_token: Option<fidl::Event>,
156    /// The power level of the target power element.
157    /// Required.
158    pub power_level: Option<u8>,
159    #[doc(hidden)]
160    pub __source_breaking: fidl::marker::SourceBreaking,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
164    for ExecutionStateManagerAddApplicationActivityDependencyRequest
165{
166}
167
168/// A collection of power elements that are managed by the activity governor.
169#[derive(Debug, Default, PartialEq)]
170pub struct PowerElements {
171    pub application_activity: Option<ApplicationActivity>,
172    #[doc(hidden)]
173    pub __source_breaking: fidl::marker::SourceBreaking,
174}
175
176impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {}
177
178#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
179pub struct ActivityGovernorMarker;
180
181impl fidl::endpoints::ProtocolMarker for ActivityGovernorMarker {
182    type Proxy = ActivityGovernorProxy;
183    type RequestStream = ActivityGovernorRequestStream;
184    #[cfg(target_os = "fuchsia")]
185    type SynchronousProxy = ActivityGovernorSynchronousProxy;
186
187    const DEBUG_NAME: &'static str = "fuchsia.power.system.ActivityGovernor";
188}
189impl fidl::endpoints::DiscoverableProtocolMarker for ActivityGovernorMarker {}
190pub type ActivityGovernorAcquireWakeLeaseResult = Result<fidl::EventPair, AcquireWakeLeaseError>;
191pub type ActivityGovernorAcquireUnmonitoredWakeLeaseResult =
192    Result<fidl::EventPair, AcquireWakeLeaseError>;
193pub type ActivityGovernorAcquireWakeLeaseWithTokenResult = Result<(), AcquireWakeLeaseError>;
194pub type ActivityGovernorRegisterSuspendBlockerResult =
195    Result<fidl::EventPair, RegisterSuspendBlockerError>;
196
197pub trait ActivityGovernorProxyInterface: Send + Sync {
198    type GetPowerElementsResponseFut: std::future::Future<Output = Result<PowerElements, fidl::Error>>
199        + Send;
200    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut;
201    type AcquireWakeLeaseResponseFut: std::future::Future<Output = Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error>>
202        + Send;
203    fn r#acquire_wake_lease(&self, name: &str) -> Self::AcquireWakeLeaseResponseFut;
204    type AcquireUnmonitoredWakeLeaseResponseFut: std::future::Future<
205            Output = Result<ActivityGovernorAcquireUnmonitoredWakeLeaseResult, fidl::Error>,
206        > + Send;
207    fn r#acquire_unmonitored_wake_lease(
208        &self,
209        name: &str,
210    ) -> Self::AcquireUnmonitoredWakeLeaseResponseFut;
211    type AcquireWakeLeaseWithTokenResponseFut: std::future::Future<
212            Output = Result<ActivityGovernorAcquireWakeLeaseWithTokenResult, fidl::Error>,
213        > + Send;
214    fn r#acquire_wake_lease_with_token(
215        &self,
216        name: &str,
217        server_token: fidl::EventPair,
218    ) -> Self::AcquireWakeLeaseWithTokenResponseFut;
219    type TakeApplicationActivityLeaseResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
220        + Send;
221    fn r#take_application_activity_lease(
222        &self,
223        name: &str,
224    ) -> Self::TakeApplicationActivityLeaseResponseFut;
225    type RegisterSuspendBlockerResponseFut: std::future::Future<
226            Output = Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error>,
227        > + Send;
228    fn r#register_suspend_blocker(
229        &self,
230        payload: ActivityGovernorRegisterSuspendBlockerRequest,
231    ) -> Self::RegisterSuspendBlockerResponseFut;
232}
233#[derive(Debug)]
234#[cfg(target_os = "fuchsia")]
235pub struct ActivityGovernorSynchronousProxy {
236    client: fidl::client::sync::Client,
237}
238
239#[cfg(target_os = "fuchsia")]
240impl fidl::endpoints::SynchronousProxy for ActivityGovernorSynchronousProxy {
241    type Proxy = ActivityGovernorProxy;
242    type Protocol = ActivityGovernorMarker;
243
244    fn from_channel(inner: fidl::Channel) -> Self {
245        Self::new(inner)
246    }
247
248    fn into_channel(self) -> fidl::Channel {
249        self.client.into_channel()
250    }
251
252    fn as_channel(&self) -> &fidl::Channel {
253        self.client.as_channel()
254    }
255}
256
257#[cfg(target_os = "fuchsia")]
258impl ActivityGovernorSynchronousProxy {
259    pub fn new(channel: fidl::Channel) -> Self {
260        Self { client: fidl::client::sync::Client::new(channel) }
261    }
262
263    pub fn into_channel(self) -> fidl::Channel {
264        self.client.into_channel()
265    }
266
267    /// Waits until an event arrives and returns it. It is safe for other
268    /// threads to make concurrent requests while waiting for an event.
269    pub fn wait_for_event(
270        &self,
271        deadline: zx::MonotonicInstant,
272    ) -> Result<ActivityGovernorEvent, fidl::Error> {
273        ActivityGovernorEvent::decode(
274            self.client.wait_for_event::<ActivityGovernorMarker>(deadline)?,
275        )
276    }
277
278    /// Gets the power elements owned by the activity governor.
279    ///
280    /// If an error occurs while the server is registering a power element with
281    /// the power broker or an error occurs while creating a token for a power
282    /// element, then the channel to `ActivityGovernor` will be closed by the
283    /// server and no response will be returned.
284    pub fn r#get_power_elements(
285        &self,
286        ___deadline: zx::MonotonicInstant,
287    ) -> Result<PowerElements, fidl::Error> {
288        let _response = self.client.send_query::<
289            fidl::encoding::EmptyPayload,
290            fidl::encoding::FlexibleType<PowerElements>,
291            ActivityGovernorMarker,
292        >(
293            (),
294            0x798003259dfb5672,
295            fidl::encoding::DynamicFlags::FLEXIBLE,
296            ___deadline,
297        )?
298        .into_result::<ActivityGovernorMarker>("get_power_elements")?;
299        Ok(_response)
300    }
301
302    /// Creates a lease that blocks suspension of the hardware platform.
303    ///
304    /// The hardware platform will not suspend as long as a valid
305    /// [`LeaseToken`] exists.
306    pub fn r#acquire_wake_lease(
307        &self,
308        mut name: &str,
309        ___deadline: zx::MonotonicInstant,
310    ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
311        let _response = self.client.send_query::<
312            ActivityGovernorAcquireWakeLeaseRequest,
313            fidl::encoding::FlexibleResultType<ActivityGovernorAcquireWakeLeaseResponse, AcquireWakeLeaseError>,
314            ActivityGovernorMarker,
315        >(
316            (name,),
317            0x2de25abd8fa7c103,
318            fidl::encoding::DynamicFlags::FLEXIBLE,
319            ___deadline,
320        )?
321        .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
322        Ok(_response.map(|x| x.token))
323    }
324
325    /// Creates an unmonitored lease that blocks suspension of the hardware platform.
326    ///
327    /// The hardware platform will not suspend as long as a valid
328    /// [`LeaseToken`] exists.
329    ///
330    /// This is intended for leases expected to be held for extended periods.
331    /// Unlike normal wake leases, the server does not monitor the duration
332    /// of an unmonitored wake lease and will not file a crash report if it exceeds
333    /// preconfigured alert thresholds.
334    pub fn r#acquire_unmonitored_wake_lease(
335        &self,
336        mut name: &str,
337        ___deadline: zx::MonotonicInstant,
338    ) -> Result<ActivityGovernorAcquireUnmonitoredWakeLeaseResult, fidl::Error> {
339        let _response = self.client.send_query::<
340            ActivityGovernorAcquireUnmonitoredWakeLeaseRequest,
341            fidl::encoding::FlexibleResultType<ActivityGovernorAcquireUnmonitoredWakeLeaseResponse, AcquireWakeLeaseError>,
342            ActivityGovernorMarker,
343        >(
344            (name,),
345            0x5f7007d6b0786da9,
346            fidl::encoding::DynamicFlags::FLEXIBLE,
347            ___deadline,
348        )?
349        .into_result::<ActivityGovernorMarker>("acquire_unmonitored_wake_lease")?;
350        Ok(_response.map(|x| x.token))
351    }
352
353    /// Creates a lease that blocks suspension of the hardware platform.
354    /// WARNING: Suspension can only be considered blocked after the client
355    /// receives the response to this call. This means, for example, an
356    /// interrupt should only be ack'ed or a different wake lease dropped only
357    /// **after** getting an error-free response.
358    ///
359    /// The hardware platform will remain resumed until `server_token` observes
360    /// `PEER_CLOSED`, indicating all handles to the client side of the
361    /// `LeaseToken` are closed.
362    pub fn r#acquire_wake_lease_with_token(
363        &self,
364        mut name: &str,
365        mut server_token: fidl::EventPair,
366        ___deadline: zx::MonotonicInstant,
367    ) -> Result<ActivityGovernorAcquireWakeLeaseWithTokenResult, fidl::Error> {
368        let _response = self.client.send_query::<
369            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
370            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, AcquireWakeLeaseError>,
371            ActivityGovernorMarker,
372        >(
373            (name, server_token,),
374            0x1cdd2ea3bee46f51,
375            fidl::encoding::DynamicFlags::FLEXIBLE,
376            ___deadline,
377        )?
378        .into_result::<ActivityGovernorMarker>("acquire_wake_lease_with_token")?;
379        Ok(_response.map(|x| x))
380    }
381
382    /// Creates a lease that blocks the system from dropping below the Application
383    /// Activity 'Active' state. In particular, this blocks suspension of the
384    /// hardware platform.
385    ///
386    /// This method is _not_ safe to call during SuspendBlocker.BeforeSuspend.
387    ///
388    /// If an error occurs while creating a token for the activity lease, then the
389    /// channel to `ActivityGovernor` will be closed by the server and no
390    /// response will be returned.
391    pub fn r#take_application_activity_lease(
392        &self,
393        mut name: &str,
394        ___deadline: zx::MonotonicInstant,
395    ) -> Result<fidl::EventPair, fidl::Error> {
396        let _response = self.client.send_query::<
397            ActivityGovernorTakeApplicationActivityLeaseRequest,
398            fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
399            ActivityGovernorMarker,
400        >(
401            (name,),
402            0x37cd5364de7ada14,
403            fidl::encoding::DynamicFlags::FLEXIBLE,
404            ___deadline,
405        )?
406        .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
407        Ok(_response.token)
408    }
409
410    /// Registers a suspend blocker.
411    ///
412    /// On successful registration, a wake lease token is returned. This token
413    /// prevents hardware platform suspension while it exists. Clients are
414    /// expected to perform any initialization of the given `suspend_blocker`
415    /// server while holding this token. Additionally, this means the first call
416    /// `suspend_blocker` will get is `BeforeSuspend`.
417    ///
418    /// To unregister, close the `SuspendBlocker` channel.
419    ///
420    /// If any required field of the table is missing, the error
421    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
422    ///
423    /// If an error occurs while registering `suspend_blocker`, it will be
424    /// dropped, closing the channel.
425    pub fn r#register_suspend_blocker(
426        &self,
427        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
428        ___deadline: zx::MonotonicInstant,
429    ) -> Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error> {
430        let _response = self.client.send_query::<
431            ActivityGovernorRegisterSuspendBlockerRequest,
432            fidl::encoding::FlexibleResultType<ActivityGovernorRegisterSuspendBlockerResponse, RegisterSuspendBlockerError>,
433            ActivityGovernorMarker,
434        >(
435            &mut payload,
436            0x34ef55b180feef01,
437            fidl::encoding::DynamicFlags::FLEXIBLE,
438            ___deadline,
439        )?
440        .into_result::<ActivityGovernorMarker>("register_suspend_blocker")?;
441        Ok(_response.map(|x| x.token))
442    }
443}
444
445#[cfg(target_os = "fuchsia")]
446impl From<ActivityGovernorSynchronousProxy> for zx::NullableHandle {
447    fn from(value: ActivityGovernorSynchronousProxy) -> Self {
448        value.into_channel().into()
449    }
450}
451
452#[cfg(target_os = "fuchsia")]
453impl From<fidl::Channel> for ActivityGovernorSynchronousProxy {
454    fn from(value: fidl::Channel) -> Self {
455        Self::new(value)
456    }
457}
458
459#[cfg(target_os = "fuchsia")]
460impl fidl::endpoints::FromClient for ActivityGovernorSynchronousProxy {
461    type Protocol = ActivityGovernorMarker;
462
463    fn from_client(value: fidl::endpoints::ClientEnd<ActivityGovernorMarker>) -> Self {
464        Self::new(value.into_channel())
465    }
466}
467
468#[derive(Debug, Clone)]
469pub struct ActivityGovernorProxy {
470    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
471}
472
473impl fidl::endpoints::Proxy for ActivityGovernorProxy {
474    type Protocol = ActivityGovernorMarker;
475
476    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
477        Self::new(inner)
478    }
479
480    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
481        self.client.into_channel().map_err(|client| Self { client })
482    }
483
484    fn as_channel(&self) -> &::fidl::AsyncChannel {
485        self.client.as_channel()
486    }
487}
488
489impl ActivityGovernorProxy {
490    /// Create a new Proxy for fuchsia.power.system/ActivityGovernor.
491    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
492        let protocol_name = <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
493        Self { client: fidl::client::Client::new(channel, protocol_name) }
494    }
495
496    /// Get a Stream of events from the remote end of the protocol.
497    ///
498    /// # Panics
499    ///
500    /// Panics if the event stream was already taken.
501    pub fn take_event_stream(&self) -> ActivityGovernorEventStream {
502        ActivityGovernorEventStream { event_receiver: self.client.take_event_receiver() }
503    }
504
505    /// Gets the power elements owned by the activity governor.
506    ///
507    /// If an error occurs while the server is registering a power element with
508    /// the power broker or an error occurs while creating a token for a power
509    /// element, then the channel to `ActivityGovernor` will be closed by the
510    /// server and no response will be returned.
511    pub fn r#get_power_elements(
512        &self,
513    ) -> fidl::client::QueryResponseFut<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
514    {
515        ActivityGovernorProxyInterface::r#get_power_elements(self)
516    }
517
518    /// Creates a lease that blocks suspension of the hardware platform.
519    ///
520    /// The hardware platform will not suspend as long as a valid
521    /// [`LeaseToken`] exists.
522    pub fn r#acquire_wake_lease(
523        &self,
524        mut name: &str,
525    ) -> fidl::client::QueryResponseFut<
526        ActivityGovernorAcquireWakeLeaseResult,
527        fidl::encoding::DefaultFuchsiaResourceDialect,
528    > {
529        ActivityGovernorProxyInterface::r#acquire_wake_lease(self, name)
530    }
531
532    /// Creates an unmonitored lease that blocks suspension of the hardware platform.
533    ///
534    /// The hardware platform will not suspend as long as a valid
535    /// [`LeaseToken`] exists.
536    ///
537    /// This is intended for leases expected to be held for extended periods.
538    /// Unlike normal wake leases, the server does not monitor the duration
539    /// of an unmonitored wake lease and will not file a crash report if it exceeds
540    /// preconfigured alert thresholds.
541    pub fn r#acquire_unmonitored_wake_lease(
542        &self,
543        mut name: &str,
544    ) -> fidl::client::QueryResponseFut<
545        ActivityGovernorAcquireUnmonitoredWakeLeaseResult,
546        fidl::encoding::DefaultFuchsiaResourceDialect,
547    > {
548        ActivityGovernorProxyInterface::r#acquire_unmonitored_wake_lease(self, name)
549    }
550
551    /// Creates a lease that blocks suspension of the hardware platform.
552    /// WARNING: Suspension can only be considered blocked after the client
553    /// receives the response to this call. This means, for example, an
554    /// interrupt should only be ack'ed or a different wake lease dropped only
555    /// **after** getting an error-free response.
556    ///
557    /// The hardware platform will remain resumed until `server_token` observes
558    /// `PEER_CLOSED`, indicating all handles to the client side of the
559    /// `LeaseToken` are closed.
560    pub fn r#acquire_wake_lease_with_token(
561        &self,
562        mut name: &str,
563        mut server_token: fidl::EventPair,
564    ) -> fidl::client::QueryResponseFut<
565        ActivityGovernorAcquireWakeLeaseWithTokenResult,
566        fidl::encoding::DefaultFuchsiaResourceDialect,
567    > {
568        ActivityGovernorProxyInterface::r#acquire_wake_lease_with_token(self, name, server_token)
569    }
570
571    /// Creates a lease that blocks the system from dropping below the Application
572    /// Activity 'Active' state. In particular, this blocks suspension of the
573    /// hardware platform.
574    ///
575    /// This method is _not_ safe to call during SuspendBlocker.BeforeSuspend.
576    ///
577    /// If an error occurs while creating a token for the activity lease, then the
578    /// channel to `ActivityGovernor` will be closed by the server and no
579    /// response will be returned.
580    pub fn r#take_application_activity_lease(
581        &self,
582        mut name: &str,
583    ) -> fidl::client::QueryResponseFut<
584        fidl::EventPair,
585        fidl::encoding::DefaultFuchsiaResourceDialect,
586    > {
587        ActivityGovernorProxyInterface::r#take_application_activity_lease(self, name)
588    }
589
590    /// Registers a suspend blocker.
591    ///
592    /// On successful registration, a wake lease token is returned. This token
593    /// prevents hardware platform suspension while it exists. Clients are
594    /// expected to perform any initialization of the given `suspend_blocker`
595    /// server while holding this token. Additionally, this means the first call
596    /// `suspend_blocker` will get is `BeforeSuspend`.
597    ///
598    /// To unregister, close the `SuspendBlocker` channel.
599    ///
600    /// If any required field of the table is missing, the error
601    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
602    ///
603    /// If an error occurs while registering `suspend_blocker`, it will be
604    /// dropped, closing the channel.
605    pub fn r#register_suspend_blocker(
606        &self,
607        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
608    ) -> fidl::client::QueryResponseFut<
609        ActivityGovernorRegisterSuspendBlockerResult,
610        fidl::encoding::DefaultFuchsiaResourceDialect,
611    > {
612        ActivityGovernorProxyInterface::r#register_suspend_blocker(self, payload)
613    }
614}
615
616impl ActivityGovernorProxyInterface for ActivityGovernorProxy {
617    type GetPowerElementsResponseFut = fidl::client::QueryResponseFut<
618        PowerElements,
619        fidl::encoding::DefaultFuchsiaResourceDialect,
620    >;
621    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut {
622        fn _decode(
623            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
624        ) -> Result<PowerElements, fidl::Error> {
625            let _response = fidl::client::decode_transaction_body::<
626                fidl::encoding::FlexibleType<PowerElements>,
627                fidl::encoding::DefaultFuchsiaResourceDialect,
628                0x798003259dfb5672,
629            >(_buf?)?
630            .into_result::<ActivityGovernorMarker>("get_power_elements")?;
631            Ok(_response)
632        }
633        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PowerElements>(
634            (),
635            0x798003259dfb5672,
636            fidl::encoding::DynamicFlags::FLEXIBLE,
637            _decode,
638        )
639    }
640
641    type AcquireWakeLeaseResponseFut = fidl::client::QueryResponseFut<
642        ActivityGovernorAcquireWakeLeaseResult,
643        fidl::encoding::DefaultFuchsiaResourceDialect,
644    >;
645    fn r#acquire_wake_lease(&self, mut name: &str) -> Self::AcquireWakeLeaseResponseFut {
646        fn _decode(
647            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
648        ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
649            let _response = fidl::client::decode_transaction_body::<
650                fidl::encoding::FlexibleResultType<
651                    ActivityGovernorAcquireWakeLeaseResponse,
652                    AcquireWakeLeaseError,
653                >,
654                fidl::encoding::DefaultFuchsiaResourceDialect,
655                0x2de25abd8fa7c103,
656            >(_buf?)?
657            .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
658            Ok(_response.map(|x| x.token))
659        }
660        self.client.send_query_and_decode::<
661            ActivityGovernorAcquireWakeLeaseRequest,
662            ActivityGovernorAcquireWakeLeaseResult,
663        >(
664            (name,),
665            0x2de25abd8fa7c103,
666            fidl::encoding::DynamicFlags::FLEXIBLE,
667            _decode,
668        )
669    }
670
671    type AcquireUnmonitoredWakeLeaseResponseFut = fidl::client::QueryResponseFut<
672        ActivityGovernorAcquireUnmonitoredWakeLeaseResult,
673        fidl::encoding::DefaultFuchsiaResourceDialect,
674    >;
675    fn r#acquire_unmonitored_wake_lease(
676        &self,
677        mut name: &str,
678    ) -> Self::AcquireUnmonitoredWakeLeaseResponseFut {
679        fn _decode(
680            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
681        ) -> Result<ActivityGovernorAcquireUnmonitoredWakeLeaseResult, fidl::Error> {
682            let _response = fidl::client::decode_transaction_body::<
683                fidl::encoding::FlexibleResultType<
684                    ActivityGovernorAcquireUnmonitoredWakeLeaseResponse,
685                    AcquireWakeLeaseError,
686                >,
687                fidl::encoding::DefaultFuchsiaResourceDialect,
688                0x5f7007d6b0786da9,
689            >(_buf?)?
690            .into_result::<ActivityGovernorMarker>("acquire_unmonitored_wake_lease")?;
691            Ok(_response.map(|x| x.token))
692        }
693        self.client.send_query_and_decode::<
694            ActivityGovernorAcquireUnmonitoredWakeLeaseRequest,
695            ActivityGovernorAcquireUnmonitoredWakeLeaseResult,
696        >(
697            (name,),
698            0x5f7007d6b0786da9,
699            fidl::encoding::DynamicFlags::FLEXIBLE,
700            _decode,
701        )
702    }
703
704    type AcquireWakeLeaseWithTokenResponseFut = fidl::client::QueryResponseFut<
705        ActivityGovernorAcquireWakeLeaseWithTokenResult,
706        fidl::encoding::DefaultFuchsiaResourceDialect,
707    >;
708    fn r#acquire_wake_lease_with_token(
709        &self,
710        mut name: &str,
711        mut server_token: fidl::EventPair,
712    ) -> Self::AcquireWakeLeaseWithTokenResponseFut {
713        fn _decode(
714            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
715        ) -> Result<ActivityGovernorAcquireWakeLeaseWithTokenResult, fidl::Error> {
716            let _response = fidl::client::decode_transaction_body::<
717                fidl::encoding::FlexibleResultType<
718                    fidl::encoding::EmptyStruct,
719                    AcquireWakeLeaseError,
720                >,
721                fidl::encoding::DefaultFuchsiaResourceDialect,
722                0x1cdd2ea3bee46f51,
723            >(_buf?)?
724            .into_result::<ActivityGovernorMarker>("acquire_wake_lease_with_token")?;
725            Ok(_response.map(|x| x))
726        }
727        self.client.send_query_and_decode::<
728            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
729            ActivityGovernorAcquireWakeLeaseWithTokenResult,
730        >(
731            (name, server_token,),
732            0x1cdd2ea3bee46f51,
733            fidl::encoding::DynamicFlags::FLEXIBLE,
734            _decode,
735        )
736    }
737
738    type TakeApplicationActivityLeaseResponseFut = fidl::client::QueryResponseFut<
739        fidl::EventPair,
740        fidl::encoding::DefaultFuchsiaResourceDialect,
741    >;
742    fn r#take_application_activity_lease(
743        &self,
744        mut name: &str,
745    ) -> Self::TakeApplicationActivityLeaseResponseFut {
746        fn _decode(
747            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
748        ) -> Result<fidl::EventPair, fidl::Error> {
749            let _response = fidl::client::decode_transaction_body::<
750                fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
751                fidl::encoding::DefaultFuchsiaResourceDialect,
752                0x37cd5364de7ada14,
753            >(_buf?)?
754            .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
755            Ok(_response.token)
756        }
757        self.client.send_query_and_decode::<
758            ActivityGovernorTakeApplicationActivityLeaseRequest,
759            fidl::EventPair,
760        >(
761            (name,),
762            0x37cd5364de7ada14,
763            fidl::encoding::DynamicFlags::FLEXIBLE,
764            _decode,
765        )
766    }
767
768    type RegisterSuspendBlockerResponseFut = fidl::client::QueryResponseFut<
769        ActivityGovernorRegisterSuspendBlockerResult,
770        fidl::encoding::DefaultFuchsiaResourceDialect,
771    >;
772    fn r#register_suspend_blocker(
773        &self,
774        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
775    ) -> Self::RegisterSuspendBlockerResponseFut {
776        fn _decode(
777            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
778        ) -> Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error> {
779            let _response = fidl::client::decode_transaction_body::<
780                fidl::encoding::FlexibleResultType<
781                    ActivityGovernorRegisterSuspendBlockerResponse,
782                    RegisterSuspendBlockerError,
783                >,
784                fidl::encoding::DefaultFuchsiaResourceDialect,
785                0x34ef55b180feef01,
786            >(_buf?)?
787            .into_result::<ActivityGovernorMarker>("register_suspend_blocker")?;
788            Ok(_response.map(|x| x.token))
789        }
790        self.client.send_query_and_decode::<
791            ActivityGovernorRegisterSuspendBlockerRequest,
792            ActivityGovernorRegisterSuspendBlockerResult,
793        >(
794            &mut payload,
795            0x34ef55b180feef01,
796            fidl::encoding::DynamicFlags::FLEXIBLE,
797            _decode,
798        )
799    }
800}
801
802pub struct ActivityGovernorEventStream {
803    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
804}
805
806impl std::marker::Unpin for ActivityGovernorEventStream {}
807
808impl futures::stream::FusedStream for ActivityGovernorEventStream {
809    fn is_terminated(&self) -> bool {
810        self.event_receiver.is_terminated()
811    }
812}
813
814impl futures::Stream for ActivityGovernorEventStream {
815    type Item = Result<ActivityGovernorEvent, fidl::Error>;
816
817    fn poll_next(
818        mut self: std::pin::Pin<&mut Self>,
819        cx: &mut std::task::Context<'_>,
820    ) -> std::task::Poll<Option<Self::Item>> {
821        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
822            &mut self.event_receiver,
823            cx
824        )?) {
825            Some(buf) => std::task::Poll::Ready(Some(ActivityGovernorEvent::decode(buf))),
826            None => std::task::Poll::Ready(None),
827        }
828    }
829}
830
831#[derive(Debug)]
832pub enum ActivityGovernorEvent {
833    #[non_exhaustive]
834    _UnknownEvent {
835        /// Ordinal of the event that was sent.
836        ordinal: u64,
837    },
838}
839
840impl ActivityGovernorEvent {
841    /// Decodes a message buffer as a [`ActivityGovernorEvent`].
842    fn decode(
843        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
844    ) -> Result<ActivityGovernorEvent, fidl::Error> {
845        let (bytes, _handles) = buf.split_mut();
846        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
847        debug_assert_eq!(tx_header.tx_id, 0);
848        match tx_header.ordinal {
849            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
850                Ok(ActivityGovernorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
851            }
852            _ => Err(fidl::Error::UnknownOrdinal {
853                ordinal: tx_header.ordinal,
854                protocol_name:
855                    <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
856            }),
857        }
858    }
859}
860
861/// A Stream of incoming requests for fuchsia.power.system/ActivityGovernor.
862pub struct ActivityGovernorRequestStream {
863    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
864    is_terminated: bool,
865}
866
867impl std::marker::Unpin for ActivityGovernorRequestStream {}
868
869impl futures::stream::FusedStream for ActivityGovernorRequestStream {
870    fn is_terminated(&self) -> bool {
871        self.is_terminated
872    }
873}
874
875impl fidl::endpoints::RequestStream for ActivityGovernorRequestStream {
876    type Protocol = ActivityGovernorMarker;
877    type ControlHandle = ActivityGovernorControlHandle;
878
879    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
880        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
881    }
882
883    fn control_handle(&self) -> Self::ControlHandle {
884        ActivityGovernorControlHandle { inner: self.inner.clone() }
885    }
886
887    fn into_inner(
888        self,
889    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
890    {
891        (self.inner, self.is_terminated)
892    }
893
894    fn from_inner(
895        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
896        is_terminated: bool,
897    ) -> Self {
898        Self { inner, is_terminated }
899    }
900}
901
902impl futures::Stream for ActivityGovernorRequestStream {
903    type Item = Result<ActivityGovernorRequest, fidl::Error>;
904
905    fn poll_next(
906        mut self: std::pin::Pin<&mut Self>,
907        cx: &mut std::task::Context<'_>,
908    ) -> std::task::Poll<Option<Self::Item>> {
909        let this = &mut *self;
910        if this.inner.check_shutdown(cx) {
911            this.is_terminated = true;
912            return std::task::Poll::Ready(None);
913        }
914        if this.is_terminated {
915            panic!("polled ActivityGovernorRequestStream after completion");
916        }
917        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
918            |bytes, handles| {
919                match this.inner.channel().read_etc(cx, bytes, handles) {
920                    std::task::Poll::Ready(Ok(())) => {}
921                    std::task::Poll::Pending => return std::task::Poll::Pending,
922                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
923                        this.is_terminated = true;
924                        return std::task::Poll::Ready(None);
925                    }
926                    std::task::Poll::Ready(Err(e)) => {
927                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
928                            e.into(),
929                        ))));
930                    }
931                }
932
933                // A message has been received from the channel
934                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
935
936                std::task::Poll::Ready(Some(match header.ordinal {
937                    0x798003259dfb5672 => {
938                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
939                        let mut req = fidl::new_empty!(
940                            fidl::encoding::EmptyPayload,
941                            fidl::encoding::DefaultFuchsiaResourceDialect
942                        );
943                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
944                        let control_handle =
945                            ActivityGovernorControlHandle { inner: this.inner.clone() };
946                        Ok(ActivityGovernorRequest::GetPowerElements {
947                            responder: ActivityGovernorGetPowerElementsResponder {
948                                control_handle: std::mem::ManuallyDrop::new(control_handle),
949                                tx_id: header.tx_id,
950                            },
951                        })
952                    }
953                    0x2de25abd8fa7c103 => {
954                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
955                        let mut req = fidl::new_empty!(
956                            ActivityGovernorAcquireWakeLeaseRequest,
957                            fidl::encoding::DefaultFuchsiaResourceDialect
958                        );
959                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorAcquireWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
960                        let control_handle =
961                            ActivityGovernorControlHandle { inner: this.inner.clone() };
962                        Ok(ActivityGovernorRequest::AcquireWakeLease {
963                            name: req.name,
964
965                            responder: ActivityGovernorAcquireWakeLeaseResponder {
966                                control_handle: std::mem::ManuallyDrop::new(control_handle),
967                                tx_id: header.tx_id,
968                            },
969                        })
970                    }
971                    0x5f7007d6b0786da9 => {
972                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
973                        let mut req = fidl::new_empty!(
974                            ActivityGovernorAcquireUnmonitoredWakeLeaseRequest,
975                            fidl::encoding::DefaultFuchsiaResourceDialect
976                        );
977                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorAcquireUnmonitoredWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
978                        let control_handle =
979                            ActivityGovernorControlHandle { inner: this.inner.clone() };
980                        Ok(ActivityGovernorRequest::AcquireUnmonitoredWakeLease {
981                            name: req.name,
982
983                            responder: ActivityGovernorAcquireUnmonitoredWakeLeaseResponder {
984                                control_handle: std::mem::ManuallyDrop::new(control_handle),
985                                tx_id: header.tx_id,
986                            },
987                        })
988                    }
989                    0x1cdd2ea3bee46f51 => {
990                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
991                        let mut req = fidl::new_empty!(
992                            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
993                            fidl::encoding::DefaultFuchsiaResourceDialect
994                        );
995                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorAcquireWakeLeaseWithTokenRequest>(&header, _body_bytes, handles, &mut req)?;
996                        let control_handle =
997                            ActivityGovernorControlHandle { inner: this.inner.clone() };
998                        Ok(ActivityGovernorRequest::AcquireWakeLeaseWithToken {
999                            name: req.name,
1000                            server_token: req.server_token,
1001
1002                            responder: ActivityGovernorAcquireWakeLeaseWithTokenResponder {
1003                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1004                                tx_id: header.tx_id,
1005                            },
1006                        })
1007                    }
1008                    0x37cd5364de7ada14 => {
1009                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1010                        let mut req = fidl::new_empty!(
1011                            ActivityGovernorTakeApplicationActivityLeaseRequest,
1012                            fidl::encoding::DefaultFuchsiaResourceDialect
1013                        );
1014                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorTakeApplicationActivityLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1015                        let control_handle =
1016                            ActivityGovernorControlHandle { inner: this.inner.clone() };
1017                        Ok(ActivityGovernorRequest::TakeApplicationActivityLease {
1018                            name: req.name,
1019
1020                            responder: ActivityGovernorTakeApplicationActivityLeaseResponder {
1021                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1022                                tx_id: header.tx_id,
1023                            },
1024                        })
1025                    }
1026                    0x34ef55b180feef01 => {
1027                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1028                        let mut req = fidl::new_empty!(
1029                            ActivityGovernorRegisterSuspendBlockerRequest,
1030                            fidl::encoding::DefaultFuchsiaResourceDialect
1031                        );
1032                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorRegisterSuspendBlockerRequest>(&header, _body_bytes, handles, &mut req)?;
1033                        let control_handle =
1034                            ActivityGovernorControlHandle { inner: this.inner.clone() };
1035                        Ok(ActivityGovernorRequest::RegisterSuspendBlocker {
1036                            payload: req,
1037                            responder: ActivityGovernorRegisterSuspendBlockerResponder {
1038                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1039                                tx_id: header.tx_id,
1040                            },
1041                        })
1042                    }
1043                    _ if header.tx_id == 0
1044                        && header
1045                            .dynamic_flags()
1046                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1047                    {
1048                        Ok(ActivityGovernorRequest::_UnknownMethod {
1049                            ordinal: header.ordinal,
1050                            control_handle: ActivityGovernorControlHandle {
1051                                inner: this.inner.clone(),
1052                            },
1053                            method_type: fidl::MethodType::OneWay,
1054                        })
1055                    }
1056                    _ if header
1057                        .dynamic_flags()
1058                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1059                    {
1060                        this.inner.send_framework_err(
1061                            fidl::encoding::FrameworkErr::UnknownMethod,
1062                            header.tx_id,
1063                            header.ordinal,
1064                            header.dynamic_flags(),
1065                            (bytes, handles),
1066                        )?;
1067                        Ok(ActivityGovernorRequest::_UnknownMethod {
1068                            ordinal: header.ordinal,
1069                            control_handle: ActivityGovernorControlHandle {
1070                                inner: this.inner.clone(),
1071                            },
1072                            method_type: fidl::MethodType::TwoWay,
1073                        })
1074                    }
1075                    _ => Err(fidl::Error::UnknownOrdinal {
1076                        ordinal: header.ordinal,
1077                        protocol_name:
1078                            <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1079                    }),
1080                }))
1081            },
1082        )
1083    }
1084}
1085
1086/// A service for exposing events and power elements managed by the system
1087/// activity governor (SAG).
1088///
1089/// SAG is responsible for managing the execution state of the hardware
1090/// platform. The hardware platform consists of the components required to
1091/// execute code on the device. This typically includes the CPU, memory,
1092/// operating system, and other components required for these components to
1093/// function (clock trees, power domains, etc.).
1094#[derive(Debug)]
1095pub enum ActivityGovernorRequest {
1096    /// Gets the power elements owned by the activity governor.
1097    ///
1098    /// If an error occurs while the server is registering a power element with
1099    /// the power broker or an error occurs while creating a token for a power
1100    /// element, then the channel to `ActivityGovernor` will be closed by the
1101    /// server and no response will be returned.
1102    GetPowerElements { responder: ActivityGovernorGetPowerElementsResponder },
1103    /// Creates a lease that blocks suspension of the hardware platform.
1104    ///
1105    /// The hardware platform will not suspend as long as a valid
1106    /// [`LeaseToken`] exists.
1107    AcquireWakeLease { name: String, responder: ActivityGovernorAcquireWakeLeaseResponder },
1108    /// Creates an unmonitored lease that blocks suspension of the hardware platform.
1109    ///
1110    /// The hardware platform will not suspend as long as a valid
1111    /// [`LeaseToken`] exists.
1112    ///
1113    /// This is intended for leases expected to be held for extended periods.
1114    /// Unlike normal wake leases, the server does not monitor the duration
1115    /// of an unmonitored wake lease and will not file a crash report if it exceeds
1116    /// preconfigured alert thresholds.
1117    AcquireUnmonitoredWakeLease {
1118        name: String,
1119        responder: ActivityGovernorAcquireUnmonitoredWakeLeaseResponder,
1120    },
1121    /// Creates a lease that blocks suspension of the hardware platform.
1122    /// WARNING: Suspension can only be considered blocked after the client
1123    /// receives the response to this call. This means, for example, an
1124    /// interrupt should only be ack'ed or a different wake lease dropped only
1125    /// **after** getting an error-free response.
1126    ///
1127    /// The hardware platform will remain resumed until `server_token` observes
1128    /// `PEER_CLOSED`, indicating all handles to the client side of the
1129    /// `LeaseToken` are closed.
1130    AcquireWakeLeaseWithToken {
1131        name: String,
1132        server_token: fidl::EventPair,
1133        responder: ActivityGovernorAcquireWakeLeaseWithTokenResponder,
1134    },
1135    /// Creates a lease that blocks the system from dropping below the Application
1136    /// Activity 'Active' state. In particular, this blocks suspension of the
1137    /// hardware platform.
1138    ///
1139    /// This method is _not_ safe to call during SuspendBlocker.BeforeSuspend.
1140    ///
1141    /// If an error occurs while creating a token for the activity lease, then the
1142    /// channel to `ActivityGovernor` will be closed by the server and no
1143    /// response will be returned.
1144    TakeApplicationActivityLease {
1145        name: String,
1146        responder: ActivityGovernorTakeApplicationActivityLeaseResponder,
1147    },
1148    /// Registers a suspend blocker.
1149    ///
1150    /// On successful registration, a wake lease token is returned. This token
1151    /// prevents hardware platform suspension while it exists. Clients are
1152    /// expected to perform any initialization of the given `suspend_blocker`
1153    /// server while holding this token. Additionally, this means the first call
1154    /// `suspend_blocker` will get is `BeforeSuspend`.
1155    ///
1156    /// To unregister, close the `SuspendBlocker` channel.
1157    ///
1158    /// If any required field of the table is missing, the error
1159    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
1160    ///
1161    /// If an error occurs while registering `suspend_blocker`, it will be
1162    /// dropped, closing the channel.
1163    RegisterSuspendBlocker {
1164        payload: ActivityGovernorRegisterSuspendBlockerRequest,
1165        responder: ActivityGovernorRegisterSuspendBlockerResponder,
1166    },
1167    /// An interaction was received which does not match any known method.
1168    #[non_exhaustive]
1169    _UnknownMethod {
1170        /// Ordinal of the method that was called.
1171        ordinal: u64,
1172        control_handle: ActivityGovernorControlHandle,
1173        method_type: fidl::MethodType,
1174    },
1175}
1176
1177impl ActivityGovernorRequest {
1178    #[allow(irrefutable_let_patterns)]
1179    pub fn into_get_power_elements(self) -> Option<(ActivityGovernorGetPowerElementsResponder)> {
1180        if let ActivityGovernorRequest::GetPowerElements { responder } = self {
1181            Some((responder))
1182        } else {
1183            None
1184        }
1185    }
1186
1187    #[allow(irrefutable_let_patterns)]
1188    pub fn into_acquire_wake_lease(
1189        self,
1190    ) -> Option<(String, ActivityGovernorAcquireWakeLeaseResponder)> {
1191        if let ActivityGovernorRequest::AcquireWakeLease { name, responder } = self {
1192            Some((name, responder))
1193        } else {
1194            None
1195        }
1196    }
1197
1198    #[allow(irrefutable_let_patterns)]
1199    pub fn into_acquire_unmonitored_wake_lease(
1200        self,
1201    ) -> Option<(String, ActivityGovernorAcquireUnmonitoredWakeLeaseResponder)> {
1202        if let ActivityGovernorRequest::AcquireUnmonitoredWakeLease { name, responder } = self {
1203            Some((name, responder))
1204        } else {
1205            None
1206        }
1207    }
1208
1209    #[allow(irrefutable_let_patterns)]
1210    pub fn into_acquire_wake_lease_with_token(
1211        self,
1212    ) -> Option<(String, fidl::EventPair, ActivityGovernorAcquireWakeLeaseWithTokenResponder)> {
1213        if let ActivityGovernorRequest::AcquireWakeLeaseWithToken {
1214            name,
1215            server_token,
1216            responder,
1217        } = self
1218        {
1219            Some((name, server_token, responder))
1220        } else {
1221            None
1222        }
1223    }
1224
1225    #[allow(irrefutable_let_patterns)]
1226    pub fn into_take_application_activity_lease(
1227        self,
1228    ) -> Option<(String, ActivityGovernorTakeApplicationActivityLeaseResponder)> {
1229        if let ActivityGovernorRequest::TakeApplicationActivityLease { name, responder } = self {
1230            Some((name, responder))
1231        } else {
1232            None
1233        }
1234    }
1235
1236    #[allow(irrefutable_let_patterns)]
1237    pub fn into_register_suspend_blocker(
1238        self,
1239    ) -> Option<(
1240        ActivityGovernorRegisterSuspendBlockerRequest,
1241        ActivityGovernorRegisterSuspendBlockerResponder,
1242    )> {
1243        if let ActivityGovernorRequest::RegisterSuspendBlocker { payload, responder } = self {
1244            Some((payload, responder))
1245        } else {
1246            None
1247        }
1248    }
1249
1250    /// Name of the method defined in FIDL
1251    pub fn method_name(&self) -> &'static str {
1252        match *self {
1253            ActivityGovernorRequest::GetPowerElements { .. } => "get_power_elements",
1254            ActivityGovernorRequest::AcquireWakeLease { .. } => "acquire_wake_lease",
1255            ActivityGovernorRequest::AcquireUnmonitoredWakeLease { .. } => {
1256                "acquire_unmonitored_wake_lease"
1257            }
1258            ActivityGovernorRequest::AcquireWakeLeaseWithToken { .. } => {
1259                "acquire_wake_lease_with_token"
1260            }
1261            ActivityGovernorRequest::TakeApplicationActivityLease { .. } => {
1262                "take_application_activity_lease"
1263            }
1264            ActivityGovernorRequest::RegisterSuspendBlocker { .. } => "register_suspend_blocker",
1265            ActivityGovernorRequest::_UnknownMethod {
1266                method_type: fidl::MethodType::OneWay,
1267                ..
1268            } => "unknown one-way method",
1269            ActivityGovernorRequest::_UnknownMethod {
1270                method_type: fidl::MethodType::TwoWay,
1271                ..
1272            } => "unknown two-way method",
1273        }
1274    }
1275}
1276
1277#[derive(Debug, Clone)]
1278pub struct ActivityGovernorControlHandle {
1279    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1280}
1281
1282impl ActivityGovernorControlHandle {
1283    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1284        self.inner.shutdown_with_epitaph(status.into())
1285    }
1286}
1287
1288impl fidl::endpoints::ControlHandle for ActivityGovernorControlHandle {
1289    fn shutdown(&self) {
1290        self.inner.shutdown()
1291    }
1292
1293    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1294        self.inner.shutdown_with_epitaph(status)
1295    }
1296
1297    fn is_closed(&self) -> bool {
1298        self.inner.channel().is_closed()
1299    }
1300    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1301        self.inner.channel().on_closed()
1302    }
1303
1304    #[cfg(target_os = "fuchsia")]
1305    fn signal_peer(
1306        &self,
1307        clear_mask: zx::Signals,
1308        set_mask: zx::Signals,
1309    ) -> Result<(), zx_status::Status> {
1310        use fidl::Peered;
1311        self.inner.channel().signal_peer(clear_mask, set_mask)
1312    }
1313}
1314
1315impl ActivityGovernorControlHandle {}
1316
1317#[must_use = "FIDL methods require a response to be sent"]
1318#[derive(Debug)]
1319pub struct ActivityGovernorGetPowerElementsResponder {
1320    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1321    tx_id: u32,
1322}
1323
1324/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1325/// if the responder is dropped without sending a response, so that the client
1326/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1327impl std::ops::Drop for ActivityGovernorGetPowerElementsResponder {
1328    fn drop(&mut self) {
1329        self.control_handle.shutdown();
1330        // Safety: drops once, never accessed again
1331        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1332    }
1333}
1334
1335impl fidl::endpoints::Responder for ActivityGovernorGetPowerElementsResponder {
1336    type ControlHandle = ActivityGovernorControlHandle;
1337
1338    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1339        &self.control_handle
1340    }
1341
1342    fn drop_without_shutdown(mut self) {
1343        // Safety: drops once, never accessed again due to mem::forget
1344        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1345        // Prevent Drop from running (which would shut down the channel)
1346        std::mem::forget(self);
1347    }
1348}
1349
1350impl ActivityGovernorGetPowerElementsResponder {
1351    /// Sends a response to the FIDL transaction.
1352    ///
1353    /// Sets the channel to shutdown if an error occurs.
1354    pub fn send(self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1355        let _result = self.send_raw(payload);
1356        if _result.is_err() {
1357            self.control_handle.shutdown();
1358        }
1359        self.drop_without_shutdown();
1360        _result
1361    }
1362
1363    /// Similar to "send" but does not shutdown the channel if an error occurs.
1364    pub fn send_no_shutdown_on_err(self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1365        let _result = self.send_raw(payload);
1366        self.drop_without_shutdown();
1367        _result
1368    }
1369
1370    fn send_raw(&self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1371        self.control_handle.inner.send::<fidl::encoding::FlexibleType<PowerElements>>(
1372            fidl::encoding::Flexible::new(&mut payload),
1373            self.tx_id,
1374            0x798003259dfb5672,
1375            fidl::encoding::DynamicFlags::FLEXIBLE,
1376        )
1377    }
1378}
1379
1380#[must_use = "FIDL methods require a response to be sent"]
1381#[derive(Debug)]
1382pub struct ActivityGovernorAcquireWakeLeaseResponder {
1383    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1384    tx_id: u32,
1385}
1386
1387/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1388/// if the responder is dropped without sending a response, so that the client
1389/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1390impl std::ops::Drop for ActivityGovernorAcquireWakeLeaseResponder {
1391    fn drop(&mut self) {
1392        self.control_handle.shutdown();
1393        // Safety: drops once, never accessed again
1394        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1395    }
1396}
1397
1398impl fidl::endpoints::Responder for ActivityGovernorAcquireWakeLeaseResponder {
1399    type ControlHandle = ActivityGovernorControlHandle;
1400
1401    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1402        &self.control_handle
1403    }
1404
1405    fn drop_without_shutdown(mut self) {
1406        // Safety: drops once, never accessed again due to mem::forget
1407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1408        // Prevent Drop from running (which would shut down the channel)
1409        std::mem::forget(self);
1410    }
1411}
1412
1413impl ActivityGovernorAcquireWakeLeaseResponder {
1414    /// Sends a response to the FIDL transaction.
1415    ///
1416    /// Sets the channel to shutdown if an error occurs.
1417    pub fn send(
1418        self,
1419        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1420    ) -> Result<(), fidl::Error> {
1421        let _result = self.send_raw(result);
1422        if _result.is_err() {
1423            self.control_handle.shutdown();
1424        }
1425        self.drop_without_shutdown();
1426        _result
1427    }
1428
1429    /// Similar to "send" but does not shutdown the channel if an error occurs.
1430    pub fn send_no_shutdown_on_err(
1431        self,
1432        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1433    ) -> Result<(), fidl::Error> {
1434        let _result = self.send_raw(result);
1435        self.drop_without_shutdown();
1436        _result
1437    }
1438
1439    fn send_raw(
1440        &self,
1441        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1442    ) -> Result<(), fidl::Error> {
1443        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1444            ActivityGovernorAcquireWakeLeaseResponse,
1445            AcquireWakeLeaseError,
1446        >>(
1447            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1448            self.tx_id,
1449            0x2de25abd8fa7c103,
1450            fidl::encoding::DynamicFlags::FLEXIBLE,
1451        )
1452    }
1453}
1454
1455#[must_use = "FIDL methods require a response to be sent"]
1456#[derive(Debug)]
1457pub struct ActivityGovernorAcquireUnmonitoredWakeLeaseResponder {
1458    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1459    tx_id: u32,
1460}
1461
1462/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1463/// if the responder is dropped without sending a response, so that the client
1464/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1465impl std::ops::Drop for ActivityGovernorAcquireUnmonitoredWakeLeaseResponder {
1466    fn drop(&mut self) {
1467        self.control_handle.shutdown();
1468        // Safety: drops once, never accessed again
1469        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1470    }
1471}
1472
1473impl fidl::endpoints::Responder for ActivityGovernorAcquireUnmonitoredWakeLeaseResponder {
1474    type ControlHandle = ActivityGovernorControlHandle;
1475
1476    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1477        &self.control_handle
1478    }
1479
1480    fn drop_without_shutdown(mut self) {
1481        // Safety: drops once, never accessed again due to mem::forget
1482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1483        // Prevent Drop from running (which would shut down the channel)
1484        std::mem::forget(self);
1485    }
1486}
1487
1488impl ActivityGovernorAcquireUnmonitoredWakeLeaseResponder {
1489    /// Sends a response to the FIDL transaction.
1490    ///
1491    /// Sets the channel to shutdown if an error occurs.
1492    pub fn send(
1493        self,
1494        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1495    ) -> Result<(), fidl::Error> {
1496        let _result = self.send_raw(result);
1497        if _result.is_err() {
1498            self.control_handle.shutdown();
1499        }
1500        self.drop_without_shutdown();
1501        _result
1502    }
1503
1504    /// Similar to "send" but does not shutdown the channel if an error occurs.
1505    pub fn send_no_shutdown_on_err(
1506        self,
1507        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1508    ) -> Result<(), fidl::Error> {
1509        let _result = self.send_raw(result);
1510        self.drop_without_shutdown();
1511        _result
1512    }
1513
1514    fn send_raw(
1515        &self,
1516        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1517    ) -> Result<(), fidl::Error> {
1518        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1519            ActivityGovernorAcquireUnmonitoredWakeLeaseResponse,
1520            AcquireWakeLeaseError,
1521        >>(
1522            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1523            self.tx_id,
1524            0x5f7007d6b0786da9,
1525            fidl::encoding::DynamicFlags::FLEXIBLE,
1526        )
1527    }
1528}
1529
1530#[must_use = "FIDL methods require a response to be sent"]
1531#[derive(Debug)]
1532pub struct ActivityGovernorAcquireWakeLeaseWithTokenResponder {
1533    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1534    tx_id: u32,
1535}
1536
1537/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1538/// if the responder is dropped without sending a response, so that the client
1539/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1540impl std::ops::Drop for ActivityGovernorAcquireWakeLeaseWithTokenResponder {
1541    fn drop(&mut self) {
1542        self.control_handle.shutdown();
1543        // Safety: drops once, never accessed again
1544        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1545    }
1546}
1547
1548impl fidl::endpoints::Responder for ActivityGovernorAcquireWakeLeaseWithTokenResponder {
1549    type ControlHandle = ActivityGovernorControlHandle;
1550
1551    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1552        &self.control_handle
1553    }
1554
1555    fn drop_without_shutdown(mut self) {
1556        // Safety: drops once, never accessed again due to mem::forget
1557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1558        // Prevent Drop from running (which would shut down the channel)
1559        std::mem::forget(self);
1560    }
1561}
1562
1563impl ActivityGovernorAcquireWakeLeaseWithTokenResponder {
1564    /// Sends a response to the FIDL transaction.
1565    ///
1566    /// Sets the channel to shutdown if an error occurs.
1567    pub fn send(self, mut result: Result<(), AcquireWakeLeaseError>) -> Result<(), fidl::Error> {
1568        let _result = self.send_raw(result);
1569        if _result.is_err() {
1570            self.control_handle.shutdown();
1571        }
1572        self.drop_without_shutdown();
1573        _result
1574    }
1575
1576    /// Similar to "send" but does not shutdown the channel if an error occurs.
1577    pub fn send_no_shutdown_on_err(
1578        self,
1579        mut result: Result<(), AcquireWakeLeaseError>,
1580    ) -> Result<(), fidl::Error> {
1581        let _result = self.send_raw(result);
1582        self.drop_without_shutdown();
1583        _result
1584    }
1585
1586    fn send_raw(&self, mut result: Result<(), AcquireWakeLeaseError>) -> Result<(), fidl::Error> {
1587        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1588            fidl::encoding::EmptyStruct,
1589            AcquireWakeLeaseError,
1590        >>(
1591            fidl::encoding::FlexibleResult::new(result),
1592            self.tx_id,
1593            0x1cdd2ea3bee46f51,
1594            fidl::encoding::DynamicFlags::FLEXIBLE,
1595        )
1596    }
1597}
1598
1599#[must_use = "FIDL methods require a response to be sent"]
1600#[derive(Debug)]
1601pub struct ActivityGovernorTakeApplicationActivityLeaseResponder {
1602    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1603    tx_id: u32,
1604}
1605
1606/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1607/// if the responder is dropped without sending a response, so that the client
1608/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1609impl std::ops::Drop for ActivityGovernorTakeApplicationActivityLeaseResponder {
1610    fn drop(&mut self) {
1611        self.control_handle.shutdown();
1612        // Safety: drops once, never accessed again
1613        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1614    }
1615}
1616
1617impl fidl::endpoints::Responder for ActivityGovernorTakeApplicationActivityLeaseResponder {
1618    type ControlHandle = ActivityGovernorControlHandle;
1619
1620    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1621        &self.control_handle
1622    }
1623
1624    fn drop_without_shutdown(mut self) {
1625        // Safety: drops once, never accessed again due to mem::forget
1626        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1627        // Prevent Drop from running (which would shut down the channel)
1628        std::mem::forget(self);
1629    }
1630}
1631
1632impl ActivityGovernorTakeApplicationActivityLeaseResponder {
1633    /// Sends a response to the FIDL transaction.
1634    ///
1635    /// Sets the channel to shutdown if an error occurs.
1636    pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1637        let _result = self.send_raw(token);
1638        if _result.is_err() {
1639            self.control_handle.shutdown();
1640        }
1641        self.drop_without_shutdown();
1642        _result
1643    }
1644
1645    /// Similar to "send" but does not shutdown the channel if an error occurs.
1646    pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1647        let _result = self.send_raw(token);
1648        self.drop_without_shutdown();
1649        _result
1650    }
1651
1652    fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1653        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1654            ActivityGovernorTakeApplicationActivityLeaseResponse,
1655        >>(
1656            fidl::encoding::Flexible::new((token,)),
1657            self.tx_id,
1658            0x37cd5364de7ada14,
1659            fidl::encoding::DynamicFlags::FLEXIBLE,
1660        )
1661    }
1662}
1663
1664#[must_use = "FIDL methods require a response to be sent"]
1665#[derive(Debug)]
1666pub struct ActivityGovernorRegisterSuspendBlockerResponder {
1667    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1668    tx_id: u32,
1669}
1670
1671/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1672/// if the responder is dropped without sending a response, so that the client
1673/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1674impl std::ops::Drop for ActivityGovernorRegisterSuspendBlockerResponder {
1675    fn drop(&mut self) {
1676        self.control_handle.shutdown();
1677        // Safety: drops once, never accessed again
1678        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1679    }
1680}
1681
1682impl fidl::endpoints::Responder for ActivityGovernorRegisterSuspendBlockerResponder {
1683    type ControlHandle = ActivityGovernorControlHandle;
1684
1685    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1686        &self.control_handle
1687    }
1688
1689    fn drop_without_shutdown(mut self) {
1690        // Safety: drops once, never accessed again due to mem::forget
1691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1692        // Prevent Drop from running (which would shut down the channel)
1693        std::mem::forget(self);
1694    }
1695}
1696
1697impl ActivityGovernorRegisterSuspendBlockerResponder {
1698    /// Sends a response to the FIDL transaction.
1699    ///
1700    /// Sets the channel to shutdown if an error occurs.
1701    pub fn send(
1702        self,
1703        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1704    ) -> Result<(), fidl::Error> {
1705        let _result = self.send_raw(result);
1706        if _result.is_err() {
1707            self.control_handle.shutdown();
1708        }
1709        self.drop_without_shutdown();
1710        _result
1711    }
1712
1713    /// Similar to "send" but does not shutdown the channel if an error occurs.
1714    pub fn send_no_shutdown_on_err(
1715        self,
1716        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1717    ) -> Result<(), fidl::Error> {
1718        let _result = self.send_raw(result);
1719        self.drop_without_shutdown();
1720        _result
1721    }
1722
1723    fn send_raw(
1724        &self,
1725        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1726    ) -> Result<(), fidl::Error> {
1727        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1728            ActivityGovernorRegisterSuspendBlockerResponse,
1729            RegisterSuspendBlockerError,
1730        >>(
1731            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1732            self.tx_id,
1733            0x34ef55b180feef01,
1734            fidl::encoding::DynamicFlags::FLEXIBLE,
1735        )
1736    }
1737}
1738
1739#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1740pub struct BootControlMarker;
1741
1742impl fidl::endpoints::ProtocolMarker for BootControlMarker {
1743    type Proxy = BootControlProxy;
1744    type RequestStream = BootControlRequestStream;
1745    #[cfg(target_os = "fuchsia")]
1746    type SynchronousProxy = BootControlSynchronousProxy;
1747
1748    const DEBUG_NAME: &'static str = "fuchsia.power.system.BootControl";
1749}
1750impl fidl::endpoints::DiscoverableProtocolMarker for BootControlMarker {}
1751
1752pub trait BootControlProxyInterface: Send + Sync {
1753    type SetBootCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1754    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut;
1755}
1756#[derive(Debug)]
1757#[cfg(target_os = "fuchsia")]
1758pub struct BootControlSynchronousProxy {
1759    client: fidl::client::sync::Client,
1760}
1761
1762#[cfg(target_os = "fuchsia")]
1763impl fidl::endpoints::SynchronousProxy for BootControlSynchronousProxy {
1764    type Proxy = BootControlProxy;
1765    type Protocol = BootControlMarker;
1766
1767    fn from_channel(inner: fidl::Channel) -> Self {
1768        Self::new(inner)
1769    }
1770
1771    fn into_channel(self) -> fidl::Channel {
1772        self.client.into_channel()
1773    }
1774
1775    fn as_channel(&self) -> &fidl::Channel {
1776        self.client.as_channel()
1777    }
1778}
1779
1780#[cfg(target_os = "fuchsia")]
1781impl BootControlSynchronousProxy {
1782    pub fn new(channel: fidl::Channel) -> Self {
1783        Self { client: fidl::client::sync::Client::new(channel) }
1784    }
1785
1786    pub fn into_channel(self) -> fidl::Channel {
1787        self.client.into_channel()
1788    }
1789
1790    /// Waits until an event arrives and returns it. It is safe for other
1791    /// threads to make concurrent requests while waiting for an event.
1792    pub fn wait_for_event(
1793        &self,
1794        deadline: zx::MonotonicInstant,
1795    ) -> Result<BootControlEvent, fidl::Error> {
1796        BootControlEvent::decode(self.client.wait_for_event::<BootControlMarker>(deadline)?)
1797    }
1798
1799    /// Notify the SAG that the system has booted. SAG will not suspend the
1800    /// hardware platform until this method is called at least once per boot.
1801    pub fn r#set_boot_complete(
1802        &self,
1803        ___deadline: zx::MonotonicInstant,
1804    ) -> Result<(), fidl::Error> {
1805        let _response = self.client.send_query::<
1806            fidl::encoding::EmptyPayload,
1807            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1808            BootControlMarker,
1809        >(
1810            (),
1811            0x3c9b9f24ad3ca2b5,
1812            fidl::encoding::DynamicFlags::FLEXIBLE,
1813            ___deadline,
1814        )?
1815        .into_result::<BootControlMarker>("set_boot_complete")?;
1816        Ok(_response)
1817    }
1818}
1819
1820#[cfg(target_os = "fuchsia")]
1821impl From<BootControlSynchronousProxy> for zx::NullableHandle {
1822    fn from(value: BootControlSynchronousProxy) -> Self {
1823        value.into_channel().into()
1824    }
1825}
1826
1827#[cfg(target_os = "fuchsia")]
1828impl From<fidl::Channel> for BootControlSynchronousProxy {
1829    fn from(value: fidl::Channel) -> Self {
1830        Self::new(value)
1831    }
1832}
1833
1834#[cfg(target_os = "fuchsia")]
1835impl fidl::endpoints::FromClient for BootControlSynchronousProxy {
1836    type Protocol = BootControlMarker;
1837
1838    fn from_client(value: fidl::endpoints::ClientEnd<BootControlMarker>) -> Self {
1839        Self::new(value.into_channel())
1840    }
1841}
1842
1843#[derive(Debug, Clone)]
1844pub struct BootControlProxy {
1845    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1846}
1847
1848impl fidl::endpoints::Proxy for BootControlProxy {
1849    type Protocol = BootControlMarker;
1850
1851    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1852        Self::new(inner)
1853    }
1854
1855    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1856        self.client.into_channel().map_err(|client| Self { client })
1857    }
1858
1859    fn as_channel(&self) -> &::fidl::AsyncChannel {
1860        self.client.as_channel()
1861    }
1862}
1863
1864impl BootControlProxy {
1865    /// Create a new Proxy for fuchsia.power.system/BootControl.
1866    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1867        let protocol_name = <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1868        Self { client: fidl::client::Client::new(channel, protocol_name) }
1869    }
1870
1871    /// Get a Stream of events from the remote end of the protocol.
1872    ///
1873    /// # Panics
1874    ///
1875    /// Panics if the event stream was already taken.
1876    pub fn take_event_stream(&self) -> BootControlEventStream {
1877        BootControlEventStream { event_receiver: self.client.take_event_receiver() }
1878    }
1879
1880    /// Notify the SAG that the system has booted. SAG will not suspend the
1881    /// hardware platform until this method is called at least once per boot.
1882    pub fn r#set_boot_complete(
1883        &self,
1884    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1885        BootControlProxyInterface::r#set_boot_complete(self)
1886    }
1887}
1888
1889impl BootControlProxyInterface for BootControlProxy {
1890    type SetBootCompleteResponseFut =
1891        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1892    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut {
1893        fn _decode(
1894            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1895        ) -> Result<(), fidl::Error> {
1896            let _response = fidl::client::decode_transaction_body::<
1897                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1898                fidl::encoding::DefaultFuchsiaResourceDialect,
1899                0x3c9b9f24ad3ca2b5,
1900            >(_buf?)?
1901            .into_result::<BootControlMarker>("set_boot_complete")?;
1902            Ok(_response)
1903        }
1904        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1905            (),
1906            0x3c9b9f24ad3ca2b5,
1907            fidl::encoding::DynamicFlags::FLEXIBLE,
1908            _decode,
1909        )
1910    }
1911}
1912
1913pub struct BootControlEventStream {
1914    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1915}
1916
1917impl std::marker::Unpin for BootControlEventStream {}
1918
1919impl futures::stream::FusedStream for BootControlEventStream {
1920    fn is_terminated(&self) -> bool {
1921        self.event_receiver.is_terminated()
1922    }
1923}
1924
1925impl futures::Stream for BootControlEventStream {
1926    type Item = Result<BootControlEvent, fidl::Error>;
1927
1928    fn poll_next(
1929        mut self: std::pin::Pin<&mut Self>,
1930        cx: &mut std::task::Context<'_>,
1931    ) -> std::task::Poll<Option<Self::Item>> {
1932        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1933            &mut self.event_receiver,
1934            cx
1935        )?) {
1936            Some(buf) => std::task::Poll::Ready(Some(BootControlEvent::decode(buf))),
1937            None => std::task::Poll::Ready(None),
1938        }
1939    }
1940}
1941
1942#[derive(Debug)]
1943pub enum BootControlEvent {
1944    #[non_exhaustive]
1945    _UnknownEvent {
1946        /// Ordinal of the event that was sent.
1947        ordinal: u64,
1948    },
1949}
1950
1951impl BootControlEvent {
1952    /// Decodes a message buffer as a [`BootControlEvent`].
1953    fn decode(
1954        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1955    ) -> Result<BootControlEvent, fidl::Error> {
1956        let (bytes, _handles) = buf.split_mut();
1957        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1958        debug_assert_eq!(tx_header.tx_id, 0);
1959        match tx_header.ordinal {
1960            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1961                Ok(BootControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1962            }
1963            _ => Err(fidl::Error::UnknownOrdinal {
1964                ordinal: tx_header.ordinal,
1965                protocol_name: <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1966            }),
1967        }
1968    }
1969}
1970
1971/// A Stream of incoming requests for fuchsia.power.system/BootControl.
1972pub struct BootControlRequestStream {
1973    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1974    is_terminated: bool,
1975}
1976
1977impl std::marker::Unpin for BootControlRequestStream {}
1978
1979impl futures::stream::FusedStream for BootControlRequestStream {
1980    fn is_terminated(&self) -> bool {
1981        self.is_terminated
1982    }
1983}
1984
1985impl fidl::endpoints::RequestStream for BootControlRequestStream {
1986    type Protocol = BootControlMarker;
1987    type ControlHandle = BootControlControlHandle;
1988
1989    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1990        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1991    }
1992
1993    fn control_handle(&self) -> Self::ControlHandle {
1994        BootControlControlHandle { inner: self.inner.clone() }
1995    }
1996
1997    fn into_inner(
1998        self,
1999    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2000    {
2001        (self.inner, self.is_terminated)
2002    }
2003
2004    fn from_inner(
2005        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2006        is_terminated: bool,
2007    ) -> Self {
2008        Self { inner, is_terminated }
2009    }
2010}
2011
2012impl futures::Stream for BootControlRequestStream {
2013    type Item = Result<BootControlRequest, fidl::Error>;
2014
2015    fn poll_next(
2016        mut self: std::pin::Pin<&mut Self>,
2017        cx: &mut std::task::Context<'_>,
2018    ) -> std::task::Poll<Option<Self::Item>> {
2019        let this = &mut *self;
2020        if this.inner.check_shutdown(cx) {
2021            this.is_terminated = true;
2022            return std::task::Poll::Ready(None);
2023        }
2024        if this.is_terminated {
2025            panic!("polled BootControlRequestStream after completion");
2026        }
2027        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2028            |bytes, handles| {
2029                match this.inner.channel().read_etc(cx, bytes, handles) {
2030                    std::task::Poll::Ready(Ok(())) => {}
2031                    std::task::Poll::Pending => return std::task::Poll::Pending,
2032                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2033                        this.is_terminated = true;
2034                        return std::task::Poll::Ready(None);
2035                    }
2036                    std::task::Poll::Ready(Err(e)) => {
2037                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2038                            e.into(),
2039                        ))));
2040                    }
2041                }
2042
2043                // A message has been received from the channel
2044                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2045
2046                std::task::Poll::Ready(Some(match header.ordinal {
2047                    0x3c9b9f24ad3ca2b5 => {
2048                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2049                        let mut req = fidl::new_empty!(
2050                            fidl::encoding::EmptyPayload,
2051                            fidl::encoding::DefaultFuchsiaResourceDialect
2052                        );
2053                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2054                        let control_handle = BootControlControlHandle { inner: this.inner.clone() };
2055                        Ok(BootControlRequest::SetBootComplete {
2056                            responder: BootControlSetBootCompleteResponder {
2057                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2058                                tx_id: header.tx_id,
2059                            },
2060                        })
2061                    }
2062                    _ if header.tx_id == 0
2063                        && header
2064                            .dynamic_flags()
2065                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2066                    {
2067                        Ok(BootControlRequest::_UnknownMethod {
2068                            ordinal: header.ordinal,
2069                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2070                            method_type: fidl::MethodType::OneWay,
2071                        })
2072                    }
2073                    _ if header
2074                        .dynamic_flags()
2075                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2076                    {
2077                        this.inner.send_framework_err(
2078                            fidl::encoding::FrameworkErr::UnknownMethod,
2079                            header.tx_id,
2080                            header.ordinal,
2081                            header.dynamic_flags(),
2082                            (bytes, handles),
2083                        )?;
2084                        Ok(BootControlRequest::_UnknownMethod {
2085                            ordinal: header.ordinal,
2086                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2087                            method_type: fidl::MethodType::TwoWay,
2088                        })
2089                    }
2090                    _ => Err(fidl::Error::UnknownOrdinal {
2091                        ordinal: header.ordinal,
2092                        protocol_name:
2093                            <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2094                    }),
2095                }))
2096            },
2097        )
2098    }
2099}
2100
2101/// A service that processes notification about the system boot state.
2102#[derive(Debug)]
2103pub enum BootControlRequest {
2104    /// Notify the SAG that the system has booted. SAG will not suspend the
2105    /// hardware platform until this method is called at least once per boot.
2106    SetBootComplete { responder: BootControlSetBootCompleteResponder },
2107    /// An interaction was received which does not match any known method.
2108    #[non_exhaustive]
2109    _UnknownMethod {
2110        /// Ordinal of the method that was called.
2111        ordinal: u64,
2112        control_handle: BootControlControlHandle,
2113        method_type: fidl::MethodType,
2114    },
2115}
2116
2117impl BootControlRequest {
2118    #[allow(irrefutable_let_patterns)]
2119    pub fn into_set_boot_complete(self) -> Option<(BootControlSetBootCompleteResponder)> {
2120        if let BootControlRequest::SetBootComplete { responder } = self {
2121            Some((responder))
2122        } else {
2123            None
2124        }
2125    }
2126
2127    /// Name of the method defined in FIDL
2128    pub fn method_name(&self) -> &'static str {
2129        match *self {
2130            BootControlRequest::SetBootComplete { .. } => "set_boot_complete",
2131            BootControlRequest::_UnknownMethod {
2132                method_type: fidl::MethodType::OneWay, ..
2133            } => "unknown one-way method",
2134            BootControlRequest::_UnknownMethod {
2135                method_type: fidl::MethodType::TwoWay, ..
2136            } => "unknown two-way method",
2137        }
2138    }
2139}
2140
2141#[derive(Debug, Clone)]
2142pub struct BootControlControlHandle {
2143    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2144}
2145
2146impl BootControlControlHandle {
2147    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2148        self.inner.shutdown_with_epitaph(status.into())
2149    }
2150}
2151
2152impl fidl::endpoints::ControlHandle for BootControlControlHandle {
2153    fn shutdown(&self) {
2154        self.inner.shutdown()
2155    }
2156
2157    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2158        self.inner.shutdown_with_epitaph(status)
2159    }
2160
2161    fn is_closed(&self) -> bool {
2162        self.inner.channel().is_closed()
2163    }
2164    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2165        self.inner.channel().on_closed()
2166    }
2167
2168    #[cfg(target_os = "fuchsia")]
2169    fn signal_peer(
2170        &self,
2171        clear_mask: zx::Signals,
2172        set_mask: zx::Signals,
2173    ) -> Result<(), zx_status::Status> {
2174        use fidl::Peered;
2175        self.inner.channel().signal_peer(clear_mask, set_mask)
2176    }
2177}
2178
2179impl BootControlControlHandle {}
2180
2181#[must_use = "FIDL methods require a response to be sent"]
2182#[derive(Debug)]
2183pub struct BootControlSetBootCompleteResponder {
2184    control_handle: std::mem::ManuallyDrop<BootControlControlHandle>,
2185    tx_id: u32,
2186}
2187
2188/// Set the the channel to be shutdown (see [`BootControlControlHandle::shutdown`])
2189/// if the responder is dropped without sending a response, so that the client
2190/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2191impl std::ops::Drop for BootControlSetBootCompleteResponder {
2192    fn drop(&mut self) {
2193        self.control_handle.shutdown();
2194        // Safety: drops once, never accessed again
2195        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2196    }
2197}
2198
2199impl fidl::endpoints::Responder for BootControlSetBootCompleteResponder {
2200    type ControlHandle = BootControlControlHandle;
2201
2202    fn control_handle(&self) -> &BootControlControlHandle {
2203        &self.control_handle
2204    }
2205
2206    fn drop_without_shutdown(mut self) {
2207        // Safety: drops once, never accessed again due to mem::forget
2208        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2209        // Prevent Drop from running (which would shut down the channel)
2210        std::mem::forget(self);
2211    }
2212}
2213
2214impl BootControlSetBootCompleteResponder {
2215    /// Sends a response to the FIDL transaction.
2216    ///
2217    /// Sets the channel to shutdown if an error occurs.
2218    pub fn send(self) -> Result<(), fidl::Error> {
2219        let _result = self.send_raw();
2220        if _result.is_err() {
2221            self.control_handle.shutdown();
2222        }
2223        self.drop_without_shutdown();
2224        _result
2225    }
2226
2227    /// Similar to "send" but does not shutdown the channel if an error occurs.
2228    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2229        let _result = self.send_raw();
2230        self.drop_without_shutdown();
2231        _result
2232    }
2233
2234    fn send_raw(&self) -> Result<(), fidl::Error> {
2235        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2236            fidl::encoding::Flexible::new(()),
2237            self.tx_id,
2238            0x3c9b9f24ad3ca2b5,
2239            fidl::encoding::DynamicFlags::FLEXIBLE,
2240        )
2241    }
2242}
2243
2244#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2245pub struct CpuElementManagerMarker;
2246
2247impl fidl::endpoints::ProtocolMarker for CpuElementManagerMarker {
2248    type Proxy = CpuElementManagerProxy;
2249    type RequestStream = CpuElementManagerRequestStream;
2250    #[cfg(target_os = "fuchsia")]
2251    type SynchronousProxy = CpuElementManagerSynchronousProxy;
2252
2253    const DEBUG_NAME: &'static str = "fuchsia.power.system.CpuElementManager";
2254}
2255impl fidl::endpoints::DiscoverableProtocolMarker for CpuElementManagerMarker {}
2256pub type CpuElementManagerAddExecutionStateDependencyResult =
2257    Result<(), AddExecutionStateDependencyError>;
2258
2259pub trait CpuElementManagerProxyInterface: Send + Sync {
2260    type GetCpuDependencyTokenResponseFut: std::future::Future<Output = Result<Cpu, fidl::Error>>
2261        + Send;
2262    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut;
2263    type AddExecutionStateDependencyResponseFut: std::future::Future<
2264            Output = Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error>,
2265        > + Send;
2266    fn r#add_execution_state_dependency(
2267        &self,
2268        payload: CpuElementManagerAddExecutionStateDependencyRequest,
2269    ) -> Self::AddExecutionStateDependencyResponseFut;
2270}
2271#[derive(Debug)]
2272#[cfg(target_os = "fuchsia")]
2273pub struct CpuElementManagerSynchronousProxy {
2274    client: fidl::client::sync::Client,
2275}
2276
2277#[cfg(target_os = "fuchsia")]
2278impl fidl::endpoints::SynchronousProxy for CpuElementManagerSynchronousProxy {
2279    type Proxy = CpuElementManagerProxy;
2280    type Protocol = CpuElementManagerMarker;
2281
2282    fn from_channel(inner: fidl::Channel) -> Self {
2283        Self::new(inner)
2284    }
2285
2286    fn into_channel(self) -> fidl::Channel {
2287        self.client.into_channel()
2288    }
2289
2290    fn as_channel(&self) -> &fidl::Channel {
2291        self.client.as_channel()
2292    }
2293}
2294
2295#[cfg(target_os = "fuchsia")]
2296impl CpuElementManagerSynchronousProxy {
2297    pub fn new(channel: fidl::Channel) -> Self {
2298        Self { client: fidl::client::sync::Client::new(channel) }
2299    }
2300
2301    pub fn into_channel(self) -> fidl::Channel {
2302        self.client.into_channel()
2303    }
2304
2305    /// Waits until an event arrives and returns it. It is safe for other
2306    /// threads to make concurrent requests while waiting for an event.
2307    pub fn wait_for_event(
2308        &self,
2309        deadline: zx::MonotonicInstant,
2310    ) -> Result<CpuElementManagerEvent, fidl::Error> {
2311        CpuElementManagerEvent::decode(
2312            self.client.wait_for_event::<CpuElementManagerMarker>(deadline)?,
2313        )
2314    }
2315
2316    /// Gets the assertive dependency token for the CPU power element.
2317    pub fn r#get_cpu_dependency_token(
2318        &self,
2319        ___deadline: zx::MonotonicInstant,
2320    ) -> Result<Cpu, fidl::Error> {
2321        let _response = self.client.send_query::<
2322            fidl::encoding::EmptyPayload,
2323            fidl::encoding::FlexibleType<Cpu>,
2324            CpuElementManagerMarker,
2325        >(
2326            (),
2327            0x2c43645ed70344ba,
2328            fidl::encoding::DynamicFlags::FLEXIBLE,
2329            ___deadline,
2330        )?
2331        .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
2332        Ok(_response)
2333    }
2334
2335    /// Adds a dependency from the Execution State power element to the target
2336    /// power element identified by [`dependency_token`] at [`power_level`].
2337    ///
2338    /// Once the Execution State power element is created, future calls will
2339    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2340    /// and no changes to Execution State dependencies will be made.
2341    ///
2342    /// If any required entries in the request are missing, the server will
2343    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2344    pub fn r#add_execution_state_dependency(
2345        &self,
2346        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2347        ___deadline: zx::MonotonicInstant,
2348    ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
2349        let _response = self.client.send_query::<
2350            CpuElementManagerAddExecutionStateDependencyRequest,
2351            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, AddExecutionStateDependencyError>,
2352            CpuElementManagerMarker,
2353        >(
2354            &mut payload,
2355            0xdf2f5ea2af76234,
2356            fidl::encoding::DynamicFlags::FLEXIBLE,
2357            ___deadline,
2358        )?
2359        .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
2360        Ok(_response.map(|x| x))
2361    }
2362}
2363
2364#[cfg(target_os = "fuchsia")]
2365impl From<CpuElementManagerSynchronousProxy> for zx::NullableHandle {
2366    fn from(value: CpuElementManagerSynchronousProxy) -> Self {
2367        value.into_channel().into()
2368    }
2369}
2370
2371#[cfg(target_os = "fuchsia")]
2372impl From<fidl::Channel> for CpuElementManagerSynchronousProxy {
2373    fn from(value: fidl::Channel) -> Self {
2374        Self::new(value)
2375    }
2376}
2377
2378#[cfg(target_os = "fuchsia")]
2379impl fidl::endpoints::FromClient for CpuElementManagerSynchronousProxy {
2380    type Protocol = CpuElementManagerMarker;
2381
2382    fn from_client(value: fidl::endpoints::ClientEnd<CpuElementManagerMarker>) -> Self {
2383        Self::new(value.into_channel())
2384    }
2385}
2386
2387#[derive(Debug, Clone)]
2388pub struct CpuElementManagerProxy {
2389    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2390}
2391
2392impl fidl::endpoints::Proxy for CpuElementManagerProxy {
2393    type Protocol = CpuElementManagerMarker;
2394
2395    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2396        Self::new(inner)
2397    }
2398
2399    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2400        self.client.into_channel().map_err(|client| Self { client })
2401    }
2402
2403    fn as_channel(&self) -> &::fidl::AsyncChannel {
2404        self.client.as_channel()
2405    }
2406}
2407
2408impl CpuElementManagerProxy {
2409    /// Create a new Proxy for fuchsia.power.system/CpuElementManager.
2410    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2411        let protocol_name =
2412            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2413        Self { client: fidl::client::Client::new(channel, protocol_name) }
2414    }
2415
2416    /// Get a Stream of events from the remote end of the protocol.
2417    ///
2418    /// # Panics
2419    ///
2420    /// Panics if the event stream was already taken.
2421    pub fn take_event_stream(&self) -> CpuElementManagerEventStream {
2422        CpuElementManagerEventStream { event_receiver: self.client.take_event_receiver() }
2423    }
2424
2425    /// Gets the assertive dependency token for the CPU power element.
2426    pub fn r#get_cpu_dependency_token(
2427        &self,
2428    ) -> fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect> {
2429        CpuElementManagerProxyInterface::r#get_cpu_dependency_token(self)
2430    }
2431
2432    /// Adds a dependency from the Execution State power element to the target
2433    /// power element identified by [`dependency_token`] at [`power_level`].
2434    ///
2435    /// Once the Execution State power element is created, future calls will
2436    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2437    /// and no changes to Execution State dependencies will be made.
2438    ///
2439    /// If any required entries in the request are missing, the server will
2440    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2441    pub fn r#add_execution_state_dependency(
2442        &self,
2443        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2444    ) -> fidl::client::QueryResponseFut<
2445        CpuElementManagerAddExecutionStateDependencyResult,
2446        fidl::encoding::DefaultFuchsiaResourceDialect,
2447    > {
2448        CpuElementManagerProxyInterface::r#add_execution_state_dependency(self, payload)
2449    }
2450}
2451
2452impl CpuElementManagerProxyInterface for CpuElementManagerProxy {
2453    type GetCpuDependencyTokenResponseFut =
2454        fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>;
2455    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut {
2456        fn _decode(
2457            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2458        ) -> Result<Cpu, fidl::Error> {
2459            let _response = fidl::client::decode_transaction_body::<
2460                fidl::encoding::FlexibleType<Cpu>,
2461                fidl::encoding::DefaultFuchsiaResourceDialect,
2462                0x2c43645ed70344ba,
2463            >(_buf?)?
2464            .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
2465            Ok(_response)
2466        }
2467        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Cpu>(
2468            (),
2469            0x2c43645ed70344ba,
2470            fidl::encoding::DynamicFlags::FLEXIBLE,
2471            _decode,
2472        )
2473    }
2474
2475    type AddExecutionStateDependencyResponseFut = fidl::client::QueryResponseFut<
2476        CpuElementManagerAddExecutionStateDependencyResult,
2477        fidl::encoding::DefaultFuchsiaResourceDialect,
2478    >;
2479    fn r#add_execution_state_dependency(
2480        &self,
2481        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2482    ) -> Self::AddExecutionStateDependencyResponseFut {
2483        fn _decode(
2484            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2485        ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
2486            let _response = fidl::client::decode_transaction_body::<
2487                fidl::encoding::FlexibleResultType<
2488                    fidl::encoding::EmptyStruct,
2489                    AddExecutionStateDependencyError,
2490                >,
2491                fidl::encoding::DefaultFuchsiaResourceDialect,
2492                0xdf2f5ea2af76234,
2493            >(_buf?)?
2494            .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
2495            Ok(_response.map(|x| x))
2496        }
2497        self.client.send_query_and_decode::<
2498            CpuElementManagerAddExecutionStateDependencyRequest,
2499            CpuElementManagerAddExecutionStateDependencyResult,
2500        >(
2501            &mut payload,
2502            0xdf2f5ea2af76234,
2503            fidl::encoding::DynamicFlags::FLEXIBLE,
2504            _decode,
2505        )
2506    }
2507}
2508
2509pub struct CpuElementManagerEventStream {
2510    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2511}
2512
2513impl std::marker::Unpin for CpuElementManagerEventStream {}
2514
2515impl futures::stream::FusedStream for CpuElementManagerEventStream {
2516    fn is_terminated(&self) -> bool {
2517        self.event_receiver.is_terminated()
2518    }
2519}
2520
2521impl futures::Stream for CpuElementManagerEventStream {
2522    type Item = Result<CpuElementManagerEvent, fidl::Error>;
2523
2524    fn poll_next(
2525        mut self: std::pin::Pin<&mut Self>,
2526        cx: &mut std::task::Context<'_>,
2527    ) -> std::task::Poll<Option<Self::Item>> {
2528        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2529            &mut self.event_receiver,
2530            cx
2531        )?) {
2532            Some(buf) => std::task::Poll::Ready(Some(CpuElementManagerEvent::decode(buf))),
2533            None => std::task::Poll::Ready(None),
2534        }
2535    }
2536}
2537
2538#[derive(Debug)]
2539pub enum CpuElementManagerEvent {
2540    #[non_exhaustive]
2541    _UnknownEvent {
2542        /// Ordinal of the event that was sent.
2543        ordinal: u64,
2544    },
2545}
2546
2547impl CpuElementManagerEvent {
2548    /// Decodes a message buffer as a [`CpuElementManagerEvent`].
2549    fn decode(
2550        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2551    ) -> Result<CpuElementManagerEvent, fidl::Error> {
2552        let (bytes, _handles) = buf.split_mut();
2553        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2554        debug_assert_eq!(tx_header.tx_id, 0);
2555        match tx_header.ordinal {
2556            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2557                Ok(CpuElementManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2558            }
2559            _ => Err(fidl::Error::UnknownOrdinal {
2560                ordinal: tx_header.ordinal,
2561                protocol_name:
2562                    <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2563            }),
2564        }
2565    }
2566}
2567
2568/// A Stream of incoming requests for fuchsia.power.system/CpuElementManager.
2569pub struct CpuElementManagerRequestStream {
2570    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2571    is_terminated: bool,
2572}
2573
2574impl std::marker::Unpin for CpuElementManagerRequestStream {}
2575
2576impl futures::stream::FusedStream for CpuElementManagerRequestStream {
2577    fn is_terminated(&self) -> bool {
2578        self.is_terminated
2579    }
2580}
2581
2582impl fidl::endpoints::RequestStream for CpuElementManagerRequestStream {
2583    type Protocol = CpuElementManagerMarker;
2584    type ControlHandle = CpuElementManagerControlHandle;
2585
2586    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2587        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2588    }
2589
2590    fn control_handle(&self) -> Self::ControlHandle {
2591        CpuElementManagerControlHandle { inner: self.inner.clone() }
2592    }
2593
2594    fn into_inner(
2595        self,
2596    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2597    {
2598        (self.inner, self.is_terminated)
2599    }
2600
2601    fn from_inner(
2602        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2603        is_terminated: bool,
2604    ) -> Self {
2605        Self { inner, is_terminated }
2606    }
2607}
2608
2609impl futures::Stream for CpuElementManagerRequestStream {
2610    type Item = Result<CpuElementManagerRequest, fidl::Error>;
2611
2612    fn poll_next(
2613        mut self: std::pin::Pin<&mut Self>,
2614        cx: &mut std::task::Context<'_>,
2615    ) -> std::task::Poll<Option<Self::Item>> {
2616        let this = &mut *self;
2617        if this.inner.check_shutdown(cx) {
2618            this.is_terminated = true;
2619            return std::task::Poll::Ready(None);
2620        }
2621        if this.is_terminated {
2622            panic!("polled CpuElementManagerRequestStream after completion");
2623        }
2624        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2625            |bytes, handles| {
2626                match this.inner.channel().read_etc(cx, bytes, handles) {
2627                    std::task::Poll::Ready(Ok(())) => {}
2628                    std::task::Poll::Pending => return std::task::Poll::Pending,
2629                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2630                        this.is_terminated = true;
2631                        return std::task::Poll::Ready(None);
2632                    }
2633                    std::task::Poll::Ready(Err(e)) => {
2634                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2635                            e.into(),
2636                        ))));
2637                    }
2638                }
2639
2640                // A message has been received from the channel
2641                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2642
2643                std::task::Poll::Ready(Some(match header.ordinal {
2644                    0x2c43645ed70344ba => {
2645                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2646                        let mut req = fidl::new_empty!(
2647                            fidl::encoding::EmptyPayload,
2648                            fidl::encoding::DefaultFuchsiaResourceDialect
2649                        );
2650                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2651                        let control_handle =
2652                            CpuElementManagerControlHandle { inner: this.inner.clone() };
2653                        Ok(CpuElementManagerRequest::GetCpuDependencyToken {
2654                            responder: CpuElementManagerGetCpuDependencyTokenResponder {
2655                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2656                                tx_id: header.tx_id,
2657                            },
2658                        })
2659                    }
2660                    0xdf2f5ea2af76234 => {
2661                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2662                        let mut req = fidl::new_empty!(
2663                            CpuElementManagerAddExecutionStateDependencyRequest,
2664                            fidl::encoding::DefaultFuchsiaResourceDialect
2665                        );
2666                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CpuElementManagerAddExecutionStateDependencyRequest>(&header, _body_bytes, handles, &mut req)?;
2667                        let control_handle =
2668                            CpuElementManagerControlHandle { inner: this.inner.clone() };
2669                        Ok(CpuElementManagerRequest::AddExecutionStateDependency {
2670                            payload: req,
2671                            responder: CpuElementManagerAddExecutionStateDependencyResponder {
2672                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2673                                tx_id: header.tx_id,
2674                            },
2675                        })
2676                    }
2677                    _ if header.tx_id == 0
2678                        && header
2679                            .dynamic_flags()
2680                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2681                    {
2682                        Ok(CpuElementManagerRequest::_UnknownMethod {
2683                            ordinal: header.ordinal,
2684                            control_handle: CpuElementManagerControlHandle {
2685                                inner: this.inner.clone(),
2686                            },
2687                            method_type: fidl::MethodType::OneWay,
2688                        })
2689                    }
2690                    _ if header
2691                        .dynamic_flags()
2692                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2693                    {
2694                        this.inner.send_framework_err(
2695                            fidl::encoding::FrameworkErr::UnknownMethod,
2696                            header.tx_id,
2697                            header.ordinal,
2698                            header.dynamic_flags(),
2699                            (bytes, handles),
2700                        )?;
2701                        Ok(CpuElementManagerRequest::_UnknownMethod {
2702                            ordinal: header.ordinal,
2703                            control_handle: CpuElementManagerControlHandle {
2704                                inner: this.inner.clone(),
2705                            },
2706                            method_type: fidl::MethodType::TwoWay,
2707                        })
2708                    }
2709                    _ => Err(fidl::Error::UnknownOrdinal {
2710                        ordinal: header.ordinal,
2711                        protocol_name:
2712                            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2713                    }),
2714                }))
2715            },
2716        )
2717    }
2718}
2719
2720/// A service that provides access to CPU-related power elements.
2721#[derive(Debug)]
2722pub enum CpuElementManagerRequest {
2723    /// Gets the assertive dependency token for the CPU power element.
2724    GetCpuDependencyToken { responder: CpuElementManagerGetCpuDependencyTokenResponder },
2725    /// Adds a dependency from the Execution State power element to the target
2726    /// power element identified by [`dependency_token`] at [`power_level`].
2727    ///
2728    /// Once the Execution State power element is created, future calls will
2729    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2730    /// and no changes to Execution State dependencies will be made.
2731    ///
2732    /// If any required entries in the request are missing, the server will
2733    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2734    AddExecutionStateDependency {
2735        payload: CpuElementManagerAddExecutionStateDependencyRequest,
2736        responder: CpuElementManagerAddExecutionStateDependencyResponder,
2737    },
2738    /// An interaction was received which does not match any known method.
2739    #[non_exhaustive]
2740    _UnknownMethod {
2741        /// Ordinal of the method that was called.
2742        ordinal: u64,
2743        control_handle: CpuElementManagerControlHandle,
2744        method_type: fidl::MethodType,
2745    },
2746}
2747
2748impl CpuElementManagerRequest {
2749    #[allow(irrefutable_let_patterns)]
2750    pub fn into_get_cpu_dependency_token(
2751        self,
2752    ) -> Option<(CpuElementManagerGetCpuDependencyTokenResponder)> {
2753        if let CpuElementManagerRequest::GetCpuDependencyToken { responder } = self {
2754            Some((responder))
2755        } else {
2756            None
2757        }
2758    }
2759
2760    #[allow(irrefutable_let_patterns)]
2761    pub fn into_add_execution_state_dependency(
2762        self,
2763    ) -> Option<(
2764        CpuElementManagerAddExecutionStateDependencyRequest,
2765        CpuElementManagerAddExecutionStateDependencyResponder,
2766    )> {
2767        if let CpuElementManagerRequest::AddExecutionStateDependency { payload, responder } = self {
2768            Some((payload, responder))
2769        } else {
2770            None
2771        }
2772    }
2773
2774    /// Name of the method defined in FIDL
2775    pub fn method_name(&self) -> &'static str {
2776        match *self {
2777            CpuElementManagerRequest::GetCpuDependencyToken { .. } => "get_cpu_dependency_token",
2778            CpuElementManagerRequest::AddExecutionStateDependency { .. } => {
2779                "add_execution_state_dependency"
2780            }
2781            CpuElementManagerRequest::_UnknownMethod {
2782                method_type: fidl::MethodType::OneWay,
2783                ..
2784            } => "unknown one-way method",
2785            CpuElementManagerRequest::_UnknownMethod {
2786                method_type: fidl::MethodType::TwoWay,
2787                ..
2788            } => "unknown two-way method",
2789        }
2790    }
2791}
2792
2793#[derive(Debug, Clone)]
2794pub struct CpuElementManagerControlHandle {
2795    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2796}
2797
2798impl CpuElementManagerControlHandle {
2799    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2800        self.inner.shutdown_with_epitaph(status.into())
2801    }
2802}
2803
2804impl fidl::endpoints::ControlHandle for CpuElementManagerControlHandle {
2805    fn shutdown(&self) {
2806        self.inner.shutdown()
2807    }
2808
2809    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2810        self.inner.shutdown_with_epitaph(status)
2811    }
2812
2813    fn is_closed(&self) -> bool {
2814        self.inner.channel().is_closed()
2815    }
2816    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2817        self.inner.channel().on_closed()
2818    }
2819
2820    #[cfg(target_os = "fuchsia")]
2821    fn signal_peer(
2822        &self,
2823        clear_mask: zx::Signals,
2824        set_mask: zx::Signals,
2825    ) -> Result<(), zx_status::Status> {
2826        use fidl::Peered;
2827        self.inner.channel().signal_peer(clear_mask, set_mask)
2828    }
2829}
2830
2831impl CpuElementManagerControlHandle {}
2832
2833#[must_use = "FIDL methods require a response to be sent"]
2834#[derive(Debug)]
2835pub struct CpuElementManagerGetCpuDependencyTokenResponder {
2836    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
2837    tx_id: u32,
2838}
2839
2840/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
2841/// if the responder is dropped without sending a response, so that the client
2842/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2843impl std::ops::Drop for CpuElementManagerGetCpuDependencyTokenResponder {
2844    fn drop(&mut self) {
2845        self.control_handle.shutdown();
2846        // Safety: drops once, never accessed again
2847        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2848    }
2849}
2850
2851impl fidl::endpoints::Responder for CpuElementManagerGetCpuDependencyTokenResponder {
2852    type ControlHandle = CpuElementManagerControlHandle;
2853
2854    fn control_handle(&self) -> &CpuElementManagerControlHandle {
2855        &self.control_handle
2856    }
2857
2858    fn drop_without_shutdown(mut self) {
2859        // Safety: drops once, never accessed again due to mem::forget
2860        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2861        // Prevent Drop from running (which would shut down the channel)
2862        std::mem::forget(self);
2863    }
2864}
2865
2866impl CpuElementManagerGetCpuDependencyTokenResponder {
2867    /// Sends a response to the FIDL transaction.
2868    ///
2869    /// Sets the channel to shutdown if an error occurs.
2870    pub fn send(self, mut payload: Cpu) -> Result<(), fidl::Error> {
2871        let _result = self.send_raw(payload);
2872        if _result.is_err() {
2873            self.control_handle.shutdown();
2874        }
2875        self.drop_without_shutdown();
2876        _result
2877    }
2878
2879    /// Similar to "send" but does not shutdown the channel if an error occurs.
2880    pub fn send_no_shutdown_on_err(self, mut payload: Cpu) -> Result<(), fidl::Error> {
2881        let _result = self.send_raw(payload);
2882        self.drop_without_shutdown();
2883        _result
2884    }
2885
2886    fn send_raw(&self, mut payload: Cpu) -> Result<(), fidl::Error> {
2887        self.control_handle.inner.send::<fidl::encoding::FlexibleType<Cpu>>(
2888            fidl::encoding::Flexible::new(&mut payload),
2889            self.tx_id,
2890            0x2c43645ed70344ba,
2891            fidl::encoding::DynamicFlags::FLEXIBLE,
2892        )
2893    }
2894}
2895
2896#[must_use = "FIDL methods require a response to be sent"]
2897#[derive(Debug)]
2898pub struct CpuElementManagerAddExecutionStateDependencyResponder {
2899    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
2900    tx_id: u32,
2901}
2902
2903/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
2904/// if the responder is dropped without sending a response, so that the client
2905/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2906impl std::ops::Drop for CpuElementManagerAddExecutionStateDependencyResponder {
2907    fn drop(&mut self) {
2908        self.control_handle.shutdown();
2909        // Safety: drops once, never accessed again
2910        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2911    }
2912}
2913
2914impl fidl::endpoints::Responder for CpuElementManagerAddExecutionStateDependencyResponder {
2915    type ControlHandle = CpuElementManagerControlHandle;
2916
2917    fn control_handle(&self) -> &CpuElementManagerControlHandle {
2918        &self.control_handle
2919    }
2920
2921    fn drop_without_shutdown(mut self) {
2922        // Safety: drops once, never accessed again due to mem::forget
2923        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2924        // Prevent Drop from running (which would shut down the channel)
2925        std::mem::forget(self);
2926    }
2927}
2928
2929impl CpuElementManagerAddExecutionStateDependencyResponder {
2930    /// Sends a response to the FIDL transaction.
2931    ///
2932    /// Sets the channel to shutdown if an error occurs.
2933    pub fn send(
2934        self,
2935        mut result: Result<(), AddExecutionStateDependencyError>,
2936    ) -> Result<(), fidl::Error> {
2937        let _result = self.send_raw(result);
2938        if _result.is_err() {
2939            self.control_handle.shutdown();
2940        }
2941        self.drop_without_shutdown();
2942        _result
2943    }
2944
2945    /// Similar to "send" but does not shutdown the channel if an error occurs.
2946    pub fn send_no_shutdown_on_err(
2947        self,
2948        mut result: Result<(), AddExecutionStateDependencyError>,
2949    ) -> Result<(), fidl::Error> {
2950        let _result = self.send_raw(result);
2951        self.drop_without_shutdown();
2952        _result
2953    }
2954
2955    fn send_raw(
2956        &self,
2957        mut result: Result<(), AddExecutionStateDependencyError>,
2958    ) -> Result<(), fidl::Error> {
2959        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2960            fidl::encoding::EmptyStruct,
2961            AddExecutionStateDependencyError,
2962        >>(
2963            fidl::encoding::FlexibleResult::new(result),
2964            self.tx_id,
2965            0xdf2f5ea2af76234,
2966            fidl::encoding::DynamicFlags::FLEXIBLE,
2967        )
2968    }
2969}
2970
2971#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2972pub struct ExecutionStateManagerMarker;
2973
2974impl fidl::endpoints::ProtocolMarker for ExecutionStateManagerMarker {
2975    type Proxy = ExecutionStateManagerProxy;
2976    type RequestStream = ExecutionStateManagerRequestStream;
2977    #[cfg(target_os = "fuchsia")]
2978    type SynchronousProxy = ExecutionStateManagerSynchronousProxy;
2979
2980    const DEBUG_NAME: &'static str = "fuchsia.power.system.ExecutionStateManager";
2981}
2982impl fidl::endpoints::DiscoverableProtocolMarker for ExecutionStateManagerMarker {}
2983pub type ExecutionStateManagerAddApplicationActivityDependencyResult =
2984    Result<(), AddApplicationActivityDependencyError>;
2985
2986pub trait ExecutionStateManagerProxyInterface: Send + Sync {
2987    type GetExecutionStateDependencyTokenResponseFut: std::future::Future<Output = Result<ExecutionState, fidl::Error>>
2988        + Send;
2989    fn r#get_execution_state_dependency_token(
2990        &self,
2991    ) -> Self::GetExecutionStateDependencyTokenResponseFut;
2992    type AddApplicationActivityDependencyResponseFut: std::future::Future<
2993            Output = Result<
2994                ExecutionStateManagerAddApplicationActivityDependencyResult,
2995                fidl::Error,
2996            >,
2997        > + Send;
2998    fn r#add_application_activity_dependency(
2999        &self,
3000        payload: ExecutionStateManagerAddApplicationActivityDependencyRequest,
3001    ) -> Self::AddApplicationActivityDependencyResponseFut;
3002}
3003#[derive(Debug)]
3004#[cfg(target_os = "fuchsia")]
3005pub struct ExecutionStateManagerSynchronousProxy {
3006    client: fidl::client::sync::Client,
3007}
3008
3009#[cfg(target_os = "fuchsia")]
3010impl fidl::endpoints::SynchronousProxy for ExecutionStateManagerSynchronousProxy {
3011    type Proxy = ExecutionStateManagerProxy;
3012    type Protocol = ExecutionStateManagerMarker;
3013
3014    fn from_channel(inner: fidl::Channel) -> Self {
3015        Self::new(inner)
3016    }
3017
3018    fn into_channel(self) -> fidl::Channel {
3019        self.client.into_channel()
3020    }
3021
3022    fn as_channel(&self) -> &fidl::Channel {
3023        self.client.as_channel()
3024    }
3025}
3026
3027#[cfg(target_os = "fuchsia")]
3028impl ExecutionStateManagerSynchronousProxy {
3029    pub fn new(channel: fidl::Channel) -> Self {
3030        Self { client: fidl::client::sync::Client::new(channel) }
3031    }
3032
3033    pub fn into_channel(self) -> fidl::Channel {
3034        self.client.into_channel()
3035    }
3036
3037    /// Waits until an event arrives and returns it. It is safe for other
3038    /// threads to make concurrent requests while waiting for an event.
3039    pub fn wait_for_event(
3040        &self,
3041        deadline: zx::MonotonicInstant,
3042    ) -> Result<ExecutionStateManagerEvent, fidl::Error> {
3043        ExecutionStateManagerEvent::decode(
3044            self.client.wait_for_event::<ExecutionStateManagerMarker>(deadline)?,
3045        )
3046    }
3047
3048    /// Gets the dependency token for the execution state power element. This will block if SAG
3049    /// is not fully initialized.
3050    pub fn r#get_execution_state_dependency_token(
3051        &self,
3052        ___deadline: zx::MonotonicInstant,
3053    ) -> Result<ExecutionState, fidl::Error> {
3054        let _response = self.client.send_query::<
3055            fidl::encoding::EmptyPayload,
3056            fidl::encoding::FlexibleType<ExecutionState>,
3057            ExecutionStateManagerMarker,
3058        >(
3059            (),
3060            0x71e8ddeb7f737710,
3061            fidl::encoding::DynamicFlags::FLEXIBLE,
3062            ___deadline,
3063        )?
3064        .into_result::<ExecutionStateManagerMarker>("get_execution_state_dependency_token")?;
3065        Ok(_response)
3066    }
3067
3068    /// Adds a dependency from the Application Activity power element to the target
3069    /// power element identified by [`dependency_token`] at [`power_level`].
3070    /// Be aware of the following client-side conditions:
3071    ///  - If SAG is not fully initialized, the call blocks until initialization is complete.
3072    ///  - The call may block as required by `fuchsia.power.broker/ElementControl.AddDependency`,
3073    ///    which at time of writing may call `fuchsia.power.ElementControl.SetLevel` on the
3074    ///    associated power element.
3075    pub fn r#add_application_activity_dependency(
3076        &self,
3077        mut payload: ExecutionStateManagerAddApplicationActivityDependencyRequest,
3078        ___deadline: zx::MonotonicInstant,
3079    ) -> Result<ExecutionStateManagerAddApplicationActivityDependencyResult, fidl::Error> {
3080        let _response = self.client.send_query::<
3081            ExecutionStateManagerAddApplicationActivityDependencyRequest,
3082            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, AddApplicationActivityDependencyError>,
3083            ExecutionStateManagerMarker,
3084        >(
3085            &mut payload,
3086            0x39959f51c557e1d9,
3087            fidl::encoding::DynamicFlags::FLEXIBLE,
3088            ___deadline,
3089        )?
3090        .into_result::<ExecutionStateManagerMarker>("add_application_activity_dependency")?;
3091        Ok(_response.map(|x| x))
3092    }
3093}
3094
3095#[cfg(target_os = "fuchsia")]
3096impl From<ExecutionStateManagerSynchronousProxy> for zx::NullableHandle {
3097    fn from(value: ExecutionStateManagerSynchronousProxy) -> Self {
3098        value.into_channel().into()
3099    }
3100}
3101
3102#[cfg(target_os = "fuchsia")]
3103impl From<fidl::Channel> for ExecutionStateManagerSynchronousProxy {
3104    fn from(value: fidl::Channel) -> Self {
3105        Self::new(value)
3106    }
3107}
3108
3109#[cfg(target_os = "fuchsia")]
3110impl fidl::endpoints::FromClient for ExecutionStateManagerSynchronousProxy {
3111    type Protocol = ExecutionStateManagerMarker;
3112
3113    fn from_client(value: fidl::endpoints::ClientEnd<ExecutionStateManagerMarker>) -> Self {
3114        Self::new(value.into_channel())
3115    }
3116}
3117
3118#[derive(Debug, Clone)]
3119pub struct ExecutionStateManagerProxy {
3120    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3121}
3122
3123impl fidl::endpoints::Proxy for ExecutionStateManagerProxy {
3124    type Protocol = ExecutionStateManagerMarker;
3125
3126    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3127        Self::new(inner)
3128    }
3129
3130    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3131        self.client.into_channel().map_err(|client| Self { client })
3132    }
3133
3134    fn as_channel(&self) -> &::fidl::AsyncChannel {
3135        self.client.as_channel()
3136    }
3137}
3138
3139impl ExecutionStateManagerProxy {
3140    /// Create a new Proxy for fuchsia.power.system/ExecutionStateManager.
3141    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3142        let protocol_name =
3143            <ExecutionStateManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3144        Self { client: fidl::client::Client::new(channel, protocol_name) }
3145    }
3146
3147    /// Get a Stream of events from the remote end of the protocol.
3148    ///
3149    /// # Panics
3150    ///
3151    /// Panics if the event stream was already taken.
3152    pub fn take_event_stream(&self) -> ExecutionStateManagerEventStream {
3153        ExecutionStateManagerEventStream { event_receiver: self.client.take_event_receiver() }
3154    }
3155
3156    /// Gets the dependency token for the execution state power element. This will block if SAG
3157    /// is not fully initialized.
3158    pub fn r#get_execution_state_dependency_token(
3159        &self,
3160    ) -> fidl::client::QueryResponseFut<ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect>
3161    {
3162        ExecutionStateManagerProxyInterface::r#get_execution_state_dependency_token(self)
3163    }
3164
3165    /// Adds a dependency from the Application Activity power element to the target
3166    /// power element identified by [`dependency_token`] at [`power_level`].
3167    /// Be aware of the following client-side conditions:
3168    ///  - If SAG is not fully initialized, the call blocks until initialization is complete.
3169    ///  - The call may block as required by `fuchsia.power.broker/ElementControl.AddDependency`,
3170    ///    which at time of writing may call `fuchsia.power.ElementControl.SetLevel` on the
3171    ///    associated power element.
3172    pub fn r#add_application_activity_dependency(
3173        &self,
3174        mut payload: ExecutionStateManagerAddApplicationActivityDependencyRequest,
3175    ) -> fidl::client::QueryResponseFut<
3176        ExecutionStateManagerAddApplicationActivityDependencyResult,
3177        fidl::encoding::DefaultFuchsiaResourceDialect,
3178    > {
3179        ExecutionStateManagerProxyInterface::r#add_application_activity_dependency(self, payload)
3180    }
3181}
3182
3183impl ExecutionStateManagerProxyInterface for ExecutionStateManagerProxy {
3184    type GetExecutionStateDependencyTokenResponseFut = fidl::client::QueryResponseFut<
3185        ExecutionState,
3186        fidl::encoding::DefaultFuchsiaResourceDialect,
3187    >;
3188    fn r#get_execution_state_dependency_token(
3189        &self,
3190    ) -> Self::GetExecutionStateDependencyTokenResponseFut {
3191        fn _decode(
3192            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3193        ) -> Result<ExecutionState, fidl::Error> {
3194            let _response = fidl::client::decode_transaction_body::<
3195                fidl::encoding::FlexibleType<ExecutionState>,
3196                fidl::encoding::DefaultFuchsiaResourceDialect,
3197                0x71e8ddeb7f737710,
3198            >(_buf?)?
3199            .into_result::<ExecutionStateManagerMarker>("get_execution_state_dependency_token")?;
3200            Ok(_response)
3201        }
3202        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ExecutionState>(
3203            (),
3204            0x71e8ddeb7f737710,
3205            fidl::encoding::DynamicFlags::FLEXIBLE,
3206            _decode,
3207        )
3208    }
3209
3210    type AddApplicationActivityDependencyResponseFut = fidl::client::QueryResponseFut<
3211        ExecutionStateManagerAddApplicationActivityDependencyResult,
3212        fidl::encoding::DefaultFuchsiaResourceDialect,
3213    >;
3214    fn r#add_application_activity_dependency(
3215        &self,
3216        mut payload: ExecutionStateManagerAddApplicationActivityDependencyRequest,
3217    ) -> Self::AddApplicationActivityDependencyResponseFut {
3218        fn _decode(
3219            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3220        ) -> Result<ExecutionStateManagerAddApplicationActivityDependencyResult, fidl::Error>
3221        {
3222            let _response = fidl::client::decode_transaction_body::<
3223                fidl::encoding::FlexibleResultType<
3224                    fidl::encoding::EmptyStruct,
3225                    AddApplicationActivityDependencyError,
3226                >,
3227                fidl::encoding::DefaultFuchsiaResourceDialect,
3228                0x39959f51c557e1d9,
3229            >(_buf?)?
3230            .into_result::<ExecutionStateManagerMarker>("add_application_activity_dependency")?;
3231            Ok(_response.map(|x| x))
3232        }
3233        self.client.send_query_and_decode::<
3234            ExecutionStateManagerAddApplicationActivityDependencyRequest,
3235            ExecutionStateManagerAddApplicationActivityDependencyResult,
3236        >(
3237            &mut payload,
3238            0x39959f51c557e1d9,
3239            fidl::encoding::DynamicFlags::FLEXIBLE,
3240            _decode,
3241        )
3242    }
3243}
3244
3245pub struct ExecutionStateManagerEventStream {
3246    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3247}
3248
3249impl std::marker::Unpin for ExecutionStateManagerEventStream {}
3250
3251impl futures::stream::FusedStream for ExecutionStateManagerEventStream {
3252    fn is_terminated(&self) -> bool {
3253        self.event_receiver.is_terminated()
3254    }
3255}
3256
3257impl futures::Stream for ExecutionStateManagerEventStream {
3258    type Item = Result<ExecutionStateManagerEvent, fidl::Error>;
3259
3260    fn poll_next(
3261        mut self: std::pin::Pin<&mut Self>,
3262        cx: &mut std::task::Context<'_>,
3263    ) -> std::task::Poll<Option<Self::Item>> {
3264        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3265            &mut self.event_receiver,
3266            cx
3267        )?) {
3268            Some(buf) => std::task::Poll::Ready(Some(ExecutionStateManagerEvent::decode(buf))),
3269            None => std::task::Poll::Ready(None),
3270        }
3271    }
3272}
3273
3274#[derive(Debug)]
3275pub enum ExecutionStateManagerEvent {
3276    #[non_exhaustive]
3277    _UnknownEvent {
3278        /// Ordinal of the event that was sent.
3279        ordinal: u64,
3280    },
3281}
3282
3283impl ExecutionStateManagerEvent {
3284    /// Decodes a message buffer as a [`ExecutionStateManagerEvent`].
3285    fn decode(
3286        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3287    ) -> Result<ExecutionStateManagerEvent, fidl::Error> {
3288        let (bytes, _handles) = buf.split_mut();
3289        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3290        debug_assert_eq!(tx_header.tx_id, 0);
3291        match tx_header.ordinal {
3292            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3293                Ok(ExecutionStateManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3294            }
3295            _ => Err(fidl::Error::UnknownOrdinal {
3296                ordinal: tx_header.ordinal,
3297                protocol_name:
3298                    <ExecutionStateManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3299            }),
3300        }
3301    }
3302}
3303
3304/// A Stream of incoming requests for fuchsia.power.system/ExecutionStateManager.
3305pub struct ExecutionStateManagerRequestStream {
3306    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3307    is_terminated: bool,
3308}
3309
3310impl std::marker::Unpin for ExecutionStateManagerRequestStream {}
3311
3312impl futures::stream::FusedStream for ExecutionStateManagerRequestStream {
3313    fn is_terminated(&self) -> bool {
3314        self.is_terminated
3315    }
3316}
3317
3318impl fidl::endpoints::RequestStream for ExecutionStateManagerRequestStream {
3319    type Protocol = ExecutionStateManagerMarker;
3320    type ControlHandle = ExecutionStateManagerControlHandle;
3321
3322    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3323        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3324    }
3325
3326    fn control_handle(&self) -> Self::ControlHandle {
3327        ExecutionStateManagerControlHandle { inner: self.inner.clone() }
3328    }
3329
3330    fn into_inner(
3331        self,
3332    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3333    {
3334        (self.inner, self.is_terminated)
3335    }
3336
3337    fn from_inner(
3338        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3339        is_terminated: bool,
3340    ) -> Self {
3341        Self { inner, is_terminated }
3342    }
3343}
3344
3345impl futures::Stream for ExecutionStateManagerRequestStream {
3346    type Item = Result<ExecutionStateManagerRequest, fidl::Error>;
3347
3348    fn poll_next(
3349        mut self: std::pin::Pin<&mut Self>,
3350        cx: &mut std::task::Context<'_>,
3351    ) -> std::task::Poll<Option<Self::Item>> {
3352        let this = &mut *self;
3353        if this.inner.check_shutdown(cx) {
3354            this.is_terminated = true;
3355            return std::task::Poll::Ready(None);
3356        }
3357        if this.is_terminated {
3358            panic!("polled ExecutionStateManagerRequestStream after completion");
3359        }
3360        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3361            |bytes, handles| {
3362                match this.inner.channel().read_etc(cx, bytes, handles) {
3363                    std::task::Poll::Ready(Ok(())) => {}
3364                    std::task::Poll::Pending => return std::task::Poll::Pending,
3365                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3366                        this.is_terminated = true;
3367                        return std::task::Poll::Ready(None);
3368                    }
3369                    std::task::Poll::Ready(Err(e)) => {
3370                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3371                            e.into(),
3372                        ))));
3373                    }
3374                }
3375
3376                // A message has been received from the channel
3377                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3378
3379                std::task::Poll::Ready(Some(match header.ordinal {
3380                0x71e8ddeb7f737710 => {
3381                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3382                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
3383                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3384                    let control_handle = ExecutionStateManagerControlHandle {
3385                        inner: this.inner.clone(),
3386                    };
3387                    Ok(ExecutionStateManagerRequest::GetExecutionStateDependencyToken {
3388                        responder: ExecutionStateManagerGetExecutionStateDependencyTokenResponder {
3389                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3390                            tx_id: header.tx_id,
3391                        },
3392                    })
3393                }
3394                0x39959f51c557e1d9 => {
3395                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3396                    let mut req = fidl::new_empty!(ExecutionStateManagerAddApplicationActivityDependencyRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
3397                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ExecutionStateManagerAddApplicationActivityDependencyRequest>(&header, _body_bytes, handles, &mut req)?;
3398                    let control_handle = ExecutionStateManagerControlHandle {
3399                        inner: this.inner.clone(),
3400                    };
3401                    Ok(ExecutionStateManagerRequest::AddApplicationActivityDependency {payload: req,
3402                        responder: ExecutionStateManagerAddApplicationActivityDependencyResponder {
3403                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3404                            tx_id: header.tx_id,
3405                        },
3406                    })
3407                }
3408                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3409                    Ok(ExecutionStateManagerRequest::_UnknownMethod {
3410                        ordinal: header.ordinal,
3411                        control_handle: ExecutionStateManagerControlHandle { inner: this.inner.clone() },
3412                        method_type: fidl::MethodType::OneWay,
3413                    })
3414                }
3415                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3416                    this.inner.send_framework_err(
3417                        fidl::encoding::FrameworkErr::UnknownMethod,
3418                        header.tx_id,
3419                        header.ordinal,
3420                        header.dynamic_flags(),
3421                        (bytes, handles),
3422                    )?;
3423                    Ok(ExecutionStateManagerRequest::_UnknownMethod {
3424                        ordinal: header.ordinal,
3425                        control_handle: ExecutionStateManagerControlHandle { inner: this.inner.clone() },
3426                        method_type: fidl::MethodType::TwoWay,
3427                    })
3428                }
3429                _ => Err(fidl::Error::UnknownOrdinal {
3430                    ordinal: header.ordinal,
3431                    protocol_name: <ExecutionStateManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3432                }),
3433            }))
3434            },
3435        )
3436    }
3437}
3438
3439/// A service for exposing execution state management capabilities.
3440#[derive(Debug)]
3441pub enum ExecutionStateManagerRequest {
3442    /// Gets the dependency token for the execution state power element. This will block if SAG
3443    /// is not fully initialized.
3444    GetExecutionStateDependencyToken {
3445        responder: ExecutionStateManagerGetExecutionStateDependencyTokenResponder,
3446    },
3447    /// Adds a dependency from the Application Activity power element to the target
3448    /// power element identified by [`dependency_token`] at [`power_level`].
3449    /// Be aware of the following client-side conditions:
3450    ///  - If SAG is not fully initialized, the call blocks until initialization is complete.
3451    ///  - The call may block as required by `fuchsia.power.broker/ElementControl.AddDependency`,
3452    ///    which at time of writing may call `fuchsia.power.ElementControl.SetLevel` on the
3453    ///    associated power element.
3454    AddApplicationActivityDependency {
3455        payload: ExecutionStateManagerAddApplicationActivityDependencyRequest,
3456        responder: ExecutionStateManagerAddApplicationActivityDependencyResponder,
3457    },
3458    /// An interaction was received which does not match any known method.
3459    #[non_exhaustive]
3460    _UnknownMethod {
3461        /// Ordinal of the method that was called.
3462        ordinal: u64,
3463        control_handle: ExecutionStateManagerControlHandle,
3464        method_type: fidl::MethodType,
3465    },
3466}
3467
3468impl ExecutionStateManagerRequest {
3469    #[allow(irrefutable_let_patterns)]
3470    pub fn into_get_execution_state_dependency_token(
3471        self,
3472    ) -> Option<(ExecutionStateManagerGetExecutionStateDependencyTokenResponder)> {
3473        if let ExecutionStateManagerRequest::GetExecutionStateDependencyToken { responder } = self {
3474            Some((responder))
3475        } else {
3476            None
3477        }
3478    }
3479
3480    #[allow(irrefutable_let_patterns)]
3481    pub fn into_add_application_activity_dependency(
3482        self,
3483    ) -> Option<(
3484        ExecutionStateManagerAddApplicationActivityDependencyRequest,
3485        ExecutionStateManagerAddApplicationActivityDependencyResponder,
3486    )> {
3487        if let ExecutionStateManagerRequest::AddApplicationActivityDependency {
3488            payload,
3489            responder,
3490        } = self
3491        {
3492            Some((payload, responder))
3493        } else {
3494            None
3495        }
3496    }
3497
3498    /// Name of the method defined in FIDL
3499    pub fn method_name(&self) -> &'static str {
3500        match *self {
3501            ExecutionStateManagerRequest::GetExecutionStateDependencyToken { .. } => {
3502                "get_execution_state_dependency_token"
3503            }
3504            ExecutionStateManagerRequest::AddApplicationActivityDependency { .. } => {
3505                "add_application_activity_dependency"
3506            }
3507            ExecutionStateManagerRequest::_UnknownMethod {
3508                method_type: fidl::MethodType::OneWay,
3509                ..
3510            } => "unknown one-way method",
3511            ExecutionStateManagerRequest::_UnknownMethod {
3512                method_type: fidl::MethodType::TwoWay,
3513                ..
3514            } => "unknown two-way method",
3515        }
3516    }
3517}
3518
3519#[derive(Debug, Clone)]
3520pub struct ExecutionStateManagerControlHandle {
3521    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3522}
3523
3524impl ExecutionStateManagerControlHandle {
3525    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3526        self.inner.shutdown_with_epitaph(status.into())
3527    }
3528}
3529
3530impl fidl::endpoints::ControlHandle for ExecutionStateManagerControlHandle {
3531    fn shutdown(&self) {
3532        self.inner.shutdown()
3533    }
3534
3535    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3536        self.inner.shutdown_with_epitaph(status)
3537    }
3538
3539    fn is_closed(&self) -> bool {
3540        self.inner.channel().is_closed()
3541    }
3542    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3543        self.inner.channel().on_closed()
3544    }
3545
3546    #[cfg(target_os = "fuchsia")]
3547    fn signal_peer(
3548        &self,
3549        clear_mask: zx::Signals,
3550        set_mask: zx::Signals,
3551    ) -> Result<(), zx_status::Status> {
3552        use fidl::Peered;
3553        self.inner.channel().signal_peer(clear_mask, set_mask)
3554    }
3555}
3556
3557impl ExecutionStateManagerControlHandle {}
3558
3559#[must_use = "FIDL methods require a response to be sent"]
3560#[derive(Debug)]
3561pub struct ExecutionStateManagerGetExecutionStateDependencyTokenResponder {
3562    control_handle: std::mem::ManuallyDrop<ExecutionStateManagerControlHandle>,
3563    tx_id: u32,
3564}
3565
3566/// Set the the channel to be shutdown (see [`ExecutionStateManagerControlHandle::shutdown`])
3567/// if the responder is dropped without sending a response, so that the client
3568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3569impl std::ops::Drop for ExecutionStateManagerGetExecutionStateDependencyTokenResponder {
3570    fn drop(&mut self) {
3571        self.control_handle.shutdown();
3572        // Safety: drops once, never accessed again
3573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3574    }
3575}
3576
3577impl fidl::endpoints::Responder for ExecutionStateManagerGetExecutionStateDependencyTokenResponder {
3578    type ControlHandle = ExecutionStateManagerControlHandle;
3579
3580    fn control_handle(&self) -> &ExecutionStateManagerControlHandle {
3581        &self.control_handle
3582    }
3583
3584    fn drop_without_shutdown(mut self) {
3585        // Safety: drops once, never accessed again due to mem::forget
3586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3587        // Prevent Drop from running (which would shut down the channel)
3588        std::mem::forget(self);
3589    }
3590}
3591
3592impl ExecutionStateManagerGetExecutionStateDependencyTokenResponder {
3593    /// Sends a response to the FIDL transaction.
3594    ///
3595    /// Sets the channel to shutdown if an error occurs.
3596    pub fn send(self, mut payload: ExecutionState) -> Result<(), fidl::Error> {
3597        let _result = self.send_raw(payload);
3598        if _result.is_err() {
3599            self.control_handle.shutdown();
3600        }
3601        self.drop_without_shutdown();
3602        _result
3603    }
3604
3605    /// Similar to "send" but does not shutdown the channel if an error occurs.
3606    pub fn send_no_shutdown_on_err(self, mut payload: ExecutionState) -> Result<(), fidl::Error> {
3607        let _result = self.send_raw(payload);
3608        self.drop_without_shutdown();
3609        _result
3610    }
3611
3612    fn send_raw(&self, mut payload: ExecutionState) -> Result<(), fidl::Error> {
3613        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ExecutionState>>(
3614            fidl::encoding::Flexible::new(&mut payload),
3615            self.tx_id,
3616            0x71e8ddeb7f737710,
3617            fidl::encoding::DynamicFlags::FLEXIBLE,
3618        )
3619    }
3620}
3621
3622#[must_use = "FIDL methods require a response to be sent"]
3623#[derive(Debug)]
3624pub struct ExecutionStateManagerAddApplicationActivityDependencyResponder {
3625    control_handle: std::mem::ManuallyDrop<ExecutionStateManagerControlHandle>,
3626    tx_id: u32,
3627}
3628
3629/// Set the the channel to be shutdown (see [`ExecutionStateManagerControlHandle::shutdown`])
3630/// if the responder is dropped without sending a response, so that the client
3631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3632impl std::ops::Drop for ExecutionStateManagerAddApplicationActivityDependencyResponder {
3633    fn drop(&mut self) {
3634        self.control_handle.shutdown();
3635        // Safety: drops once, never accessed again
3636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3637    }
3638}
3639
3640impl fidl::endpoints::Responder for ExecutionStateManagerAddApplicationActivityDependencyResponder {
3641    type ControlHandle = ExecutionStateManagerControlHandle;
3642
3643    fn control_handle(&self) -> &ExecutionStateManagerControlHandle {
3644        &self.control_handle
3645    }
3646
3647    fn drop_without_shutdown(mut self) {
3648        // Safety: drops once, never accessed again due to mem::forget
3649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3650        // Prevent Drop from running (which would shut down the channel)
3651        std::mem::forget(self);
3652    }
3653}
3654
3655impl ExecutionStateManagerAddApplicationActivityDependencyResponder {
3656    /// Sends a response to the FIDL transaction.
3657    ///
3658    /// Sets the channel to shutdown if an error occurs.
3659    pub fn send(
3660        self,
3661        mut result: Result<(), AddApplicationActivityDependencyError>,
3662    ) -> Result<(), fidl::Error> {
3663        let _result = self.send_raw(result);
3664        if _result.is_err() {
3665            self.control_handle.shutdown();
3666        }
3667        self.drop_without_shutdown();
3668        _result
3669    }
3670
3671    /// Similar to "send" but does not shutdown the channel if an error occurs.
3672    pub fn send_no_shutdown_on_err(
3673        self,
3674        mut result: Result<(), AddApplicationActivityDependencyError>,
3675    ) -> Result<(), fidl::Error> {
3676        let _result = self.send_raw(result);
3677        self.drop_without_shutdown();
3678        _result
3679    }
3680
3681    fn send_raw(
3682        &self,
3683        mut result: Result<(), AddApplicationActivityDependencyError>,
3684    ) -> Result<(), fidl::Error> {
3685        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3686            fidl::encoding::EmptyStruct,
3687            AddApplicationActivityDependencyError,
3688        >>(
3689            fidl::encoding::FlexibleResult::new(result),
3690            self.tx_id,
3691            0x39959f51c557e1d9,
3692            fidl::encoding::DynamicFlags::FLEXIBLE,
3693        )
3694    }
3695}
3696
3697#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3698pub struct SuspendBlockerMarker;
3699
3700impl fidl::endpoints::ProtocolMarker for SuspendBlockerMarker {
3701    type Proxy = SuspendBlockerProxy;
3702    type RequestStream = SuspendBlockerRequestStream;
3703    #[cfg(target_os = "fuchsia")]
3704    type SynchronousProxy = SuspendBlockerSynchronousProxy;
3705
3706    const DEBUG_NAME: &'static str = "(anonymous) SuspendBlocker";
3707}
3708
3709pub trait SuspendBlockerProxyInterface: Send + Sync {
3710    type BeforeSuspendResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3711    fn r#before_suspend(&self) -> Self::BeforeSuspendResponseFut;
3712    type AfterResumeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3713    fn r#after_resume(&self) -> Self::AfterResumeResponseFut;
3714}
3715#[derive(Debug)]
3716#[cfg(target_os = "fuchsia")]
3717pub struct SuspendBlockerSynchronousProxy {
3718    client: fidl::client::sync::Client,
3719}
3720
3721#[cfg(target_os = "fuchsia")]
3722impl fidl::endpoints::SynchronousProxy for SuspendBlockerSynchronousProxy {
3723    type Proxy = SuspendBlockerProxy;
3724    type Protocol = SuspendBlockerMarker;
3725
3726    fn from_channel(inner: fidl::Channel) -> Self {
3727        Self::new(inner)
3728    }
3729
3730    fn into_channel(self) -> fidl::Channel {
3731        self.client.into_channel()
3732    }
3733
3734    fn as_channel(&self) -> &fidl::Channel {
3735        self.client.as_channel()
3736    }
3737}
3738
3739#[cfg(target_os = "fuchsia")]
3740impl SuspendBlockerSynchronousProxy {
3741    pub fn new(channel: fidl::Channel) -> Self {
3742        Self { client: fidl::client::sync::Client::new(channel) }
3743    }
3744
3745    pub fn into_channel(self) -> fidl::Channel {
3746        self.client.into_channel()
3747    }
3748
3749    /// Waits until an event arrives and returns it. It is safe for other
3750    /// threads to make concurrent requests while waiting for an event.
3751    pub fn wait_for_event(
3752        &self,
3753        deadline: zx::MonotonicInstant,
3754    ) -> Result<SuspendBlockerEvent, fidl::Error> {
3755        SuspendBlockerEvent::decode(self.client.wait_for_event::<SuspendBlockerMarker>(deadline)?)
3756    }
3757
3758    /// Called after system activity governor begins operations to suspend the
3759    /// hardware platform.
3760    ///
3761    /// The server is expected to respond once it has performed the operations
3762    /// it needs to prepare itself for suspend, if any. All dependencies of
3763    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3764    /// the duration of this call and may be revoked once the server replies.
3765    ///
3766    /// Operations to suspend the hardware platform may vary between different
3767    /// hardware platforms and product configurations. At a minimum, the client
3768    /// and server MUST assume that general code execution continues
3769    /// until a reply to this call is received by the client. If the
3770    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3771    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3772    ///
3773    /// ExecutionState will be at its SUSPENDING level for the duration of this
3774    /// call. Consequently, a SuspendBlocker MUST NOT call
3775    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
3776    ///  action that blocks on Execution State reaching a level other than
3777    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
3778    /// does _not_ block in this way and is safe to call.)
3779    pub fn r#before_suspend(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3780        let _response = self.client.send_query::<
3781            fidl::encoding::EmptyPayload,
3782            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3783            SuspendBlockerMarker,
3784        >(
3785            (),
3786            0x6b569393a01a6d80,
3787            fidl::encoding::DynamicFlags::FLEXIBLE,
3788            ___deadline,
3789        )?
3790        .into_result::<SuspendBlockerMarker>("before_suspend")?;
3791        Ok(_response)
3792    }
3793
3794    /// Called after system activity governor is aware that the hardware
3795    /// platform has resumed.
3796    ///
3797    /// For the duration of this call, ExecutionState is at level INACTIVE,
3798    /// but all dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed
3799    /// be satisified.
3800    ///
3801    /// Consequently, a SuspendBlocker MUST NOT call
3802    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
3803    ///  action that blocks on Execution State reaching a level other than
3804    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
3805    /// does _not_ block in this way and is safe to call.)
3806    pub fn r#after_resume(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3807        let _response = self.client.send_query::<
3808            fidl::encoding::EmptyPayload,
3809            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3810            SuspendBlockerMarker,
3811        >(
3812            (),
3813            0x6a329cfcc73f2dea,
3814            fidl::encoding::DynamicFlags::FLEXIBLE,
3815            ___deadline,
3816        )?
3817        .into_result::<SuspendBlockerMarker>("after_resume")?;
3818        Ok(_response)
3819    }
3820}
3821
3822#[cfg(target_os = "fuchsia")]
3823impl From<SuspendBlockerSynchronousProxy> for zx::NullableHandle {
3824    fn from(value: SuspendBlockerSynchronousProxy) -> Self {
3825        value.into_channel().into()
3826    }
3827}
3828
3829#[cfg(target_os = "fuchsia")]
3830impl From<fidl::Channel> for SuspendBlockerSynchronousProxy {
3831    fn from(value: fidl::Channel) -> Self {
3832        Self::new(value)
3833    }
3834}
3835
3836#[cfg(target_os = "fuchsia")]
3837impl fidl::endpoints::FromClient for SuspendBlockerSynchronousProxy {
3838    type Protocol = SuspendBlockerMarker;
3839
3840    fn from_client(value: fidl::endpoints::ClientEnd<SuspendBlockerMarker>) -> Self {
3841        Self::new(value.into_channel())
3842    }
3843}
3844
3845#[derive(Debug, Clone)]
3846pub struct SuspendBlockerProxy {
3847    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3848}
3849
3850impl fidl::endpoints::Proxy for SuspendBlockerProxy {
3851    type Protocol = SuspendBlockerMarker;
3852
3853    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3854        Self::new(inner)
3855    }
3856
3857    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3858        self.client.into_channel().map_err(|client| Self { client })
3859    }
3860
3861    fn as_channel(&self) -> &::fidl::AsyncChannel {
3862        self.client.as_channel()
3863    }
3864}
3865
3866impl SuspendBlockerProxy {
3867    /// Create a new Proxy for fuchsia.power.system/SuspendBlocker.
3868    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3869        let protocol_name = <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3870        Self { client: fidl::client::Client::new(channel, protocol_name) }
3871    }
3872
3873    /// Get a Stream of events from the remote end of the protocol.
3874    ///
3875    /// # Panics
3876    ///
3877    /// Panics if the event stream was already taken.
3878    pub fn take_event_stream(&self) -> SuspendBlockerEventStream {
3879        SuspendBlockerEventStream { event_receiver: self.client.take_event_receiver() }
3880    }
3881
3882    /// Called after system activity governor begins operations to suspend the
3883    /// hardware platform.
3884    ///
3885    /// The server is expected to respond once it has performed the operations
3886    /// it needs to prepare itself for suspend, if any. All dependencies of
3887    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3888    /// the duration of this call and may be revoked once the server replies.
3889    ///
3890    /// Operations to suspend the hardware platform may vary between different
3891    /// hardware platforms and product configurations. At a minimum, the client
3892    /// and server MUST assume that general code execution continues
3893    /// until a reply to this call is received by the client. If the
3894    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3895    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3896    ///
3897    /// ExecutionState will be at its SUSPENDING level for the duration of this
3898    /// call. Consequently, a SuspendBlocker MUST NOT call
3899    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
3900    ///  action that blocks on Execution State reaching a level other than
3901    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
3902    /// does _not_ block in this way and is safe to call.)
3903    pub fn r#before_suspend(
3904        &self,
3905    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3906        SuspendBlockerProxyInterface::r#before_suspend(self)
3907    }
3908
3909    /// Called after system activity governor is aware that the hardware
3910    /// platform has resumed.
3911    ///
3912    /// For the duration of this call, ExecutionState is at level INACTIVE,
3913    /// but all dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed
3914    /// be satisified.
3915    ///
3916    /// Consequently, a SuspendBlocker MUST NOT call
3917    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
3918    ///  action that blocks on Execution State reaching a level other than
3919    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
3920    /// does _not_ block in this way and is safe to call.)
3921    pub fn r#after_resume(
3922        &self,
3923    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3924        SuspendBlockerProxyInterface::r#after_resume(self)
3925    }
3926}
3927
3928impl SuspendBlockerProxyInterface for SuspendBlockerProxy {
3929    type BeforeSuspendResponseFut =
3930        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3931    fn r#before_suspend(&self) -> Self::BeforeSuspendResponseFut {
3932        fn _decode(
3933            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3934        ) -> Result<(), fidl::Error> {
3935            let _response = fidl::client::decode_transaction_body::<
3936                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3937                fidl::encoding::DefaultFuchsiaResourceDialect,
3938                0x6b569393a01a6d80,
3939            >(_buf?)?
3940            .into_result::<SuspendBlockerMarker>("before_suspend")?;
3941            Ok(_response)
3942        }
3943        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3944            (),
3945            0x6b569393a01a6d80,
3946            fidl::encoding::DynamicFlags::FLEXIBLE,
3947            _decode,
3948        )
3949    }
3950
3951    type AfterResumeResponseFut =
3952        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3953    fn r#after_resume(&self) -> Self::AfterResumeResponseFut {
3954        fn _decode(
3955            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3956        ) -> Result<(), fidl::Error> {
3957            let _response = fidl::client::decode_transaction_body::<
3958                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3959                fidl::encoding::DefaultFuchsiaResourceDialect,
3960                0x6a329cfcc73f2dea,
3961            >(_buf?)?
3962            .into_result::<SuspendBlockerMarker>("after_resume")?;
3963            Ok(_response)
3964        }
3965        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3966            (),
3967            0x6a329cfcc73f2dea,
3968            fidl::encoding::DynamicFlags::FLEXIBLE,
3969            _decode,
3970        )
3971    }
3972}
3973
3974pub struct SuspendBlockerEventStream {
3975    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3976}
3977
3978impl std::marker::Unpin for SuspendBlockerEventStream {}
3979
3980impl futures::stream::FusedStream for SuspendBlockerEventStream {
3981    fn is_terminated(&self) -> bool {
3982        self.event_receiver.is_terminated()
3983    }
3984}
3985
3986impl futures::Stream for SuspendBlockerEventStream {
3987    type Item = Result<SuspendBlockerEvent, fidl::Error>;
3988
3989    fn poll_next(
3990        mut self: std::pin::Pin<&mut Self>,
3991        cx: &mut std::task::Context<'_>,
3992    ) -> std::task::Poll<Option<Self::Item>> {
3993        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3994            &mut self.event_receiver,
3995            cx
3996        )?) {
3997            Some(buf) => std::task::Poll::Ready(Some(SuspendBlockerEvent::decode(buf))),
3998            None => std::task::Poll::Ready(None),
3999        }
4000    }
4001}
4002
4003#[derive(Debug)]
4004pub enum SuspendBlockerEvent {
4005    #[non_exhaustive]
4006    _UnknownEvent {
4007        /// Ordinal of the event that was sent.
4008        ordinal: u64,
4009    },
4010}
4011
4012impl SuspendBlockerEvent {
4013    /// Decodes a message buffer as a [`SuspendBlockerEvent`].
4014    fn decode(
4015        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4016    ) -> Result<SuspendBlockerEvent, fidl::Error> {
4017        let (bytes, _handles) = buf.split_mut();
4018        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4019        debug_assert_eq!(tx_header.tx_id, 0);
4020        match tx_header.ordinal {
4021            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4022                Ok(SuspendBlockerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4023            }
4024            _ => Err(fidl::Error::UnknownOrdinal {
4025                ordinal: tx_header.ordinal,
4026                protocol_name:
4027                    <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4028            }),
4029        }
4030    }
4031}
4032
4033/// A Stream of incoming requests for fuchsia.power.system/SuspendBlocker.
4034pub struct SuspendBlockerRequestStream {
4035    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4036    is_terminated: bool,
4037}
4038
4039impl std::marker::Unpin for SuspendBlockerRequestStream {}
4040
4041impl futures::stream::FusedStream for SuspendBlockerRequestStream {
4042    fn is_terminated(&self) -> bool {
4043        self.is_terminated
4044    }
4045}
4046
4047impl fidl::endpoints::RequestStream for SuspendBlockerRequestStream {
4048    type Protocol = SuspendBlockerMarker;
4049    type ControlHandle = SuspendBlockerControlHandle;
4050
4051    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4052        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4053    }
4054
4055    fn control_handle(&self) -> Self::ControlHandle {
4056        SuspendBlockerControlHandle { inner: self.inner.clone() }
4057    }
4058
4059    fn into_inner(
4060        self,
4061    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4062    {
4063        (self.inner, self.is_terminated)
4064    }
4065
4066    fn from_inner(
4067        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4068        is_terminated: bool,
4069    ) -> Self {
4070        Self { inner, is_terminated }
4071    }
4072}
4073
4074impl futures::Stream for SuspendBlockerRequestStream {
4075    type Item = Result<SuspendBlockerRequest, fidl::Error>;
4076
4077    fn poll_next(
4078        mut self: std::pin::Pin<&mut Self>,
4079        cx: &mut std::task::Context<'_>,
4080    ) -> std::task::Poll<Option<Self::Item>> {
4081        let this = &mut *self;
4082        if this.inner.check_shutdown(cx) {
4083            this.is_terminated = true;
4084            return std::task::Poll::Ready(None);
4085        }
4086        if this.is_terminated {
4087            panic!("polled SuspendBlockerRequestStream after completion");
4088        }
4089        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4090            |bytes, handles| {
4091                match this.inner.channel().read_etc(cx, bytes, handles) {
4092                    std::task::Poll::Ready(Ok(())) => {}
4093                    std::task::Poll::Pending => return std::task::Poll::Pending,
4094                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4095                        this.is_terminated = true;
4096                        return std::task::Poll::Ready(None);
4097                    }
4098                    std::task::Poll::Ready(Err(e)) => {
4099                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4100                            e.into(),
4101                        ))));
4102                    }
4103                }
4104
4105                // A message has been received from the channel
4106                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4107
4108                std::task::Poll::Ready(Some(match header.ordinal {
4109                    0x6b569393a01a6d80 => {
4110                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4111                        let mut req = fidl::new_empty!(
4112                            fidl::encoding::EmptyPayload,
4113                            fidl::encoding::DefaultFuchsiaResourceDialect
4114                        );
4115                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4116                        let control_handle =
4117                            SuspendBlockerControlHandle { inner: this.inner.clone() };
4118                        Ok(SuspendBlockerRequest::BeforeSuspend {
4119                            responder: SuspendBlockerBeforeSuspendResponder {
4120                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4121                                tx_id: header.tx_id,
4122                            },
4123                        })
4124                    }
4125                    0x6a329cfcc73f2dea => {
4126                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4127                        let mut req = fidl::new_empty!(
4128                            fidl::encoding::EmptyPayload,
4129                            fidl::encoding::DefaultFuchsiaResourceDialect
4130                        );
4131                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4132                        let control_handle =
4133                            SuspendBlockerControlHandle { inner: this.inner.clone() };
4134                        Ok(SuspendBlockerRequest::AfterResume {
4135                            responder: SuspendBlockerAfterResumeResponder {
4136                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4137                                tx_id: header.tx_id,
4138                            },
4139                        })
4140                    }
4141                    _ if header.tx_id == 0
4142                        && header
4143                            .dynamic_flags()
4144                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4145                    {
4146                        Ok(SuspendBlockerRequest::_UnknownMethod {
4147                            ordinal: header.ordinal,
4148                            control_handle: SuspendBlockerControlHandle {
4149                                inner: this.inner.clone(),
4150                            },
4151                            method_type: fidl::MethodType::OneWay,
4152                        })
4153                    }
4154                    _ if header
4155                        .dynamic_flags()
4156                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4157                    {
4158                        this.inner.send_framework_err(
4159                            fidl::encoding::FrameworkErr::UnknownMethod,
4160                            header.tx_id,
4161                            header.ordinal,
4162                            header.dynamic_flags(),
4163                            (bytes, handles),
4164                        )?;
4165                        Ok(SuspendBlockerRequest::_UnknownMethod {
4166                            ordinal: header.ordinal,
4167                            control_handle: SuspendBlockerControlHandle {
4168                                inner: this.inner.clone(),
4169                            },
4170                            method_type: fidl::MethodType::TwoWay,
4171                        })
4172                    }
4173                    _ => Err(fidl::Error::UnknownOrdinal {
4174                        ordinal: header.ordinal,
4175                        protocol_name:
4176                            <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4177                    }),
4178                }))
4179            },
4180        )
4181    }
4182}
4183
4184/// An entity that blocks suspend until it handles transitions across hardware
4185/// platform suspend and resume.
4186#[derive(Debug)]
4187pub enum SuspendBlockerRequest {
4188    /// Called after system activity governor begins operations to suspend the
4189    /// hardware platform.
4190    ///
4191    /// The server is expected to respond once it has performed the operations
4192    /// it needs to prepare itself for suspend, if any. All dependencies of
4193    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
4194    /// the duration of this call and may be revoked once the server replies.
4195    ///
4196    /// Operations to suspend the hardware platform may vary between different
4197    /// hardware platforms and product configurations. At a minimum, the client
4198    /// and server MUST assume that general code execution continues
4199    /// until a reply to this call is received by the client. If the
4200    /// SuspendBlocker wants to preempt suspend operations, it MUST call
4201    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
4202    ///
4203    /// ExecutionState will be at its SUSPENDING level for the duration of this
4204    /// call. Consequently, a SuspendBlocker MUST NOT call
4205    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
4206    ///  action that blocks on Execution State reaching a level other than
4207    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
4208    /// does _not_ block in this way and is safe to call.)
4209    BeforeSuspend { responder: SuspendBlockerBeforeSuspendResponder },
4210    /// Called after system activity governor is aware that the hardware
4211    /// platform has resumed.
4212    ///
4213    /// For the duration of this call, ExecutionState is at level INACTIVE,
4214    /// but all dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed
4215    /// be satisified.
4216    ///
4217    /// Consequently, a SuspendBlocker MUST NOT call
4218    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any other
4219    ///  action that blocks on Execution State reaching a level other than
4220    /// INACTIVE. Doing so will result in a deadlock. (However, AcquireWakeLease
4221    /// does _not_ block in this way and is safe to call.)
4222    AfterResume { responder: SuspendBlockerAfterResumeResponder },
4223    /// An interaction was received which does not match any known method.
4224    #[non_exhaustive]
4225    _UnknownMethod {
4226        /// Ordinal of the method that was called.
4227        ordinal: u64,
4228        control_handle: SuspendBlockerControlHandle,
4229        method_type: fidl::MethodType,
4230    },
4231}
4232
4233impl SuspendBlockerRequest {
4234    #[allow(irrefutable_let_patterns)]
4235    pub fn into_before_suspend(self) -> Option<(SuspendBlockerBeforeSuspendResponder)> {
4236        if let SuspendBlockerRequest::BeforeSuspend { responder } = self {
4237            Some((responder))
4238        } else {
4239            None
4240        }
4241    }
4242
4243    #[allow(irrefutable_let_patterns)]
4244    pub fn into_after_resume(self) -> Option<(SuspendBlockerAfterResumeResponder)> {
4245        if let SuspendBlockerRequest::AfterResume { responder } = self {
4246            Some((responder))
4247        } else {
4248            None
4249        }
4250    }
4251
4252    /// Name of the method defined in FIDL
4253    pub fn method_name(&self) -> &'static str {
4254        match *self {
4255            SuspendBlockerRequest::BeforeSuspend { .. } => "before_suspend",
4256            SuspendBlockerRequest::AfterResume { .. } => "after_resume",
4257            SuspendBlockerRequest::_UnknownMethod {
4258                method_type: fidl::MethodType::OneWay, ..
4259            } => "unknown one-way method",
4260            SuspendBlockerRequest::_UnknownMethod {
4261                method_type: fidl::MethodType::TwoWay, ..
4262            } => "unknown two-way method",
4263        }
4264    }
4265}
4266
4267#[derive(Debug, Clone)]
4268pub struct SuspendBlockerControlHandle {
4269    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4270}
4271
4272impl SuspendBlockerControlHandle {
4273    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4274        self.inner.shutdown_with_epitaph(status.into())
4275    }
4276}
4277
4278impl fidl::endpoints::ControlHandle for SuspendBlockerControlHandle {
4279    fn shutdown(&self) {
4280        self.inner.shutdown()
4281    }
4282
4283    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4284        self.inner.shutdown_with_epitaph(status)
4285    }
4286
4287    fn is_closed(&self) -> bool {
4288        self.inner.channel().is_closed()
4289    }
4290    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4291        self.inner.channel().on_closed()
4292    }
4293
4294    #[cfg(target_os = "fuchsia")]
4295    fn signal_peer(
4296        &self,
4297        clear_mask: zx::Signals,
4298        set_mask: zx::Signals,
4299    ) -> Result<(), zx_status::Status> {
4300        use fidl::Peered;
4301        self.inner.channel().signal_peer(clear_mask, set_mask)
4302    }
4303}
4304
4305impl SuspendBlockerControlHandle {}
4306
4307#[must_use = "FIDL methods require a response to be sent"]
4308#[derive(Debug)]
4309pub struct SuspendBlockerBeforeSuspendResponder {
4310    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
4311    tx_id: u32,
4312}
4313
4314/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
4315/// if the responder is dropped without sending a response, so that the client
4316/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4317impl std::ops::Drop for SuspendBlockerBeforeSuspendResponder {
4318    fn drop(&mut self) {
4319        self.control_handle.shutdown();
4320        // Safety: drops once, never accessed again
4321        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4322    }
4323}
4324
4325impl fidl::endpoints::Responder for SuspendBlockerBeforeSuspendResponder {
4326    type ControlHandle = SuspendBlockerControlHandle;
4327
4328    fn control_handle(&self) -> &SuspendBlockerControlHandle {
4329        &self.control_handle
4330    }
4331
4332    fn drop_without_shutdown(mut self) {
4333        // Safety: drops once, never accessed again due to mem::forget
4334        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4335        // Prevent Drop from running (which would shut down the channel)
4336        std::mem::forget(self);
4337    }
4338}
4339
4340impl SuspendBlockerBeforeSuspendResponder {
4341    /// Sends a response to the FIDL transaction.
4342    ///
4343    /// Sets the channel to shutdown if an error occurs.
4344    pub fn send(self) -> Result<(), fidl::Error> {
4345        let _result = self.send_raw();
4346        if _result.is_err() {
4347            self.control_handle.shutdown();
4348        }
4349        self.drop_without_shutdown();
4350        _result
4351    }
4352
4353    /// Similar to "send" but does not shutdown the channel if an error occurs.
4354    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4355        let _result = self.send_raw();
4356        self.drop_without_shutdown();
4357        _result
4358    }
4359
4360    fn send_raw(&self) -> Result<(), fidl::Error> {
4361        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4362            fidl::encoding::Flexible::new(()),
4363            self.tx_id,
4364            0x6b569393a01a6d80,
4365            fidl::encoding::DynamicFlags::FLEXIBLE,
4366        )
4367    }
4368}
4369
4370#[must_use = "FIDL methods require a response to be sent"]
4371#[derive(Debug)]
4372pub struct SuspendBlockerAfterResumeResponder {
4373    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
4374    tx_id: u32,
4375}
4376
4377/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
4378/// if the responder is dropped without sending a response, so that the client
4379/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4380impl std::ops::Drop for SuspendBlockerAfterResumeResponder {
4381    fn drop(&mut self) {
4382        self.control_handle.shutdown();
4383        // Safety: drops once, never accessed again
4384        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4385    }
4386}
4387
4388impl fidl::endpoints::Responder for SuspendBlockerAfterResumeResponder {
4389    type ControlHandle = SuspendBlockerControlHandle;
4390
4391    fn control_handle(&self) -> &SuspendBlockerControlHandle {
4392        &self.control_handle
4393    }
4394
4395    fn drop_without_shutdown(mut self) {
4396        // Safety: drops once, never accessed again due to mem::forget
4397        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4398        // Prevent Drop from running (which would shut down the channel)
4399        std::mem::forget(self);
4400    }
4401}
4402
4403impl SuspendBlockerAfterResumeResponder {
4404    /// Sends a response to the FIDL transaction.
4405    ///
4406    /// Sets the channel to shutdown if an error occurs.
4407    pub fn send(self) -> Result<(), fidl::Error> {
4408        let _result = self.send_raw();
4409        if _result.is_err() {
4410            self.control_handle.shutdown();
4411        }
4412        self.drop_without_shutdown();
4413        _result
4414    }
4415
4416    /// Similar to "send" but does not shutdown the channel if an error occurs.
4417    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4418        let _result = self.send_raw();
4419        self.drop_without_shutdown();
4420        _result
4421    }
4422
4423    fn send_raw(&self) -> Result<(), fidl::Error> {
4424        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4425            fidl::encoding::Flexible::new(()),
4426            self.tx_id,
4427            0x6a329cfcc73f2dea,
4428            fidl::encoding::DynamicFlags::FLEXIBLE,
4429        )
4430    }
4431}
4432
4433mod internal {
4434    use super::*;
4435
4436    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseWithTokenRequest {
4437        type Borrowed<'a> = &'a mut Self;
4438        fn take_or_borrow<'a>(
4439            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4440        ) -> Self::Borrowed<'a> {
4441            value
4442        }
4443    }
4444
4445    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseWithTokenRequest {
4446        type Owned = Self;
4447
4448        #[inline(always)]
4449        fn inline_align(_context: fidl::encoding::Context) -> usize {
4450            8
4451        }
4452
4453        #[inline(always)]
4454        fn inline_size(_context: fidl::encoding::Context) -> usize {
4455            24
4456        }
4457    }
4458
4459    unsafe impl
4460        fidl::encoding::Encode<
4461            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
4462            fidl::encoding::DefaultFuchsiaResourceDialect,
4463        > for &mut ActivityGovernorAcquireWakeLeaseWithTokenRequest
4464    {
4465        #[inline]
4466        unsafe fn encode(
4467            self,
4468            encoder: &mut fidl::encoding::Encoder<
4469                '_,
4470                fidl::encoding::DefaultFuchsiaResourceDialect,
4471            >,
4472            offset: usize,
4473            _depth: fidl::encoding::Depth,
4474        ) -> fidl::Result<()> {
4475            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseWithTokenRequest>(offset);
4476            // Delegate to tuple encoding.
4477            fidl::encoding::Encode::<
4478                ActivityGovernorAcquireWakeLeaseWithTokenRequest,
4479                fidl::encoding::DefaultFuchsiaResourceDialect,
4480            >::encode(
4481                (
4482                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
4483                        &self.name,
4484                    ),
4485                    <fidl::encoding::HandleType<
4486                        fidl::EventPair,
4487                        { fidl::ObjectType::EVENTPAIR.into_raw() },
4488                        16387,
4489                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4490                        &mut self.server_token,
4491                    ),
4492                ),
4493                encoder,
4494                offset,
4495                _depth,
4496            )
4497        }
4498    }
4499    unsafe impl<
4500        T0: fidl::encoding::Encode<
4501                fidl::encoding::BoundedString<64>,
4502                fidl::encoding::DefaultFuchsiaResourceDialect,
4503            >,
4504        T1: fidl::encoding::Encode<
4505                fidl::encoding::HandleType<
4506                    fidl::EventPair,
4507                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4508                    16387,
4509                >,
4510                fidl::encoding::DefaultFuchsiaResourceDialect,
4511            >,
4512    >
4513        fidl::encoding::Encode<
4514            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
4515            fidl::encoding::DefaultFuchsiaResourceDialect,
4516        > for (T0, T1)
4517    {
4518        #[inline]
4519        unsafe fn encode(
4520            self,
4521            encoder: &mut fidl::encoding::Encoder<
4522                '_,
4523                fidl::encoding::DefaultFuchsiaResourceDialect,
4524            >,
4525            offset: usize,
4526            depth: fidl::encoding::Depth,
4527        ) -> fidl::Result<()> {
4528            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseWithTokenRequest>(offset);
4529            // Zero out padding regions. There's no need to apply masks
4530            // because the unmasked parts will be overwritten by fields.
4531            unsafe {
4532                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4533                (ptr as *mut u64).write_unaligned(0);
4534            }
4535            // Write the fields.
4536            self.0.encode(encoder, offset + 0, depth)?;
4537            self.1.encode(encoder, offset + 16, depth)?;
4538            Ok(())
4539        }
4540    }
4541
4542    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4543        for ActivityGovernorAcquireWakeLeaseWithTokenRequest
4544    {
4545        #[inline(always)]
4546        fn new_empty() -> Self {
4547            Self {
4548                name: fidl::new_empty!(
4549                    fidl::encoding::BoundedString<64>,
4550                    fidl::encoding::DefaultFuchsiaResourceDialect
4551                ),
4552                server_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4553            }
4554        }
4555
4556        #[inline]
4557        unsafe fn decode(
4558            &mut self,
4559            decoder: &mut fidl::encoding::Decoder<
4560                '_,
4561                fidl::encoding::DefaultFuchsiaResourceDialect,
4562            >,
4563            offset: usize,
4564            _depth: fidl::encoding::Depth,
4565        ) -> fidl::Result<()> {
4566            decoder.debug_check_bounds::<Self>(offset);
4567            // Verify that padding bytes are zero.
4568            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
4569            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4570            let mask = 0xffffffff00000000u64;
4571            let maskedval = padval & mask;
4572            if maskedval != 0 {
4573                return Err(fidl::Error::NonZeroPadding {
4574                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
4575                });
4576            }
4577            fidl::decode!(
4578                fidl::encoding::BoundedString<64>,
4579                fidl::encoding::DefaultFuchsiaResourceDialect,
4580                &mut self.name,
4581                decoder,
4582                offset + 0,
4583                _depth
4584            )?;
4585            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_token, decoder, offset + 16, _depth)?;
4586            Ok(())
4587        }
4588    }
4589
4590    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireUnmonitoredWakeLeaseResponse {
4591        type Borrowed<'a> = &'a mut Self;
4592        fn take_or_borrow<'a>(
4593            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4594        ) -> Self::Borrowed<'a> {
4595            value
4596        }
4597    }
4598
4599    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireUnmonitoredWakeLeaseResponse {
4600        type Owned = Self;
4601
4602        #[inline(always)]
4603        fn inline_align(_context: fidl::encoding::Context) -> usize {
4604            4
4605        }
4606
4607        #[inline(always)]
4608        fn inline_size(_context: fidl::encoding::Context) -> usize {
4609            4
4610        }
4611    }
4612
4613    unsafe impl
4614        fidl::encoding::Encode<
4615            ActivityGovernorAcquireUnmonitoredWakeLeaseResponse,
4616            fidl::encoding::DefaultFuchsiaResourceDialect,
4617        > for &mut ActivityGovernorAcquireUnmonitoredWakeLeaseResponse
4618    {
4619        #[inline]
4620        unsafe fn encode(
4621            self,
4622            encoder: &mut fidl::encoding::Encoder<
4623                '_,
4624                fidl::encoding::DefaultFuchsiaResourceDialect,
4625            >,
4626            offset: usize,
4627            _depth: fidl::encoding::Depth,
4628        ) -> fidl::Result<()> {
4629            encoder
4630                .debug_check_bounds::<ActivityGovernorAcquireUnmonitoredWakeLeaseResponse>(offset);
4631            // Delegate to tuple encoding.
4632            fidl::encoding::Encode::<
4633                ActivityGovernorAcquireUnmonitoredWakeLeaseResponse,
4634                fidl::encoding::DefaultFuchsiaResourceDialect,
4635            >::encode(
4636                (<fidl::encoding::HandleType<
4637                    fidl::EventPair,
4638                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4639                    16387,
4640                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4641                    &mut self.token
4642                ),),
4643                encoder,
4644                offset,
4645                _depth,
4646            )
4647        }
4648    }
4649    unsafe impl<
4650        T0: fidl::encoding::Encode<
4651                fidl::encoding::HandleType<
4652                    fidl::EventPair,
4653                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4654                    16387,
4655                >,
4656                fidl::encoding::DefaultFuchsiaResourceDialect,
4657            >,
4658    >
4659        fidl::encoding::Encode<
4660            ActivityGovernorAcquireUnmonitoredWakeLeaseResponse,
4661            fidl::encoding::DefaultFuchsiaResourceDialect,
4662        > for (T0,)
4663    {
4664        #[inline]
4665        unsafe fn encode(
4666            self,
4667            encoder: &mut fidl::encoding::Encoder<
4668                '_,
4669                fidl::encoding::DefaultFuchsiaResourceDialect,
4670            >,
4671            offset: usize,
4672            depth: fidl::encoding::Depth,
4673        ) -> fidl::Result<()> {
4674            encoder
4675                .debug_check_bounds::<ActivityGovernorAcquireUnmonitoredWakeLeaseResponse>(offset);
4676            // Zero out padding regions. There's no need to apply masks
4677            // because the unmasked parts will be overwritten by fields.
4678            // Write the fields.
4679            self.0.encode(encoder, offset + 0, depth)?;
4680            Ok(())
4681        }
4682    }
4683
4684    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4685        for ActivityGovernorAcquireUnmonitoredWakeLeaseResponse
4686    {
4687        #[inline(always)]
4688        fn new_empty() -> Self {
4689            Self {
4690                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4691            }
4692        }
4693
4694        #[inline]
4695        unsafe fn decode(
4696            &mut self,
4697            decoder: &mut fidl::encoding::Decoder<
4698                '_,
4699                fidl::encoding::DefaultFuchsiaResourceDialect,
4700            >,
4701            offset: usize,
4702            _depth: fidl::encoding::Depth,
4703        ) -> fidl::Result<()> {
4704            decoder.debug_check_bounds::<Self>(offset);
4705            // Verify that padding bytes are zero.
4706            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4707            Ok(())
4708        }
4709    }
4710
4711    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
4712        type Borrowed<'a> = &'a mut Self;
4713        fn take_or_borrow<'a>(
4714            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4715        ) -> Self::Borrowed<'a> {
4716            value
4717        }
4718    }
4719
4720    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
4721        type Owned = Self;
4722
4723        #[inline(always)]
4724        fn inline_align(_context: fidl::encoding::Context) -> usize {
4725            4
4726        }
4727
4728        #[inline(always)]
4729        fn inline_size(_context: fidl::encoding::Context) -> usize {
4730            4
4731        }
4732    }
4733
4734    unsafe impl
4735        fidl::encoding::Encode<
4736            ActivityGovernorAcquireWakeLeaseResponse,
4737            fidl::encoding::DefaultFuchsiaResourceDialect,
4738        > for &mut ActivityGovernorAcquireWakeLeaseResponse
4739    {
4740        #[inline]
4741        unsafe fn encode(
4742            self,
4743            encoder: &mut fidl::encoding::Encoder<
4744                '_,
4745                fidl::encoding::DefaultFuchsiaResourceDialect,
4746            >,
4747            offset: usize,
4748            _depth: fidl::encoding::Depth,
4749        ) -> fidl::Result<()> {
4750            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
4751            // Delegate to tuple encoding.
4752            fidl::encoding::Encode::<
4753                ActivityGovernorAcquireWakeLeaseResponse,
4754                fidl::encoding::DefaultFuchsiaResourceDialect,
4755            >::encode(
4756                (<fidl::encoding::HandleType<
4757                    fidl::EventPair,
4758                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4759                    16387,
4760                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4761                    &mut self.token
4762                ),),
4763                encoder,
4764                offset,
4765                _depth,
4766            )
4767        }
4768    }
4769    unsafe impl<
4770        T0: fidl::encoding::Encode<
4771                fidl::encoding::HandleType<
4772                    fidl::EventPair,
4773                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4774                    16387,
4775                >,
4776                fidl::encoding::DefaultFuchsiaResourceDialect,
4777            >,
4778    >
4779        fidl::encoding::Encode<
4780            ActivityGovernorAcquireWakeLeaseResponse,
4781            fidl::encoding::DefaultFuchsiaResourceDialect,
4782        > for (T0,)
4783    {
4784        #[inline]
4785        unsafe fn encode(
4786            self,
4787            encoder: &mut fidl::encoding::Encoder<
4788                '_,
4789                fidl::encoding::DefaultFuchsiaResourceDialect,
4790            >,
4791            offset: usize,
4792            depth: fidl::encoding::Depth,
4793        ) -> fidl::Result<()> {
4794            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
4795            // Zero out padding regions. There's no need to apply masks
4796            // because the unmasked parts will be overwritten by fields.
4797            // Write the fields.
4798            self.0.encode(encoder, offset + 0, depth)?;
4799            Ok(())
4800        }
4801    }
4802
4803    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4804        for ActivityGovernorAcquireWakeLeaseResponse
4805    {
4806        #[inline(always)]
4807        fn new_empty() -> Self {
4808            Self {
4809                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4810            }
4811        }
4812
4813        #[inline]
4814        unsafe fn decode(
4815            &mut self,
4816            decoder: &mut fidl::encoding::Decoder<
4817                '_,
4818                fidl::encoding::DefaultFuchsiaResourceDialect,
4819            >,
4820            offset: usize,
4821            _depth: fidl::encoding::Depth,
4822        ) -> fidl::Result<()> {
4823            decoder.debug_check_bounds::<Self>(offset);
4824            // Verify that padding bytes are zero.
4825            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4826            Ok(())
4827        }
4828    }
4829
4830    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
4831        type Borrowed<'a> = &'a mut Self;
4832        fn take_or_borrow<'a>(
4833            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4834        ) -> Self::Borrowed<'a> {
4835            value
4836        }
4837    }
4838
4839    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
4840        type Owned = Self;
4841
4842        #[inline(always)]
4843        fn inline_align(_context: fidl::encoding::Context) -> usize {
4844            4
4845        }
4846
4847        #[inline(always)]
4848        fn inline_size(_context: fidl::encoding::Context) -> usize {
4849            4
4850        }
4851    }
4852
4853    unsafe impl
4854        fidl::encoding::Encode<
4855            ActivityGovernorRegisterSuspendBlockerResponse,
4856            fidl::encoding::DefaultFuchsiaResourceDialect,
4857        > for &mut ActivityGovernorRegisterSuspendBlockerResponse
4858    {
4859        #[inline]
4860        unsafe fn encode(
4861            self,
4862            encoder: &mut fidl::encoding::Encoder<
4863                '_,
4864                fidl::encoding::DefaultFuchsiaResourceDialect,
4865            >,
4866            offset: usize,
4867            _depth: fidl::encoding::Depth,
4868        ) -> fidl::Result<()> {
4869            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
4870            // Delegate to tuple encoding.
4871            fidl::encoding::Encode::<
4872                ActivityGovernorRegisterSuspendBlockerResponse,
4873                fidl::encoding::DefaultFuchsiaResourceDialect,
4874            >::encode(
4875                (<fidl::encoding::HandleType<
4876                    fidl::EventPair,
4877                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4878                    16387,
4879                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4880                    &mut self.token
4881                ),),
4882                encoder,
4883                offset,
4884                _depth,
4885            )
4886        }
4887    }
4888    unsafe impl<
4889        T0: fidl::encoding::Encode<
4890                fidl::encoding::HandleType<
4891                    fidl::EventPair,
4892                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4893                    16387,
4894                >,
4895                fidl::encoding::DefaultFuchsiaResourceDialect,
4896            >,
4897    >
4898        fidl::encoding::Encode<
4899            ActivityGovernorRegisterSuspendBlockerResponse,
4900            fidl::encoding::DefaultFuchsiaResourceDialect,
4901        > for (T0,)
4902    {
4903        #[inline]
4904        unsafe fn encode(
4905            self,
4906            encoder: &mut fidl::encoding::Encoder<
4907                '_,
4908                fidl::encoding::DefaultFuchsiaResourceDialect,
4909            >,
4910            offset: usize,
4911            depth: fidl::encoding::Depth,
4912        ) -> fidl::Result<()> {
4913            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
4914            // Zero out padding regions. There's no need to apply masks
4915            // because the unmasked parts will be overwritten by fields.
4916            // Write the fields.
4917            self.0.encode(encoder, offset + 0, depth)?;
4918            Ok(())
4919        }
4920    }
4921
4922    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4923        for ActivityGovernorRegisterSuspendBlockerResponse
4924    {
4925        #[inline(always)]
4926        fn new_empty() -> Self {
4927            Self {
4928                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4929            }
4930        }
4931
4932        #[inline]
4933        unsafe fn decode(
4934            &mut self,
4935            decoder: &mut fidl::encoding::Decoder<
4936                '_,
4937                fidl::encoding::DefaultFuchsiaResourceDialect,
4938            >,
4939            offset: usize,
4940            _depth: fidl::encoding::Depth,
4941        ) -> fidl::Result<()> {
4942            decoder.debug_check_bounds::<Self>(offset);
4943            // Verify that padding bytes are zero.
4944            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4945            Ok(())
4946        }
4947    }
4948
4949    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4950        type Borrowed<'a> = &'a mut Self;
4951        fn take_or_borrow<'a>(
4952            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4953        ) -> Self::Borrowed<'a> {
4954            value
4955        }
4956    }
4957
4958    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4959        type Owned = Self;
4960
4961        #[inline(always)]
4962        fn inline_align(_context: fidl::encoding::Context) -> usize {
4963            4
4964        }
4965
4966        #[inline(always)]
4967        fn inline_size(_context: fidl::encoding::Context) -> usize {
4968            4
4969        }
4970    }
4971
4972    unsafe impl
4973        fidl::encoding::Encode<
4974            ActivityGovernorTakeApplicationActivityLeaseResponse,
4975            fidl::encoding::DefaultFuchsiaResourceDialect,
4976        > for &mut ActivityGovernorTakeApplicationActivityLeaseResponse
4977    {
4978        #[inline]
4979        unsafe fn encode(
4980            self,
4981            encoder: &mut fidl::encoding::Encoder<
4982                '_,
4983                fidl::encoding::DefaultFuchsiaResourceDialect,
4984            >,
4985            offset: usize,
4986            _depth: fidl::encoding::Depth,
4987        ) -> fidl::Result<()> {
4988            encoder
4989                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
4990            // Delegate to tuple encoding.
4991            fidl::encoding::Encode::<
4992                ActivityGovernorTakeApplicationActivityLeaseResponse,
4993                fidl::encoding::DefaultFuchsiaResourceDialect,
4994            >::encode(
4995                (<fidl::encoding::HandleType<
4996                    fidl::EventPair,
4997                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4998                    16387,
4999                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5000                    &mut self.token
5001                ),),
5002                encoder,
5003                offset,
5004                _depth,
5005            )
5006        }
5007    }
5008    unsafe impl<
5009        T0: fidl::encoding::Encode<
5010                fidl::encoding::HandleType<
5011                    fidl::EventPair,
5012                    { fidl::ObjectType::EVENTPAIR.into_raw() },
5013                    16387,
5014                >,
5015                fidl::encoding::DefaultFuchsiaResourceDialect,
5016            >,
5017    >
5018        fidl::encoding::Encode<
5019            ActivityGovernorTakeApplicationActivityLeaseResponse,
5020            fidl::encoding::DefaultFuchsiaResourceDialect,
5021        > for (T0,)
5022    {
5023        #[inline]
5024        unsafe fn encode(
5025            self,
5026            encoder: &mut fidl::encoding::Encoder<
5027                '_,
5028                fidl::encoding::DefaultFuchsiaResourceDialect,
5029            >,
5030            offset: usize,
5031            depth: fidl::encoding::Depth,
5032        ) -> fidl::Result<()> {
5033            encoder
5034                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
5035            // Zero out padding regions. There's no need to apply masks
5036            // because the unmasked parts will be overwritten by fields.
5037            // Write the fields.
5038            self.0.encode(encoder, offset + 0, depth)?;
5039            Ok(())
5040        }
5041    }
5042
5043    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5044        for ActivityGovernorTakeApplicationActivityLeaseResponse
5045    {
5046        #[inline(always)]
5047        fn new_empty() -> Self {
5048            Self {
5049                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
5050            }
5051        }
5052
5053        #[inline]
5054        unsafe fn decode(
5055            &mut self,
5056            decoder: &mut fidl::encoding::Decoder<
5057                '_,
5058                fidl::encoding::DefaultFuchsiaResourceDialect,
5059            >,
5060            offset: usize,
5061            _depth: fidl::encoding::Depth,
5062        ) -> fidl::Result<()> {
5063            decoder.debug_check_bounds::<Self>(offset);
5064            // Verify that padding bytes are zero.
5065            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
5066            Ok(())
5067        }
5068    }
5069
5070    impl ActivityGovernorRegisterSuspendBlockerRequest {
5071        #[inline(always)]
5072        fn max_ordinal_present(&self) -> u64 {
5073            if let Some(_) = self.name {
5074                return 2;
5075            }
5076            if let Some(_) = self.suspend_blocker {
5077                return 1;
5078            }
5079            0
5080        }
5081    }
5082
5083    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
5084        type Borrowed<'a> = &'a mut Self;
5085        fn take_or_borrow<'a>(
5086            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5087        ) -> Self::Borrowed<'a> {
5088            value
5089        }
5090    }
5091
5092    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
5093        type Owned = Self;
5094
5095        #[inline(always)]
5096        fn inline_align(_context: fidl::encoding::Context) -> usize {
5097            8
5098        }
5099
5100        #[inline(always)]
5101        fn inline_size(_context: fidl::encoding::Context) -> usize {
5102            16
5103        }
5104    }
5105
5106    unsafe impl
5107        fidl::encoding::Encode<
5108            ActivityGovernorRegisterSuspendBlockerRequest,
5109            fidl::encoding::DefaultFuchsiaResourceDialect,
5110        > for &mut ActivityGovernorRegisterSuspendBlockerRequest
5111    {
5112        unsafe fn encode(
5113            self,
5114            encoder: &mut fidl::encoding::Encoder<
5115                '_,
5116                fidl::encoding::DefaultFuchsiaResourceDialect,
5117            >,
5118            offset: usize,
5119            mut depth: fidl::encoding::Depth,
5120        ) -> fidl::Result<()> {
5121            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerRequest>(offset);
5122            // Vector header
5123            let max_ordinal: u64 = self.max_ordinal_present();
5124            encoder.write_num(max_ordinal, offset);
5125            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5126            // Calling encoder.out_of_line_offset(0) is not allowed.
5127            if max_ordinal == 0 {
5128                return Ok(());
5129            }
5130            depth.increment()?;
5131            let envelope_size = 8;
5132            let bytes_len = max_ordinal as usize * envelope_size;
5133            #[allow(unused_variables)]
5134            let offset = encoder.out_of_line_offset(bytes_len);
5135            let mut _prev_end_offset: usize = 0;
5136            if 1 > max_ordinal {
5137                return Ok(());
5138            }
5139
5140            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5141            // are envelope_size bytes.
5142            let cur_offset: usize = (1 - 1) * envelope_size;
5143
5144            // Zero reserved fields.
5145            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5146
5147            // Safety:
5148            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5149            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5150            //   envelope_size bytes, there is always sufficient room.
5151            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5152            self.suspend_blocker.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5153            encoder, offset + cur_offset, depth
5154        )?;
5155
5156            _prev_end_offset = cur_offset + envelope_size;
5157            if 2 > max_ordinal {
5158                return Ok(());
5159            }
5160
5161            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5162            // are envelope_size bytes.
5163            let cur_offset: usize = (2 - 1) * envelope_size;
5164
5165            // Zero reserved fields.
5166            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5167
5168            // Safety:
5169            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5170            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5171            //   envelope_size bytes, there is always sufficient room.
5172            fidl::encoding::encode_in_envelope_optional::<
5173                fidl::encoding::BoundedString<64>,
5174                fidl::encoding::DefaultFuchsiaResourceDialect,
5175            >(
5176                self.name.as_ref().map(
5177                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
5178                ),
5179                encoder,
5180                offset + cur_offset,
5181                depth,
5182            )?;
5183
5184            _prev_end_offset = cur_offset + envelope_size;
5185
5186            Ok(())
5187        }
5188    }
5189
5190    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5191        for ActivityGovernorRegisterSuspendBlockerRequest
5192    {
5193        #[inline(always)]
5194        fn new_empty() -> Self {
5195            Self::default()
5196        }
5197
5198        unsafe fn decode(
5199            &mut self,
5200            decoder: &mut fidl::encoding::Decoder<
5201                '_,
5202                fidl::encoding::DefaultFuchsiaResourceDialect,
5203            >,
5204            offset: usize,
5205            mut depth: fidl::encoding::Depth,
5206        ) -> fidl::Result<()> {
5207            decoder.debug_check_bounds::<Self>(offset);
5208            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5209                None => return Err(fidl::Error::NotNullable),
5210                Some(len) => len,
5211            };
5212            // Calling decoder.out_of_line_offset(0) is not allowed.
5213            if len == 0 {
5214                return Ok(());
5215            };
5216            depth.increment()?;
5217            let envelope_size = 8;
5218            let bytes_len = len * envelope_size;
5219            let offset = decoder.out_of_line_offset(bytes_len)?;
5220            // Decode the envelope for each type.
5221            let mut _next_ordinal_to_read = 0;
5222            let mut next_offset = offset;
5223            let end_offset = offset + bytes_len;
5224            _next_ordinal_to_read += 1;
5225            if next_offset >= end_offset {
5226                return Ok(());
5227            }
5228
5229            // Decode unknown envelopes for gaps in ordinals.
5230            while _next_ordinal_to_read < 1 {
5231                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5232                _next_ordinal_to_read += 1;
5233                next_offset += envelope_size;
5234            }
5235
5236            let next_out_of_line = decoder.next_out_of_line();
5237            let handles_before = decoder.remaining_handles();
5238            if let Some((inlined, num_bytes, num_handles)) =
5239                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5240            {
5241                let member_inline_size = <fidl::encoding::Endpoint<
5242                    fidl::endpoints::ClientEnd<SuspendBlockerMarker>,
5243                > as fidl::encoding::TypeMarker>::inline_size(
5244                    decoder.context
5245                );
5246                if inlined != (member_inline_size <= 4) {
5247                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5248                }
5249                let inner_offset;
5250                let mut inner_depth = depth.clone();
5251                if inlined {
5252                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5253                    inner_offset = next_offset;
5254                } else {
5255                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5256                    inner_depth.increment()?;
5257                }
5258                let val_ref = self.suspend_blocker.get_or_insert_with(|| {
5259                    fidl::new_empty!(
5260                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
5261                        fidl::encoding::DefaultFuchsiaResourceDialect
5262                    )
5263                });
5264                fidl::decode!(
5265                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
5266                    fidl::encoding::DefaultFuchsiaResourceDialect,
5267                    val_ref,
5268                    decoder,
5269                    inner_offset,
5270                    inner_depth
5271                )?;
5272                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5273                {
5274                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5275                }
5276                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5277                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5278                }
5279            }
5280
5281            next_offset += envelope_size;
5282            _next_ordinal_to_read += 1;
5283            if next_offset >= end_offset {
5284                return Ok(());
5285            }
5286
5287            // Decode unknown envelopes for gaps in ordinals.
5288            while _next_ordinal_to_read < 2 {
5289                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5290                _next_ordinal_to_read += 1;
5291                next_offset += envelope_size;
5292            }
5293
5294            let next_out_of_line = decoder.next_out_of_line();
5295            let handles_before = decoder.remaining_handles();
5296            if let Some((inlined, num_bytes, num_handles)) =
5297                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5298            {
5299                let member_inline_size =
5300                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
5301                        decoder.context,
5302                    );
5303                if inlined != (member_inline_size <= 4) {
5304                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5305                }
5306                let inner_offset;
5307                let mut inner_depth = depth.clone();
5308                if inlined {
5309                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5310                    inner_offset = next_offset;
5311                } else {
5312                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5313                    inner_depth.increment()?;
5314                }
5315                let val_ref = self.name.get_or_insert_with(|| {
5316                    fidl::new_empty!(
5317                        fidl::encoding::BoundedString<64>,
5318                        fidl::encoding::DefaultFuchsiaResourceDialect
5319                    )
5320                });
5321                fidl::decode!(
5322                    fidl::encoding::BoundedString<64>,
5323                    fidl::encoding::DefaultFuchsiaResourceDialect,
5324                    val_ref,
5325                    decoder,
5326                    inner_offset,
5327                    inner_depth
5328                )?;
5329                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5330                {
5331                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5332                }
5333                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5334                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5335                }
5336            }
5337
5338            next_offset += envelope_size;
5339
5340            // Decode the remaining unknown envelopes.
5341            while next_offset < end_offset {
5342                _next_ordinal_to_read += 1;
5343                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5344                next_offset += envelope_size;
5345            }
5346
5347            Ok(())
5348        }
5349    }
5350
5351    impl ApplicationActivity {
5352        #[inline(always)]
5353        fn max_ordinal_present(&self) -> u64 {
5354            if let Some(_) = self.assertive_dependency_token {
5355                return 1;
5356            }
5357            0
5358        }
5359    }
5360
5361    impl fidl::encoding::ResourceTypeMarker for ApplicationActivity {
5362        type Borrowed<'a> = &'a mut Self;
5363        fn take_or_borrow<'a>(
5364            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5365        ) -> Self::Borrowed<'a> {
5366            value
5367        }
5368    }
5369
5370    unsafe impl fidl::encoding::TypeMarker for ApplicationActivity {
5371        type Owned = Self;
5372
5373        #[inline(always)]
5374        fn inline_align(_context: fidl::encoding::Context) -> usize {
5375            8
5376        }
5377
5378        #[inline(always)]
5379        fn inline_size(_context: fidl::encoding::Context) -> usize {
5380            16
5381        }
5382    }
5383
5384    unsafe impl
5385        fidl::encoding::Encode<ApplicationActivity, fidl::encoding::DefaultFuchsiaResourceDialect>
5386        for &mut ApplicationActivity
5387    {
5388        unsafe fn encode(
5389            self,
5390            encoder: &mut fidl::encoding::Encoder<
5391                '_,
5392                fidl::encoding::DefaultFuchsiaResourceDialect,
5393            >,
5394            offset: usize,
5395            mut depth: fidl::encoding::Depth,
5396        ) -> fidl::Result<()> {
5397            encoder.debug_check_bounds::<ApplicationActivity>(offset);
5398            // Vector header
5399            let max_ordinal: u64 = self.max_ordinal_present();
5400            encoder.write_num(max_ordinal, offset);
5401            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5402            // Calling encoder.out_of_line_offset(0) is not allowed.
5403            if max_ordinal == 0 {
5404                return Ok(());
5405            }
5406            depth.increment()?;
5407            let envelope_size = 8;
5408            let bytes_len = max_ordinal as usize * envelope_size;
5409            #[allow(unused_variables)]
5410            let offset = encoder.out_of_line_offset(bytes_len);
5411            let mut _prev_end_offset: usize = 0;
5412            if 1 > max_ordinal {
5413                return Ok(());
5414            }
5415
5416            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5417            // are envelope_size bytes.
5418            let cur_offset: usize = (1 - 1) * envelope_size;
5419
5420            // Zero reserved fields.
5421            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5422
5423            // Safety:
5424            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5425            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5426            //   envelope_size bytes, there is always sufficient room.
5427            fidl::encoding::encode_in_envelope_optional::<
5428                fidl::encoding::HandleType<
5429                    fidl::Event,
5430                    { fidl::ObjectType::EVENT.into_raw() },
5431                    2147483648,
5432                >,
5433                fidl::encoding::DefaultFuchsiaResourceDialect,
5434            >(
5435                self.assertive_dependency_token.as_mut().map(
5436                    <fidl::encoding::HandleType<
5437                        fidl::Event,
5438                        { fidl::ObjectType::EVENT.into_raw() },
5439                        2147483648,
5440                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5441                ),
5442                encoder,
5443                offset + cur_offset,
5444                depth,
5445            )?;
5446
5447            _prev_end_offset = cur_offset + envelope_size;
5448
5449            Ok(())
5450        }
5451    }
5452
5453    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5454        for ApplicationActivity
5455    {
5456        #[inline(always)]
5457        fn new_empty() -> Self {
5458            Self::default()
5459        }
5460
5461        unsafe fn decode(
5462            &mut self,
5463            decoder: &mut fidl::encoding::Decoder<
5464                '_,
5465                fidl::encoding::DefaultFuchsiaResourceDialect,
5466            >,
5467            offset: usize,
5468            mut depth: fidl::encoding::Depth,
5469        ) -> fidl::Result<()> {
5470            decoder.debug_check_bounds::<Self>(offset);
5471            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5472                None => return Err(fidl::Error::NotNullable),
5473                Some(len) => len,
5474            };
5475            // Calling decoder.out_of_line_offset(0) is not allowed.
5476            if len == 0 {
5477                return Ok(());
5478            };
5479            depth.increment()?;
5480            let envelope_size = 8;
5481            let bytes_len = len * envelope_size;
5482            let offset = decoder.out_of_line_offset(bytes_len)?;
5483            // Decode the envelope for each type.
5484            let mut _next_ordinal_to_read = 0;
5485            let mut next_offset = offset;
5486            let end_offset = offset + bytes_len;
5487            _next_ordinal_to_read += 1;
5488            if next_offset >= end_offset {
5489                return Ok(());
5490            }
5491
5492            // Decode unknown envelopes for gaps in ordinals.
5493            while _next_ordinal_to_read < 1 {
5494                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5495                _next_ordinal_to_read += 1;
5496                next_offset += envelope_size;
5497            }
5498
5499            let next_out_of_line = decoder.next_out_of_line();
5500            let handles_before = decoder.remaining_handles();
5501            if let Some((inlined, num_bytes, num_handles)) =
5502                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5503            {
5504                let member_inline_size = <fidl::encoding::HandleType<
5505                    fidl::Event,
5506                    { fidl::ObjectType::EVENT.into_raw() },
5507                    2147483648,
5508                > as fidl::encoding::TypeMarker>::inline_size(
5509                    decoder.context
5510                );
5511                if inlined != (member_inline_size <= 4) {
5512                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5513                }
5514                let inner_offset;
5515                let mut inner_depth = depth.clone();
5516                if inlined {
5517                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5518                    inner_offset = next_offset;
5519                } else {
5520                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5521                    inner_depth.increment()?;
5522                }
5523                let val_ref =
5524                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));
5525                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5526                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5527                {
5528                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5529                }
5530                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5531                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5532                }
5533            }
5534
5535            next_offset += envelope_size;
5536
5537            // Decode the remaining unknown envelopes.
5538            while next_offset < end_offset {
5539                _next_ordinal_to_read += 1;
5540                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5541                next_offset += envelope_size;
5542            }
5543
5544            Ok(())
5545        }
5546    }
5547
5548    impl Cpu {
5549        #[inline(always)]
5550        fn max_ordinal_present(&self) -> u64 {
5551            if let Some(_) = self.assertive_dependency_token {
5552                return 1;
5553            }
5554            0
5555        }
5556    }
5557
5558    impl fidl::encoding::ResourceTypeMarker for Cpu {
5559        type Borrowed<'a> = &'a mut Self;
5560        fn take_or_borrow<'a>(
5561            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5562        ) -> Self::Borrowed<'a> {
5563            value
5564        }
5565    }
5566
5567    unsafe impl fidl::encoding::TypeMarker for Cpu {
5568        type Owned = Self;
5569
5570        #[inline(always)]
5571        fn inline_align(_context: fidl::encoding::Context) -> usize {
5572            8
5573        }
5574
5575        #[inline(always)]
5576        fn inline_size(_context: fidl::encoding::Context) -> usize {
5577            16
5578        }
5579    }
5580
5581    unsafe impl fidl::encoding::Encode<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>
5582        for &mut Cpu
5583    {
5584        unsafe fn encode(
5585            self,
5586            encoder: &mut fidl::encoding::Encoder<
5587                '_,
5588                fidl::encoding::DefaultFuchsiaResourceDialect,
5589            >,
5590            offset: usize,
5591            mut depth: fidl::encoding::Depth,
5592        ) -> fidl::Result<()> {
5593            encoder.debug_check_bounds::<Cpu>(offset);
5594            // Vector header
5595            let max_ordinal: u64 = self.max_ordinal_present();
5596            encoder.write_num(max_ordinal, offset);
5597            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5598            // Calling encoder.out_of_line_offset(0) is not allowed.
5599            if max_ordinal == 0 {
5600                return Ok(());
5601            }
5602            depth.increment()?;
5603            let envelope_size = 8;
5604            let bytes_len = max_ordinal as usize * envelope_size;
5605            #[allow(unused_variables)]
5606            let offset = encoder.out_of_line_offset(bytes_len);
5607            let mut _prev_end_offset: usize = 0;
5608            if 1 > max_ordinal {
5609                return Ok(());
5610            }
5611
5612            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5613            // are envelope_size bytes.
5614            let cur_offset: usize = (1 - 1) * envelope_size;
5615
5616            // Zero reserved fields.
5617            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5618
5619            // Safety:
5620            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5621            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5622            //   envelope_size bytes, there is always sufficient room.
5623            fidl::encoding::encode_in_envelope_optional::<
5624                fidl::encoding::HandleType<
5625                    fidl::Event,
5626                    { fidl::ObjectType::EVENT.into_raw() },
5627                    2147483648,
5628                >,
5629                fidl::encoding::DefaultFuchsiaResourceDialect,
5630            >(
5631                self.assertive_dependency_token.as_mut().map(
5632                    <fidl::encoding::HandleType<
5633                        fidl::Event,
5634                        { fidl::ObjectType::EVENT.into_raw() },
5635                        2147483648,
5636                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5637                ),
5638                encoder,
5639                offset + cur_offset,
5640                depth,
5641            )?;
5642
5643            _prev_end_offset = cur_offset + envelope_size;
5644
5645            Ok(())
5646        }
5647    }
5648
5649    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {
5650        #[inline(always)]
5651        fn new_empty() -> Self {
5652            Self::default()
5653        }
5654
5655        unsafe fn decode(
5656            &mut self,
5657            decoder: &mut fidl::encoding::Decoder<
5658                '_,
5659                fidl::encoding::DefaultFuchsiaResourceDialect,
5660            >,
5661            offset: usize,
5662            mut depth: fidl::encoding::Depth,
5663        ) -> fidl::Result<()> {
5664            decoder.debug_check_bounds::<Self>(offset);
5665            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5666                None => return Err(fidl::Error::NotNullable),
5667                Some(len) => len,
5668            };
5669            // Calling decoder.out_of_line_offset(0) is not allowed.
5670            if len == 0 {
5671                return Ok(());
5672            };
5673            depth.increment()?;
5674            let envelope_size = 8;
5675            let bytes_len = len * envelope_size;
5676            let offset = decoder.out_of_line_offset(bytes_len)?;
5677            // Decode the envelope for each type.
5678            let mut _next_ordinal_to_read = 0;
5679            let mut next_offset = offset;
5680            let end_offset = offset + bytes_len;
5681            _next_ordinal_to_read += 1;
5682            if next_offset >= end_offset {
5683                return Ok(());
5684            }
5685
5686            // Decode unknown envelopes for gaps in ordinals.
5687            while _next_ordinal_to_read < 1 {
5688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5689                _next_ordinal_to_read += 1;
5690                next_offset += envelope_size;
5691            }
5692
5693            let next_out_of_line = decoder.next_out_of_line();
5694            let handles_before = decoder.remaining_handles();
5695            if let Some((inlined, num_bytes, num_handles)) =
5696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5697            {
5698                let member_inline_size = <fidl::encoding::HandleType<
5699                    fidl::Event,
5700                    { fidl::ObjectType::EVENT.into_raw() },
5701                    2147483648,
5702                > as fidl::encoding::TypeMarker>::inline_size(
5703                    decoder.context
5704                );
5705                if inlined != (member_inline_size <= 4) {
5706                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5707                }
5708                let inner_offset;
5709                let mut inner_depth = depth.clone();
5710                if inlined {
5711                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5712                    inner_offset = next_offset;
5713                } else {
5714                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5715                    inner_depth.increment()?;
5716                }
5717                let val_ref =
5718                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));
5719                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5720                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5721                {
5722                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5723                }
5724                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5725                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5726                }
5727            }
5728
5729            next_offset += envelope_size;
5730
5731            // Decode the remaining unknown envelopes.
5732            while next_offset < end_offset {
5733                _next_ordinal_to_read += 1;
5734                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5735                next_offset += envelope_size;
5736            }
5737
5738            Ok(())
5739        }
5740    }
5741
5742    impl CpuElementManagerAddExecutionStateDependencyRequest {
5743        #[inline(always)]
5744        fn max_ordinal_present(&self) -> u64 {
5745            if let Some(_) = self.power_level {
5746                return 2;
5747            }
5748            if let Some(_) = self.dependency_token {
5749                return 1;
5750            }
5751            0
5752        }
5753    }
5754
5755    impl fidl::encoding::ResourceTypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
5756        type Borrowed<'a> = &'a mut Self;
5757        fn take_or_borrow<'a>(
5758            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5759        ) -> Self::Borrowed<'a> {
5760            value
5761        }
5762    }
5763
5764    unsafe impl fidl::encoding::TypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
5765        type Owned = Self;
5766
5767        #[inline(always)]
5768        fn inline_align(_context: fidl::encoding::Context) -> usize {
5769            8
5770        }
5771
5772        #[inline(always)]
5773        fn inline_size(_context: fidl::encoding::Context) -> usize {
5774            16
5775        }
5776    }
5777
5778    unsafe impl
5779        fidl::encoding::Encode<
5780            CpuElementManagerAddExecutionStateDependencyRequest,
5781            fidl::encoding::DefaultFuchsiaResourceDialect,
5782        > for &mut CpuElementManagerAddExecutionStateDependencyRequest
5783    {
5784        unsafe fn encode(
5785            self,
5786            encoder: &mut fidl::encoding::Encoder<
5787                '_,
5788                fidl::encoding::DefaultFuchsiaResourceDialect,
5789            >,
5790            offset: usize,
5791            mut depth: fidl::encoding::Depth,
5792        ) -> fidl::Result<()> {
5793            encoder
5794                .debug_check_bounds::<CpuElementManagerAddExecutionStateDependencyRequest>(offset);
5795            // Vector header
5796            let max_ordinal: u64 = self.max_ordinal_present();
5797            encoder.write_num(max_ordinal, offset);
5798            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5799            // Calling encoder.out_of_line_offset(0) is not allowed.
5800            if max_ordinal == 0 {
5801                return Ok(());
5802            }
5803            depth.increment()?;
5804            let envelope_size = 8;
5805            let bytes_len = max_ordinal as usize * envelope_size;
5806            #[allow(unused_variables)]
5807            let offset = encoder.out_of_line_offset(bytes_len);
5808            let mut _prev_end_offset: usize = 0;
5809            if 1 > max_ordinal {
5810                return Ok(());
5811            }
5812
5813            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5814            // are envelope_size bytes.
5815            let cur_offset: usize = (1 - 1) * envelope_size;
5816
5817            // Zero reserved fields.
5818            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5819
5820            // Safety:
5821            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5822            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5823            //   envelope_size bytes, there is always sufficient room.
5824            fidl::encoding::encode_in_envelope_optional::<
5825                fidl::encoding::HandleType<
5826                    fidl::Event,
5827                    { fidl::ObjectType::EVENT.into_raw() },
5828                    2147483648,
5829                >,
5830                fidl::encoding::DefaultFuchsiaResourceDialect,
5831            >(
5832                self.dependency_token.as_mut().map(
5833                    <fidl::encoding::HandleType<
5834                        fidl::Event,
5835                        { fidl::ObjectType::EVENT.into_raw() },
5836                        2147483648,
5837                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5838                ),
5839                encoder,
5840                offset + cur_offset,
5841                depth,
5842            )?;
5843
5844            _prev_end_offset = cur_offset + envelope_size;
5845            if 2 > max_ordinal {
5846                return Ok(());
5847            }
5848
5849            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5850            // are envelope_size bytes.
5851            let cur_offset: usize = (2 - 1) * envelope_size;
5852
5853            // Zero reserved fields.
5854            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5855
5856            // Safety:
5857            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5858            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5859            //   envelope_size bytes, there is always sufficient room.
5860            fidl::encoding::encode_in_envelope_optional::<
5861                u8,
5862                fidl::encoding::DefaultFuchsiaResourceDialect,
5863            >(
5864                self.power_level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
5865                encoder,
5866                offset + cur_offset,
5867                depth,
5868            )?;
5869
5870            _prev_end_offset = cur_offset + envelope_size;
5871
5872            Ok(())
5873        }
5874    }
5875
5876    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5877        for CpuElementManagerAddExecutionStateDependencyRequest
5878    {
5879        #[inline(always)]
5880        fn new_empty() -> Self {
5881            Self::default()
5882        }
5883
5884        unsafe fn decode(
5885            &mut self,
5886            decoder: &mut fidl::encoding::Decoder<
5887                '_,
5888                fidl::encoding::DefaultFuchsiaResourceDialect,
5889            >,
5890            offset: usize,
5891            mut depth: fidl::encoding::Depth,
5892        ) -> fidl::Result<()> {
5893            decoder.debug_check_bounds::<Self>(offset);
5894            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5895                None => return Err(fidl::Error::NotNullable),
5896                Some(len) => len,
5897            };
5898            // Calling decoder.out_of_line_offset(0) is not allowed.
5899            if len == 0 {
5900                return Ok(());
5901            };
5902            depth.increment()?;
5903            let envelope_size = 8;
5904            let bytes_len = len * envelope_size;
5905            let offset = decoder.out_of_line_offset(bytes_len)?;
5906            // Decode the envelope for each type.
5907            let mut _next_ordinal_to_read = 0;
5908            let mut next_offset = offset;
5909            let end_offset = offset + bytes_len;
5910            _next_ordinal_to_read += 1;
5911            if next_offset >= end_offset {
5912                return Ok(());
5913            }
5914
5915            // Decode unknown envelopes for gaps in ordinals.
5916            while _next_ordinal_to_read < 1 {
5917                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5918                _next_ordinal_to_read += 1;
5919                next_offset += envelope_size;
5920            }
5921
5922            let next_out_of_line = decoder.next_out_of_line();
5923            let handles_before = decoder.remaining_handles();
5924            if let Some((inlined, num_bytes, num_handles)) =
5925                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5926            {
5927                let member_inline_size = <fidl::encoding::HandleType<
5928                    fidl::Event,
5929                    { fidl::ObjectType::EVENT.into_raw() },
5930                    2147483648,
5931                > as fidl::encoding::TypeMarker>::inline_size(
5932                    decoder.context
5933                );
5934                if inlined != (member_inline_size <= 4) {
5935                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5936                }
5937                let inner_offset;
5938                let mut inner_depth = depth.clone();
5939                if inlined {
5940                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5941                    inner_offset = next_offset;
5942                } else {
5943                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5944                    inner_depth.increment()?;
5945                }
5946                let val_ref =
5947                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5948                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5949                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5950                {
5951                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5952                }
5953                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5954                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5955                }
5956            }
5957
5958            next_offset += envelope_size;
5959            _next_ordinal_to_read += 1;
5960            if next_offset >= end_offset {
5961                return Ok(());
5962            }
5963
5964            // Decode unknown envelopes for gaps in ordinals.
5965            while _next_ordinal_to_read < 2 {
5966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5967                _next_ordinal_to_read += 1;
5968                next_offset += envelope_size;
5969            }
5970
5971            let next_out_of_line = decoder.next_out_of_line();
5972            let handles_before = decoder.remaining_handles();
5973            if let Some((inlined, num_bytes, num_handles)) =
5974                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5975            {
5976                let member_inline_size =
5977                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5978                if inlined != (member_inline_size <= 4) {
5979                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5980                }
5981                let inner_offset;
5982                let mut inner_depth = depth.clone();
5983                if inlined {
5984                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5985                    inner_offset = next_offset;
5986                } else {
5987                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5988                    inner_depth.increment()?;
5989                }
5990                let val_ref = self.power_level.get_or_insert_with(|| {
5991                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
5992                });
5993                fidl::decode!(
5994                    u8,
5995                    fidl::encoding::DefaultFuchsiaResourceDialect,
5996                    val_ref,
5997                    decoder,
5998                    inner_offset,
5999                    inner_depth
6000                )?;
6001                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6002                {
6003                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6004                }
6005                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6006                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6007                }
6008            }
6009
6010            next_offset += envelope_size;
6011
6012            // Decode the remaining unknown envelopes.
6013            while next_offset < end_offset {
6014                _next_ordinal_to_read += 1;
6015                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6016                next_offset += envelope_size;
6017            }
6018
6019            Ok(())
6020        }
6021    }
6022
6023    impl ExecutionState {
6024        #[inline(always)]
6025        fn max_ordinal_present(&self) -> u64 {
6026            if let Some(_) = self.dependency_token {
6027                return 1;
6028            }
6029            0
6030        }
6031    }
6032
6033    impl fidl::encoding::ResourceTypeMarker for ExecutionState {
6034        type Borrowed<'a> = &'a mut Self;
6035        fn take_or_borrow<'a>(
6036            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6037        ) -> Self::Borrowed<'a> {
6038            value
6039        }
6040    }
6041
6042    unsafe impl fidl::encoding::TypeMarker for ExecutionState {
6043        type Owned = Self;
6044
6045        #[inline(always)]
6046        fn inline_align(_context: fidl::encoding::Context) -> usize {
6047            8
6048        }
6049
6050        #[inline(always)]
6051        fn inline_size(_context: fidl::encoding::Context) -> usize {
6052            16
6053        }
6054    }
6055
6056    unsafe impl
6057        fidl::encoding::Encode<ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect>
6058        for &mut ExecutionState
6059    {
6060        unsafe fn encode(
6061            self,
6062            encoder: &mut fidl::encoding::Encoder<
6063                '_,
6064                fidl::encoding::DefaultFuchsiaResourceDialect,
6065            >,
6066            offset: usize,
6067            mut depth: fidl::encoding::Depth,
6068        ) -> fidl::Result<()> {
6069            encoder.debug_check_bounds::<ExecutionState>(offset);
6070            // Vector header
6071            let max_ordinal: u64 = self.max_ordinal_present();
6072            encoder.write_num(max_ordinal, offset);
6073            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6074            // Calling encoder.out_of_line_offset(0) is not allowed.
6075            if max_ordinal == 0 {
6076                return Ok(());
6077            }
6078            depth.increment()?;
6079            let envelope_size = 8;
6080            let bytes_len = max_ordinal as usize * envelope_size;
6081            #[allow(unused_variables)]
6082            let offset = encoder.out_of_line_offset(bytes_len);
6083            let mut _prev_end_offset: usize = 0;
6084            if 1 > max_ordinal {
6085                return Ok(());
6086            }
6087
6088            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6089            // are envelope_size bytes.
6090            let cur_offset: usize = (1 - 1) * envelope_size;
6091
6092            // Zero reserved fields.
6093            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6094
6095            // Safety:
6096            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6097            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6098            //   envelope_size bytes, there is always sufficient room.
6099            fidl::encoding::encode_in_envelope_optional::<
6100                fidl::encoding::HandleType<
6101                    fidl::Event,
6102                    { fidl::ObjectType::EVENT.into_raw() },
6103                    2147483648,
6104                >,
6105                fidl::encoding::DefaultFuchsiaResourceDialect,
6106            >(
6107                self.dependency_token.as_mut().map(
6108                    <fidl::encoding::HandleType<
6109                        fidl::Event,
6110                        { fidl::ObjectType::EVENT.into_raw() },
6111                        2147483648,
6112                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6113                ),
6114                encoder,
6115                offset + cur_offset,
6116                depth,
6117            )?;
6118
6119            _prev_end_offset = cur_offset + envelope_size;
6120
6121            Ok(())
6122        }
6123    }
6124
6125    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6126        for ExecutionState
6127    {
6128        #[inline(always)]
6129        fn new_empty() -> Self {
6130            Self::default()
6131        }
6132
6133        unsafe fn decode(
6134            &mut self,
6135            decoder: &mut fidl::encoding::Decoder<
6136                '_,
6137                fidl::encoding::DefaultFuchsiaResourceDialect,
6138            >,
6139            offset: usize,
6140            mut depth: fidl::encoding::Depth,
6141        ) -> fidl::Result<()> {
6142            decoder.debug_check_bounds::<Self>(offset);
6143            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6144                None => return Err(fidl::Error::NotNullable),
6145                Some(len) => len,
6146            };
6147            // Calling decoder.out_of_line_offset(0) is not allowed.
6148            if len == 0 {
6149                return Ok(());
6150            };
6151            depth.increment()?;
6152            let envelope_size = 8;
6153            let bytes_len = len * envelope_size;
6154            let offset = decoder.out_of_line_offset(bytes_len)?;
6155            // Decode the envelope for each type.
6156            let mut _next_ordinal_to_read = 0;
6157            let mut next_offset = offset;
6158            let end_offset = offset + bytes_len;
6159            _next_ordinal_to_read += 1;
6160            if next_offset >= end_offset {
6161                return Ok(());
6162            }
6163
6164            // Decode unknown envelopes for gaps in ordinals.
6165            while _next_ordinal_to_read < 1 {
6166                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6167                _next_ordinal_to_read += 1;
6168                next_offset += envelope_size;
6169            }
6170
6171            let next_out_of_line = decoder.next_out_of_line();
6172            let handles_before = decoder.remaining_handles();
6173            if let Some((inlined, num_bytes, num_handles)) =
6174                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6175            {
6176                let member_inline_size = <fidl::encoding::HandleType<
6177                    fidl::Event,
6178                    { fidl::ObjectType::EVENT.into_raw() },
6179                    2147483648,
6180                > as fidl::encoding::TypeMarker>::inline_size(
6181                    decoder.context
6182                );
6183                if inlined != (member_inline_size <= 4) {
6184                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6185                }
6186                let inner_offset;
6187                let mut inner_depth = depth.clone();
6188                if inlined {
6189                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6190                    inner_offset = next_offset;
6191                } else {
6192                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6193                    inner_depth.increment()?;
6194                }
6195                let val_ref =
6196                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6197                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6198                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6199                {
6200                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6201                }
6202                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6203                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6204                }
6205            }
6206
6207            next_offset += envelope_size;
6208
6209            // Decode the remaining unknown envelopes.
6210            while next_offset < end_offset {
6211                _next_ordinal_to_read += 1;
6212                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6213                next_offset += envelope_size;
6214            }
6215
6216            Ok(())
6217        }
6218    }
6219
6220    impl ExecutionStateManagerAddApplicationActivityDependencyRequest {
6221        #[inline(always)]
6222        fn max_ordinal_present(&self) -> u64 {
6223            if let Some(_) = self.power_level {
6224                return 2;
6225            }
6226            if let Some(_) = self.dependency_token {
6227                return 1;
6228            }
6229            0
6230        }
6231    }
6232
6233    impl fidl::encoding::ResourceTypeMarker
6234        for ExecutionStateManagerAddApplicationActivityDependencyRequest
6235    {
6236        type Borrowed<'a> = &'a mut Self;
6237        fn take_or_borrow<'a>(
6238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6239        ) -> Self::Borrowed<'a> {
6240            value
6241        }
6242    }
6243
6244    unsafe impl fidl::encoding::TypeMarker
6245        for ExecutionStateManagerAddApplicationActivityDependencyRequest
6246    {
6247        type Owned = Self;
6248
6249        #[inline(always)]
6250        fn inline_align(_context: fidl::encoding::Context) -> usize {
6251            8
6252        }
6253
6254        #[inline(always)]
6255        fn inline_size(_context: fidl::encoding::Context) -> usize {
6256            16
6257        }
6258    }
6259
6260    unsafe impl
6261        fidl::encoding::Encode<
6262            ExecutionStateManagerAddApplicationActivityDependencyRequest,
6263            fidl::encoding::DefaultFuchsiaResourceDialect,
6264        > for &mut ExecutionStateManagerAddApplicationActivityDependencyRequest
6265    {
6266        unsafe fn encode(
6267            self,
6268            encoder: &mut fidl::encoding::Encoder<
6269                '_,
6270                fidl::encoding::DefaultFuchsiaResourceDialect,
6271            >,
6272            offset: usize,
6273            mut depth: fidl::encoding::Depth,
6274        ) -> fidl::Result<()> {
6275            encoder
6276                .debug_check_bounds::<ExecutionStateManagerAddApplicationActivityDependencyRequest>(
6277                    offset,
6278                );
6279            // Vector header
6280            let max_ordinal: u64 = self.max_ordinal_present();
6281            encoder.write_num(max_ordinal, offset);
6282            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6283            // Calling encoder.out_of_line_offset(0) is not allowed.
6284            if max_ordinal == 0 {
6285                return Ok(());
6286            }
6287            depth.increment()?;
6288            let envelope_size = 8;
6289            let bytes_len = max_ordinal as usize * envelope_size;
6290            #[allow(unused_variables)]
6291            let offset = encoder.out_of_line_offset(bytes_len);
6292            let mut _prev_end_offset: usize = 0;
6293            if 1 > max_ordinal {
6294                return Ok(());
6295            }
6296
6297            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6298            // are envelope_size bytes.
6299            let cur_offset: usize = (1 - 1) * envelope_size;
6300
6301            // Zero reserved fields.
6302            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6303
6304            // Safety:
6305            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6306            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6307            //   envelope_size bytes, there is always sufficient room.
6308            fidl::encoding::encode_in_envelope_optional::<
6309                fidl::encoding::HandleType<
6310                    fidl::Event,
6311                    { fidl::ObjectType::EVENT.into_raw() },
6312                    2147483648,
6313                >,
6314                fidl::encoding::DefaultFuchsiaResourceDialect,
6315            >(
6316                self.dependency_token.as_mut().map(
6317                    <fidl::encoding::HandleType<
6318                        fidl::Event,
6319                        { fidl::ObjectType::EVENT.into_raw() },
6320                        2147483648,
6321                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6322                ),
6323                encoder,
6324                offset + cur_offset,
6325                depth,
6326            )?;
6327
6328            _prev_end_offset = cur_offset + envelope_size;
6329            if 2 > max_ordinal {
6330                return Ok(());
6331            }
6332
6333            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6334            // are envelope_size bytes.
6335            let cur_offset: usize = (2 - 1) * envelope_size;
6336
6337            // Zero reserved fields.
6338            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6339
6340            // Safety:
6341            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6342            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6343            //   envelope_size bytes, there is always sufficient room.
6344            fidl::encoding::encode_in_envelope_optional::<
6345                u8,
6346                fidl::encoding::DefaultFuchsiaResourceDialect,
6347            >(
6348                self.power_level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
6349                encoder,
6350                offset + cur_offset,
6351                depth,
6352            )?;
6353
6354            _prev_end_offset = cur_offset + envelope_size;
6355
6356            Ok(())
6357        }
6358    }
6359
6360    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6361        for ExecutionStateManagerAddApplicationActivityDependencyRequest
6362    {
6363        #[inline(always)]
6364        fn new_empty() -> Self {
6365            Self::default()
6366        }
6367
6368        unsafe fn decode(
6369            &mut self,
6370            decoder: &mut fidl::encoding::Decoder<
6371                '_,
6372                fidl::encoding::DefaultFuchsiaResourceDialect,
6373            >,
6374            offset: usize,
6375            mut depth: fidl::encoding::Depth,
6376        ) -> fidl::Result<()> {
6377            decoder.debug_check_bounds::<Self>(offset);
6378            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6379                None => return Err(fidl::Error::NotNullable),
6380                Some(len) => len,
6381            };
6382            // Calling decoder.out_of_line_offset(0) is not allowed.
6383            if len == 0 {
6384                return Ok(());
6385            };
6386            depth.increment()?;
6387            let envelope_size = 8;
6388            let bytes_len = len * envelope_size;
6389            let offset = decoder.out_of_line_offset(bytes_len)?;
6390            // Decode the envelope for each type.
6391            let mut _next_ordinal_to_read = 0;
6392            let mut next_offset = offset;
6393            let end_offset = offset + bytes_len;
6394            _next_ordinal_to_read += 1;
6395            if next_offset >= end_offset {
6396                return Ok(());
6397            }
6398
6399            // Decode unknown envelopes for gaps in ordinals.
6400            while _next_ordinal_to_read < 1 {
6401                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6402                _next_ordinal_to_read += 1;
6403                next_offset += envelope_size;
6404            }
6405
6406            let next_out_of_line = decoder.next_out_of_line();
6407            let handles_before = decoder.remaining_handles();
6408            if let Some((inlined, num_bytes, num_handles)) =
6409                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6410            {
6411                let member_inline_size = <fidl::encoding::HandleType<
6412                    fidl::Event,
6413                    { fidl::ObjectType::EVENT.into_raw() },
6414                    2147483648,
6415                > as fidl::encoding::TypeMarker>::inline_size(
6416                    decoder.context
6417                );
6418                if inlined != (member_inline_size <= 4) {
6419                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6420                }
6421                let inner_offset;
6422                let mut inner_depth = depth.clone();
6423                if inlined {
6424                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6425                    inner_offset = next_offset;
6426                } else {
6427                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6428                    inner_depth.increment()?;
6429                }
6430                let val_ref =
6431                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6432                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6433                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6434                {
6435                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6436                }
6437                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6438                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6439                }
6440            }
6441
6442            next_offset += envelope_size;
6443            _next_ordinal_to_read += 1;
6444            if next_offset >= end_offset {
6445                return Ok(());
6446            }
6447
6448            // Decode unknown envelopes for gaps in ordinals.
6449            while _next_ordinal_to_read < 2 {
6450                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6451                _next_ordinal_to_read += 1;
6452                next_offset += envelope_size;
6453            }
6454
6455            let next_out_of_line = decoder.next_out_of_line();
6456            let handles_before = decoder.remaining_handles();
6457            if let Some((inlined, num_bytes, num_handles)) =
6458                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6459            {
6460                let member_inline_size =
6461                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6462                if inlined != (member_inline_size <= 4) {
6463                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6464                }
6465                let inner_offset;
6466                let mut inner_depth = depth.clone();
6467                if inlined {
6468                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6469                    inner_offset = next_offset;
6470                } else {
6471                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6472                    inner_depth.increment()?;
6473                }
6474                let val_ref = self.power_level.get_or_insert_with(|| {
6475                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
6476                });
6477                fidl::decode!(
6478                    u8,
6479                    fidl::encoding::DefaultFuchsiaResourceDialect,
6480                    val_ref,
6481                    decoder,
6482                    inner_offset,
6483                    inner_depth
6484                )?;
6485                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6486                {
6487                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6488                }
6489                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6490                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6491                }
6492            }
6493
6494            next_offset += envelope_size;
6495
6496            // Decode the remaining unknown envelopes.
6497            while next_offset < end_offset {
6498                _next_ordinal_to_read += 1;
6499                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6500                next_offset += envelope_size;
6501            }
6502
6503            Ok(())
6504        }
6505    }
6506
6507    impl PowerElements {
6508        #[inline(always)]
6509        fn max_ordinal_present(&self) -> u64 {
6510            if let Some(_) = self.application_activity {
6511                return 3;
6512            }
6513            0
6514        }
6515    }
6516
6517    impl fidl::encoding::ResourceTypeMarker for PowerElements {
6518        type Borrowed<'a> = &'a mut Self;
6519        fn take_or_borrow<'a>(
6520            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6521        ) -> Self::Borrowed<'a> {
6522            value
6523        }
6524    }
6525
6526    unsafe impl fidl::encoding::TypeMarker for PowerElements {
6527        type Owned = Self;
6528
6529        #[inline(always)]
6530        fn inline_align(_context: fidl::encoding::Context) -> usize {
6531            8
6532        }
6533
6534        #[inline(always)]
6535        fn inline_size(_context: fidl::encoding::Context) -> usize {
6536            16
6537        }
6538    }
6539
6540    unsafe impl fidl::encoding::Encode<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
6541        for &mut PowerElements
6542    {
6543        unsafe fn encode(
6544            self,
6545            encoder: &mut fidl::encoding::Encoder<
6546                '_,
6547                fidl::encoding::DefaultFuchsiaResourceDialect,
6548            >,
6549            offset: usize,
6550            mut depth: fidl::encoding::Depth,
6551        ) -> fidl::Result<()> {
6552            encoder.debug_check_bounds::<PowerElements>(offset);
6553            // Vector header
6554            let max_ordinal: u64 = self.max_ordinal_present();
6555            encoder.write_num(max_ordinal, offset);
6556            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6557            // Calling encoder.out_of_line_offset(0) is not allowed.
6558            if max_ordinal == 0 {
6559                return Ok(());
6560            }
6561            depth.increment()?;
6562            let envelope_size = 8;
6563            let bytes_len = max_ordinal as usize * envelope_size;
6564            #[allow(unused_variables)]
6565            let offset = encoder.out_of_line_offset(bytes_len);
6566            let mut _prev_end_offset: usize = 0;
6567            if 3 > max_ordinal {
6568                return Ok(());
6569            }
6570
6571            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6572            // are envelope_size bytes.
6573            let cur_offset: usize = (3 - 1) * envelope_size;
6574
6575            // Zero reserved fields.
6576            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6577
6578            // Safety:
6579            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6580            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6581            //   envelope_size bytes, there is always sufficient room.
6582            fidl::encoding::encode_in_envelope_optional::<
6583                ApplicationActivity,
6584                fidl::encoding::DefaultFuchsiaResourceDialect,
6585            >(
6586                self.application_activity.as_mut().map(
6587                    <ApplicationActivity as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6588                ),
6589                encoder,
6590                offset + cur_offset,
6591                depth,
6592            )?;
6593
6594            _prev_end_offset = cur_offset + envelope_size;
6595
6596            Ok(())
6597        }
6598    }
6599
6600    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {
6601        #[inline(always)]
6602        fn new_empty() -> Self {
6603            Self::default()
6604        }
6605
6606        unsafe fn decode(
6607            &mut self,
6608            decoder: &mut fidl::encoding::Decoder<
6609                '_,
6610                fidl::encoding::DefaultFuchsiaResourceDialect,
6611            >,
6612            offset: usize,
6613            mut depth: fidl::encoding::Depth,
6614        ) -> fidl::Result<()> {
6615            decoder.debug_check_bounds::<Self>(offset);
6616            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6617                None => return Err(fidl::Error::NotNullable),
6618                Some(len) => len,
6619            };
6620            // Calling decoder.out_of_line_offset(0) is not allowed.
6621            if len == 0 {
6622                return Ok(());
6623            };
6624            depth.increment()?;
6625            let envelope_size = 8;
6626            let bytes_len = len * envelope_size;
6627            let offset = decoder.out_of_line_offset(bytes_len)?;
6628            // Decode the envelope for each type.
6629            let mut _next_ordinal_to_read = 0;
6630            let mut next_offset = offset;
6631            let end_offset = offset + bytes_len;
6632            _next_ordinal_to_read += 1;
6633            if next_offset >= end_offset {
6634                return Ok(());
6635            }
6636
6637            // Decode unknown envelopes for gaps in ordinals.
6638            while _next_ordinal_to_read < 3 {
6639                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6640                _next_ordinal_to_read += 1;
6641                next_offset += envelope_size;
6642            }
6643
6644            let next_out_of_line = decoder.next_out_of_line();
6645            let handles_before = decoder.remaining_handles();
6646            if let Some((inlined, num_bytes, num_handles)) =
6647                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6648            {
6649                let member_inline_size =
6650                    <ApplicationActivity as fidl::encoding::TypeMarker>::inline_size(
6651                        decoder.context,
6652                    );
6653                if inlined != (member_inline_size <= 4) {
6654                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6655                }
6656                let inner_offset;
6657                let mut inner_depth = depth.clone();
6658                if inlined {
6659                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6660                    inner_offset = next_offset;
6661                } else {
6662                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6663                    inner_depth.increment()?;
6664                }
6665                let val_ref = self.application_activity.get_or_insert_with(|| {
6666                    fidl::new_empty!(
6667                        ApplicationActivity,
6668                        fidl::encoding::DefaultFuchsiaResourceDialect
6669                    )
6670                });
6671                fidl::decode!(
6672                    ApplicationActivity,
6673                    fidl::encoding::DefaultFuchsiaResourceDialect,
6674                    val_ref,
6675                    decoder,
6676                    inner_offset,
6677                    inner_depth
6678                )?;
6679                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6680                {
6681                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6682                }
6683                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6684                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6685                }
6686            }
6687
6688            next_offset += envelope_size;
6689
6690            // Decode the remaining unknown envelopes.
6691            while next_offset < end_offset {
6692                _next_ordinal_to_read += 1;
6693                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6694                next_offset += envelope_size;
6695            }
6696
6697            Ok(())
6698        }
6699    }
6700}