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